Skip to content

Commit

Permalink
style: Put physics material into blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Jan 30, 2025
1 parent 91c886d commit c8feddc
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void IApiCoil.OnCoil(bool enabled)
IsKinematic = false,
BallId = ballId
};
var physicsMaterialData = ColliderComponent.PhysicsMaterialData;
var random = PhysicsEngine.Random;
BallCollider.Collide3DWall(ref ballState, in physicsMaterialData, in collEvent, in bumpDirection, ref random);
//var physicsMaterialData = ColliderComponent.PhysicsMaterialData;
//var random = PhysicsEngine.;
//BallCollider.Collide3DWall(ref ballState, in physicsMaterialData, in collEvent, in bumpDirection, ref state);
ballState.Velocity += bumpDirection * ColliderComponent.Force;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ public class BumperColliderComponent : ColliderComponent<BumperData, BumperCompo

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.BumperApi ?? new BumperApi(gameObject, player, physicsEngine);
#region Physics Material

protected override float PhysicsElasticity => 1;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => 0;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => true;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.BumperApi ?? new BumperApi(gameObject, player, physicsEngine);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ public class FlipperColliderComponent : ColliderComponent<FlipperData, FlipperCo

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => true;

#endregion

#region FlipperTricks
/// <summary>
/// If set, apply Flipper Tricks Physics (nFozzy/RothBauerW)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public class GateColliderComponent : ColliderComponent<GateData, GateComponent>,

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => 0;
protected override bool PhysicsOverwrite => true;

#endregion

#region IGateColliderData

public float AngleMin { get => _angleMin; set => _angleMin = value; }
Expand All @@ -73,12 +83,6 @@ public class GateColliderComponent : ColliderComponent<GateData, GateComponent>,

#endregion

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => 0;
protected override bool PhysicsOverwrite => true;

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.GateApi ?? new GateApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ public class DropTargetColliderComponent : ColliderComponent<HitTargetData, Targ

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> (MainComponent as DropTargetComponent)?.DropTargetApi ?? new DropTargetApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ public class HitTargetColliderComponent : ColliderComponent<HitTargetData, Targe

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> (MainComponent as HitTargetComponent)?.HitTargetApi ?? new HitTargetApi(gameObject, player, physicsEngine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ public class KickerColliderComponent : ColliderComponent<KickerData, KickerCompo

#endregion

private void Awake()
{
PhysicsEngine = GetComponentInParent<PhysicsEngine>();
}
#region Physics Material

protected override float PhysicsElasticity => 1;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => 0;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => true;

#endregion

private void Awake()
{
PhysicsEngine = GetComponentInParent<PhysicsEngine>();
}

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine) =>
MainComponent.KickerApi ?? new KickerApi(gameObject, player, physicsEngine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ public class MetalWireGuideColliderComponent : ColliderComponent<MetalWireGuideD

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.MetalWireGuideApi ?? new MetalWireGuideApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ public class PlayfieldColliderComponent : ColliderComponent<TableData, Playfield

#endregion

[NonSerialized] public bool ShowAllColliderMeshes = false;
#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => true;

#endregion

[NonSerialized] public bool ShowAllColliderMeshes = false;

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.PlayfieldApi ?? new PlayfieldApi(gameObject, player, physicsEngine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ public class PlungerColliderComponent : ColliderComponent<PlungerData, PlungerCo

#endregion

#region Physics Material

protected override float PhysicsElasticity => 1;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => 0;
protected override float PhysicsScatter => 0;
protected override bool PhysicsOverwrite => true;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.PlungerApi ?? new PlungerApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ public class PrimitiveColliderComponent : ColliderComponent<PrimitiveData, Primi

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=>MainComponent.PrimitiveApi ?? new PrimitiveApi(gameObject, player, physicsEngine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ public class RampColliderComponent : ColliderComponent<RampData, RampComponent>

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.RampApi ?? new RampApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ public class RubberColliderComponent : ColliderComponent<RubberData, RubberCompo

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.RubberApi ?? new RubberApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ public class SpinnerColliderComponent : ColliderComponent<SpinnerData, SpinnerCo

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => 0;
protected override float PhysicsScatter => 0;
protected override bool PhysicsOverwrite => true;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.SpinnerApi ?? new SpinnerApi(gameObject, player, physicsEngine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ public class SurfaceColliderComponent : ColliderComponent<SurfaceData, SurfaceCo

#endregion

#region Physics Material

protected override float PhysicsElasticity => Elasticity;
protected override float PhysicsElasticityFalloff => ElasticityFalloff;
protected override float PhysicsFriction => Friction;
protected override float PhysicsScatter => Scatter;
protected override bool PhysicsOverwrite => OverwritePhysics;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.SurfaceApi ?? new SurfaceApi(gameObject, player, physicsEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ public class TriggerColliderComponent : ColliderComponent<TriggerData, TriggerCo

#endregion

#region Physics Material

protected override float PhysicsElasticity => 1;
protected override float PhysicsElasticityFalloff => 1;
protected override float PhysicsFriction => 0;
protected override float PhysicsScatter => 0;
protected override bool PhysicsOverwrite => true;

#endregion

protected override IApiColliderGenerator InstantiateColliderApi(Player player, PhysicsEngine physicsEngine)
=> MainComponent.TriggerApi ?? new TriggerApi(gameObject, player, physicsEngine);
}
Expand Down

0 comments on commit c8feddc

Please sign in to comment.