TrueSync
PhysicsManagerFactory.cs
1 namespace TrueSync {
2 
6  public class PhysicsManager {
7 
11  public enum PhysicsType {W_2D, W_3D};
12 
16  public static IPhysicsManager instance;
17 
23  public static IPhysicsManager New(TrueSyncConfig trueSyncConfig) {
24  if (trueSyncConfig.physics3DEnabled) {
25  instance = new PhysicsWorldManager();
26  instance.Gravity = trueSyncConfig.gravity3D;
27  instance.SpeculativeContacts = trueSyncConfig.speculativeContacts3D;
28  } else if (trueSyncConfig.physics2DEnabled) {
29  instance = new Physics2DWorldManager();
30  instance.Gravity = new TSVector(trueSyncConfig.gravity2D.x, trueSyncConfig.gravity2D.y, 0);
31  instance.SpeculativeContacts = trueSyncConfig.speculativeContacts2D;
32  }
33 
34  return instance;
35  }
36 
40  internal static void InitTest3D() {
41  instance = new PhysicsWorldManager();
42  instance.Gravity = new TSVector(0, -10, 0);
43  instance.LockedTimeStep = 0.02f;
44  instance.Init();
45  }
46 
50  internal static void InitTest2D() {
51  instance = new Physics2DWorldManager();
52  instance.Gravity = new TSVector(0, -10, 0);
53  instance.LockedTimeStep = 0.02f;
54  instance.Init();
55  }
56 
57  }
58 
59 }
TSVector2 gravity2D
Represents the simulated gravity.
PhysicsType
Indicates the type of physics simulations: 2D or 3D.
bool speculativeContacts2D
If true enables a deeper collision detection system.
static IPhysicsManager instance
Returns a proper implementation of IPhysicsManager.
A vector structure.
Definition: TSVector.cs:29
bool physics3DEnabled
Indicates if the 3D physics engine should be enabled.
Manages the 3D physics simulation.
TSVector gravity3D
Represents the simulated gravity.
static IPhysicsManager New(TrueSyncConfig trueSyncConfig)
Instantiates a new IPhysicsManager.
Represents a set of configurations for TrueSync.
bool speculativeContacts3D
If true enables a deeper collision detection system.
Manages the 2D physics simulation.
Manages physics simulation.
bool physics2DEnabled
Indicates if the 2D physics engine should be enabled.