Skip to content

Commit

Permalink
chore(cleanup): Remove unneeded ItemId from states.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Nov 5, 2023
1 parent 0e75d8b commit 67ad5c6
Show file tree
Hide file tree
Showing 21 changed files with 16 additions and 47 deletions.
8 changes: 4 additions & 4 deletions VisualPinball.Unity/VisualPinball.Unity/Game/PhysicsCycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,31 @@ internal void Simulate(ref PhysicsState state, in AABB playfieldBounds, ref Nati
using (var enumerator = state.FlipperStates.GetEnumerator()) {
while (enumerator.MoveNext()) {
ref var flipperState = ref enumerator.Current.Value;
FlipperDisplacementPhysics.UpdateDisplacement(flipperState.ItemId, ref flipperState.Movement,
FlipperDisplacementPhysics.UpdateDisplacement(enumerator.Current.Key, ref flipperState.Movement,
ref flipperState.Tricks, in flipperState.Static, hitTime, ref state.EventQueue);
}
}
// gates
using (var enumerator = state.GateStates.GetEnumerator()) {
while (enumerator.MoveNext()) {
ref var gateState = ref enumerator.Current.Value;
GateDisplacementPhysics.UpdateDisplacement(gateState.ItemId, ref gateState.Movement, in gateState.Static,
GateDisplacementPhysics.UpdateDisplacement(enumerator.Current.Key, ref gateState.Movement, in gateState.Static,
hitTime, ref state.EventQueue);
}
}
// plunger
using (var enumerator = state.PlungerStates.GetEnumerator()) {
while (enumerator.MoveNext()) {
ref var plungerState = ref enumerator.Current.Value;
PlungerDisplacementPhysics.UpdateDisplacement(plungerState.ItemId, ref plungerState.Movement, ref plungerState.Collider,
PlungerDisplacementPhysics.UpdateDisplacement(enumerator.Current.Key, ref plungerState.Movement, ref plungerState.Collider,
in plungerState.Static, hitTime, ref state.EventQueue);
}
}
// spinners
using (var enumerator = state.SpinnerStates.GetEnumerator()) {
while (enumerator.MoveNext()) {
ref var spinnerState = ref enumerator.Current.Value;
SpinnerDisplacementPhysics.UpdateDisplacement(spinnerState.ItemId, ref spinnerState.Movement, in spinnerState.Static,
SpinnerDisplacementPhysics.UpdateDisplacement(enumerator.Current.Key, ref spinnerState.Movement, in spinnerState.Static,
hitTime, ref state.EventQueue);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ internal BumperState CreateState()
} : default;

return new BumperState(
collComponent ? gameObject.GetInstanceID() : 0,
skirtAnimComponent ? skirtAnimComponent.gameObject.GetInstanceID() : 0,
ringAnimComponent ? ringAnimComponent.gameObject.GetInstanceID() : 0,
staticData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ namespace VisualPinball.Unity
{
internal struct BumperState
{
internal readonly int ItemId;
internal readonly int SkirtItemId;
internal int RingItemId;
internal BumperStaticState Static;
internal BumperRingAnimationState RingAnimation;
internal BumperSkirtAnimationState SkirtAnimation;

public BumperState(int itemId, int skirtItemId, int ringItemId, BumperStaticState @static,
public BumperState(int skirtItemId, int ringItemId, BumperStaticState @static,
BumperRingAnimationState ringAnimation, BumperSkirtAnimationState skirtAnimation)
{
ItemId = itemId;
SkirtItemId = skirtItemId;
RingItemId = ringItemId;
Static = @static;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ internal FlipperState CreateState()
// vpx physics
var d = GetMaterialData(colliderComponent);
var state = new FlipperState(
gameObject.GetInstanceID(),
d,
GetMovementData(d),
GetVelocityData(d),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ namespace VisualPinball.Unity
{
internal struct FlipperState
{
internal readonly int ItemId;
internal FlipperStaticData Static;
internal FlipperMovementState Movement;
internal FlipperVelocityData Velocity;
internal FlipperHitData Hit;
internal FlipperTricksData Tricks;
internal SolenoidState Solenoid;

public FlipperState(int itemId, FlipperStaticData @static, FlipperMovementState movement,
public FlipperState(FlipperStaticData @static, FlipperMovementState movement,
FlipperVelocityData velocity, FlipperHitData hit, FlipperTricksData tricks,
SolenoidState solenoid)
{
ItemId = itemId;
Static = @static;
Movement = movement;
Velocity = velocity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ internal GateState CreateState()
} : default;

return new GateState(
collComponent ? gameObject.GetInstanceID() : 0,
wireComponent ? wireComponent.gameObject.GetInstanceID() : 0,
staticData,
movementData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ namespace VisualPinball.Unity
{
internal struct GateState
{
internal readonly int ItemId;
internal readonly int WireItemId;
internal GateStaticState Static;
internal GateMovementState Movement;

public GateState(int itemId, int wireItemId, GateStaticState @static, GateMovementState movement)
public GateState(int wireItemId, GateStaticState @static, GateMovementState movement)
{
ItemId = itemId;
WireItemId = wireItemId;
Static = @static;
Movement = movement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ internal DropTargetState CreateState()
} : default;

return new DropTargetState(
colliderComponent && animationComponent ? gameObject.GetInstanceID() : 0,
animationComponent ? animationComponent.gameObject.GetInstanceID() : 0,
staticData,
animationData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ namespace VisualPinball.Unity
{
internal struct DropTargetState
{
internal readonly int ItemId;
internal readonly int AnimatedItemId;
internal DropTargetStaticState Static;
internal DropTargetAnimationState Animation;

public DropTargetState(int itemId, int animatedItemId, DropTargetStaticState @static, DropTargetAnimationState animation)
public DropTargetState(int animatedItemId, DropTargetStaticState @static, DropTargetAnimationState animation)
{
ItemId = itemId;
AnimatedItemId = animatedItemId;
Static = @static;
Animation = animation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ internal HitTargetState CreateState()
} : default;

return new HitTargetState(
hitTargetColliderComponent && hitTargetAnimationComponent ? gameObject.GetInstanceID() : 0,
hitTargetAnimationComponent ? hitTargetAnimationComponent.gameObject.GetInstanceID() : 0,
staticData,
animationData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ namespace VisualPinball.Unity
{
internal struct HitTargetState
{
internal readonly int ItemId;
internal readonly int AnimatedItemId;
internal HitTargetStaticData Static;
internal HitTargetAnimationData Animation;

public HitTargetState(int itemId, int animatedItemId, HitTargetStaticData @static, HitTargetAnimationData animation)
public HitTargetState(int animatedItemId, HitTargetStaticData @static, HitTargetAnimationData animation)
{
ItemId = itemId;
AnimatedItemId = animatedItemId;
Static = @static;
Animation = animation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ internal KickerState CreateState()
: new ColliderMeshData(KickerHitMesh.Vertices, Radius, new float3(Center.x, Center.y, height), Allocator.Persistent);

return new KickerState(
colliderComponent ? colliderComponent.gameObject.GetInstanceID() : 0,
staticData,
new KickerCollisionState(),
meshData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ namespace VisualPinball.Unity
{
internal struct KickerState : IDisposable
{
internal readonly int ItemId;
internal KickerStaticState Static;
internal KickerCollisionState Collision;
internal ColliderMeshData CollisionMesh;

public KickerState(int itemId, KickerStaticState @static, KickerCollisionState collision, ColliderMeshData collisionMesh)
public KickerState(KickerStaticState @static, KickerCollisionState collision, ColliderMeshData collisionMesh)
{
ItemId = itemId;
Static = @static;
Collision = collision;
CollisionMesh = collisionMesh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ internal PlungerState CreateState()
};

return new PlungerState(
gameObject.GetInstanceID(),
new PlungerStaticState {
MomentumXfer = collComponent.MomentumXfer,
ScatterVelocity = collComponent.ScatterVelocity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ namespace VisualPinball.Unity
{
internal struct PlungerState
{
internal readonly int ItemId;
internal PlungerStaticState Static;
internal PlungerColliderState Collider;
internal PlungerMovementState Movement;
internal PlungerVelocityState Velocity;
internal PlungerAnimationState Animation;

public PlungerState(int itemId, PlungerStaticState @static, PlungerColliderState collider, PlungerMovementState movement, PlungerVelocityState velocity, PlungerAnimationState animation)
public PlungerState(PlungerStaticState @static, PlungerColliderState collider, PlungerMovementState movement, PlungerVelocityState velocity, PlungerAnimationState animation)
{
ItemId = itemId;
Static = @static;
Collider = collider;
Movement = movement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ internal SpinnerState CreateState()
} : default;

return new SpinnerState(
collComponent ? gameObject.GetInstanceID() : 0,
animComponent ? animComponent.gameObject.GetInstanceID() : 0,
staticData,
movementData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ namespace VisualPinball.Unity
{
internal struct SpinnerState
{
internal readonly int ItemId;
internal readonly int AnimationItemId;
internal SpinnerStaticState Static;
internal SpinnerMovementState Movement;

public SpinnerState(int itemId, int animationItemId, SpinnerStaticState @static, SpinnerMovementState movement)
public SpinnerState(int animationItemId, SpinnerStaticState @static, SpinnerMovementState movement)
{
ItemId = itemId;
AnimationItemId = animationItemId;
Static = @static;
Movement = movement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ internal SurfaceState CreateState()
return default;
}

return new SurfaceState(gameObject.GetInstanceID(), new LineSlingshotState {
return new SurfaceState(new LineSlingshotState {
IsDisabled = false,
Threshold = collComponent.SlingshotThreshold,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ namespace VisualPinball.Unity
{
internal struct SurfaceState
{
internal readonly int ItemId;
internal LineSlingshotState Slingshot;

public SurfaceState(int itemId, LineSlingshotState slingshot)
public SurfaceState(LineSlingshotState slingshot)
{
ItemId = itemId;
Slingshot = slingshot;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ internal TriggerState CreateState()

if (collComponent.ForFlipper == null) {
return new TriggerState(
gameObject.GetInstanceID(),
animComponent ? animComponent.gameObject.GetInstanceID() : 0,
new TriggerStaticState {
AnimSpeed = animComponent ? animComponent.AnimSpeed : 0,
Expand All @@ -275,7 +274,6 @@ internal TriggerState CreateState()
}

return new TriggerState(
gameObject.GetInstanceID(),
new TriggerStaticState {
AnimSpeed = 0,
Radius = collComponent.HitCircleRadius,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace VisualPinball.Unity
{
internal struct TriggerState : IDisposable
{
internal readonly int ItemId;
internal readonly int AnimatedItemId;
internal TriggerStaticState Static;
internal TriggerMovementState Movement;
Expand All @@ -30,9 +29,8 @@ internal struct TriggerState : IDisposable
/// <summary>
/// Default trigger usage.
/// </summary>
public TriggerState(int itemId, int animatedItemId, TriggerStaticState @static, TriggerMovementState movement, TriggerAnimationState animation)
public TriggerState(int animatedItemId, TriggerStaticState @static, TriggerMovementState movement, TriggerAnimationState animation)
{
ItemId = itemId;
AnimatedItemId = animatedItemId;
Static = @static;
Movement = movement;
Expand All @@ -43,9 +41,8 @@ public TriggerState(int itemId, int animatedItemId, TriggerStaticState @static,
/// <summary>
/// Flipper correction usage.
/// </summary>
public TriggerState(int itemId, TriggerStaticState @static, FlipperCorrectionState flipperCorrection)
public TriggerState(TriggerStaticState @static, FlipperCorrectionState flipperCorrection)
{
ItemId = itemId;
AnimatedItemId = 0;
Static = @static;
Movement = default;
Expand Down

0 comments on commit 67ad5c6

Please sign in to comment.