TrueSync: TrueSyncBehaviour.cs Source File

TrueSync

TrueSyncBehaviour.cs
1 using System;
2 using UnityEngine;
3 
4 namespace TrueSync {
5 
9  public abstract class TrueSyncBehaviour : MonoBehaviour, ITrueSyncBehaviourGamePlay, ITrueSyncBehaviourCallbacks {
10 
14  [HideInInspector]
15  public int numberOfPlayers;
16 
20  public int ownerIndex = -1;
21 
25  [HideInInspector]
26  public TSPlayerInfo owner;
27 
31  [HideInInspector]
32  public TSPlayerInfo localOwner;
33 
34  private TSTransform _tsTransform;
35 
40  get {
41  if (_tsTransform == null) {
42  _tsTransform = this.GetComponent<TSTransform>();
43  }
44 
45  return _tsTransform;
46  }
47  }
48 
49  private TSTransform2D _tsTransform2D;
50 
55  get {
56  if (_tsTransform2D == null) {
57  _tsTransform2D = this.GetComponent<TSTransform2D>();
58  }
59 
60  return _tsTransform2D;
61  }
62  }
63 
64  private TSRigidBody _tsRigidBody;
65 
70  get {
71  if (_tsRigidBody == null) {
72  _tsRigidBody = this.GetComponent<TSRigidBody>();
73  }
74 
75  return _tsRigidBody;
76  }
77  }
78 
79  private TSRigidBody2D _tsRigidBody2D;
80 
85  get {
86  if (_tsRigidBody2D == null) {
87  _tsRigidBody2D = this.GetComponent<TSRigidBody2D>();
88  }
89 
90  return _tsRigidBody2D;
91  }
92  }
93 
94  private TSCollider _tsCollider;
95 
100  get {
101  if (_tsCollider == null) {
102  _tsCollider = this.GetComponent<TSCollider>();
103  }
104 
105  return _tsCollider;
106  }
107  }
108 
109  private TSCollider2D _tsCollider2D;
110 
115  get {
116  if (_tsCollider2D == null) {
117  _tsCollider2D = this.GetComponent<TSCollider2D>();
118  }
119 
120  return _tsCollider2D;
121  }
122  }
123 
127  public void SetGameInfo(TSPlayerInfo localOwner, int numberOfPlayers) {}
128 
132  public virtual void OnSyncedStart() { }
133 
137  public virtual void OnSyncedStartLocalPlayer() { }
138 
142  public virtual void OnGamePaused() { }
143 
147  public virtual void OnGameUnPaused() { }
148 
152  public virtual void OnGameEnded() { }
153 
159  public virtual void OnPreSyncedUpdate() { }
160 
166  public virtual void OnSyncedUpdate() { }
167 
173  public virtual void OnSyncedInput() { }
174 
178  public virtual void OnPlayerDisconnection(int playerId) {}
179 
180  }
181 
182 }
virtual void OnSyncedInput()
Get local player data.
TSPlayerInfo owner
Basic info about the owner of this behaviour.
TSPlayerInfo localOwner
Basic info about the local player.
TSRigidBody tsRigidBody
Returns the TSRigidBody attached.
virtual void OnSyncedStartLocalPlayer()
Called once on instances owned by the local player after the object becomes active.
A deterministic version of Unity&#39;s Transform component for 2D physics.
Definition: TSTransform2D.cs:9
virtual void OnPreSyncedUpdate()
Called before OnSyncedUpdate.
Represents a physical 3D rigid body.
Definition: TSRigidBody.cs:12
A deterministic version of Unity&#39;s Transform component for 3D physics.
Definition: TSTransform.cs:9
Represents each player&#39;s behaviour simulated on every machine connected to the game.
virtual void OnSyncedUpdate()
Game updates goes here.
TSTransform2D tsTransform2D
Returns the TSTransform2D attached.
Abstract collider for 3D shapes.
Definition: TSCollider.cs:13
int numberOfPlayers
Number of players connected to the game.
TSTransform tsTransform
Returns the TSTransform attached.
void SetGameInfo(TSPlayerInfo localOwner, int numberOfPlayers)
It is not called for instances of TrueSyncBehaviour.
TSRigidBody2D tsRigidBody2D
Returns the TSRigidBody2D attached.
virtual void OnGamePaused()
Called when the game has paused.
int ownerIndex
Index of the owner at initial players list.
Represents a physical 2D rigid body.
virtual void OnGameEnded()
Called when the game has ended.
virtual void OnPlayerDisconnection(int playerId)
Callback called when a player get disconnected.
Abstract collider for 2D shapes.
Definition: TSCollider2D.cs:12
TSCollider2D tsCollider2D
Returns the TSCollider2D attached.
virtual void OnSyncedStart()
Called once when the object becomes active.
virtual void OnGameUnPaused()
Called when the game has unpaused.
TSCollider tsCollider
Returns the TSCollider attached.
Generated by   doxygen 1.8.11