TrueSync: TrueSyncConfig.cs Source File

TrueSync

TrueSyncConfig.cs
1 using UnityEngine;
2 
3 namespace TrueSync {
4 
8  public class TrueSyncConfig : ScriptableObject {
9 
10  private const int COLLISION_LAYERS = 32;
11  // 32 layers -> 516 unique intersections
12  private const int COLLISION_TOGGLES = 516;
13 
17  public int syncWindow = 10;
18 
22  public int rollbackWindow = 0;
23 
27  public int panicWindow = 100;
28 
32  public bool physics2DEnabled = true;
33 
37  public bool[] physics2DIgnoreMatrix = new bool[COLLISION_TOGGLES];
38 
42  public TSVector2 gravity2D = new TSVector2(0, -10);
43 
47  public bool speculativeContacts2D = false;
48 
52  public bool physics3DEnabled = true;
53 
57  public bool[] physics3DIgnoreMatrix = new bool[COLLISION_TOGGLES];
58 
62  public TSVector gravity3D = new TSVector(0, -10, 0);
63 
67  public bool speculativeContacts3D = false;
68 
72  public bool showStats = false;
73 
77  public FP lockedTimeStep = 0.02f;
78 
79  public TrueSyncConfig() {
80  }
81 
85  public bool GetIgnoreLayerCollision(int layerA, int layerB) {
86  if (layerB < layerA) {
87  int aux = layerA;
88  layerA = layerB;
89  layerB = aux;
90  }
91 
92  int matrixIndex = ((COLLISION_LAYERS + COLLISION_LAYERS - layerA + 1) * layerA) / 2 + layerB;
93 
94  if (physics2DEnabled) {
95  return physics2DIgnoreMatrix[matrixIndex];
96  } else if (physics3DEnabled) {
97  return physics3DIgnoreMatrix[matrixIndex];
98  }
99 
100  return false;
101  }
102 
103  }
104 
105 }
int rollbackWindow
Rollback window size.
TSVector2 gravity2D
Represents the simulated gravity.
bool GetIgnoreLayerCollision(int layerA, int layerB)
Returns true if the collision between layerA and layerB should be ignored.
bool[] physics3DIgnoreMatrix
Holds which layers should be ingnored in 3D collisions.
bool speculativeContacts2D
If true enables a deeper collision detection system.
bool physics3DEnabled
Indicates if the 3D physics engine should be enabled.
TSVector gravity3D
Represents the simulated gravity.
Represents a set of configurations for TrueSync.
int panicWindow
Maximum number of ticks to wait until all other players inputs arrive.
bool speculativeContacts3D
If true enables a deeper collision detection system.
bool showStats
When true shows a debug interface with a few information.
FP lockedTimeStep
Time between each TrueSync&#39;s frame.
bool[] physics2DIgnoreMatrix
Holds which layers should be ingnored in 2D collisions.
bool physics2DEnabled
Indicates if the 2D physics engine should be enabled.
int syncWindow
Synchronization window size.
Generated by   doxygen 1.8.11