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 
52  public void SetGameInfo(TSPlayerInfo localOwner, int numberOfPlayers) {}
53 
57  public virtual void OnSyncedStart() { }
58 
62  public virtual void OnGamePaused() { }
63 
67  public virtual void OnGameUnPaused() { }
68 
72  public virtual void OnGameEnded() { }
73 
79  public virtual void OnPreSyncedUpdate() { }
80 
86  public virtual void OnSyncedUpdate() { }
87 
93  public virtual void OnSyncedInput() { }
94 
98  public virtual void OnPlayerDisconnection(int playerId) {}
99 
100  }
101 
102 }
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.
virtual void OnPreSyncedUpdate()
Called before OnSyncedUpdate.
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.
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.
virtual void OnGamePaused()
Called when the game has paused.
int ownerIndex
Index of the owner at initial players list.
virtual void OnGameEnded()
Called when the game has ended.
virtual void OnPlayerDisconnection(int playerId)
Callback called when a player get disconnected.
virtual void OnSyncedStart()
Called once when the object becomes active.
virtual void OnGameUnPaused()
Called when the game has unpaused.