Esempio n. 1
0
        public static void AddTracking(object obj)
        {
            bool flag = StateTracker.instance != null;

            if (flag)
            {
                foreach (MemberInfo current in Utils.GetMembersInfo(obj.GetType()))
                {
                    object[] customAttributes = current.GetCustomAttributes(true);
                    bool     flag2            = customAttributes != null;
                    if (flag2)
                    {
                        object[] array = customAttributes;
                        for (int i = 0; i < array.Length; i++)
                        {
                            object obj2  = array[i];
                            bool   flag3 = obj2 is AddTracking;
                            if (flag3)
                            {
                                StateTracker.AddTracking(obj, current.Name);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /**
         *  @brief Initializes internal properties based on whether there is a {@link TSCollider2D} attached.
         **/
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            tsCollider = GetComponent <TSCollider2D>();
            if (transform.parent != null)
            {
                tsParent = transform.parent.GetComponent <TSTransform2D>();
            }

            if (!_serialized)
            {
                UpdateEditMode();
            }

            if (tsCollider != null)
            {
                if (tsCollider.IsBodyInitialized)
                {
                    tsCollider.Body.TSPosition    = _position + scaledCenter;
                    tsCollider.Body.TSOrientation = _rotation * FP.Deg2Rad;
                }
            }
            else
            {
                StateTracker.AddTracking(this);
            }

            initialized = true;
        }
Esempio n. 3
0
        public static void AddTracking(object obj)
        {
            bool flag = StateTracker.instance != null;

            if (flag)
            {
                List <MemberInfo> membersInfo = Utils.GetMembersInfo(obj.GetType());
                int i     = 0;
                int count = membersInfo.Count;
                while (i < count)
                {
                    MemberInfo memberInfo       = membersInfo[i];
                    object[]   customAttributes = memberInfo.GetCustomAttributes(true);
                    bool       flag2            = customAttributes != null;
                    if (flag2)
                    {
                        int j   = 0;
                        int num = customAttributes.Length;
                        while (j < num)
                        {
                            bool flag3 = customAttributes[j] is AddTracking;
                            if (flag3)
                            {
                                StateTracker.AddTracking(obj, memberInfo.Name);
                            }
                            j++;
                        }
                    }
                    i++;
                }
            }
        }
        /**
         *  @brief Initializes internal properties based on whether there is a {@link TSCollider2D} attached.
         **/
        public void Initialize()
        {
            if (m_Initialized)
            {
                return;
            }

            m_TSCollider = GetComponent <TSCollider2D>();

            if (transform.parent != null)
            {
                m_TSParent = transform.parent.GetComponent <TSTransform2D>();
            }

            if (!m_Serialized)
            {
                UpdateEditMode();
            }

            if (m_TSCollider != null)
            {
                if (m_TSCollider.isBodyInitialized)
                {
                    m_TSCollider.body.TSPosition    = m_Position + m_TSCollider.center;
                    m_TSCollider.body.TSOrientation = m_Rotation * FP.Deg2Rad;
                }
            }
            else
            {
                StateTracker.AddTracking(this);
            }

            m_Initialized = true;
        }
Esempio n. 5
0
        public AbstractLockstep(FP deltaTime, ICommunicator communicator, IPhysicsManager physicsManager, int syncWindow, int panicWindow, int rollbackWindow, TrueSyncEventCallback OnGameStarted, TrueSyncEventCallback OnGamePaused, TrueSyncEventCallback OnGameUnPaused, TrueSyncEventCallback OnGameEnded, TrueSyncPlayerDisconnectionCallback OnPlayerDisconnection, TrueSyncUpdateCallback OnStepUpdate, TrueSyncInputCallback GetLocalData)
        {
            this.deltaTime             = deltaTime;
            this.syncWindow            = syncWindow;
            this.panicWindow           = panicWindow;
            this.rollbackWindow        = rollbackWindow;
            this.totalWindow           = syncWindow + rollbackWindow;
            this.StepUpdate            = OnStepUpdate;
            this.OnGameStarted         = OnGameStarted;
            this.OnGamePaused          = OnGamePaused;
            this.OnGameUnPaused        = OnGameUnPaused;
            this.OnGameEnded           = OnGameEnded;
            this.OnPlayerDisconnection = OnPlayerDisconnection;
            this.GetLocalData          = GetLocalData;
            this.ticks        = 0;
            this.players      = new SortedDictionary <byte, TSPlayer>();
            this.communicator = communicator;
            bool flag = communicator != null;

            if (flag)
            {
                this.communicator.AddEventListener(new OnEventReceived(this.OnEventDataReceived));
            }
            this.physicsManager     = physicsManager;
            this.compoundStats      = new CompoundStats();
            this.bufferSyncedInfo   = new GenericBufferWindow <SyncedInfo>(3);
            this.checksumOk         = true;
            this.simulationState    = AbstractLockstep.SimulationState.NOT_STARTED;
            this.bodiesToDestroy    = new Dictionary <int, List <IBody> >();
            this.delegatesToExecute = new Dictionary <int, List <Delegate> >();
            this.ReplayRecord       = ReplayRecord.replayToLoad;
            this.ReplayMode         = ReplayRecord.replayMode;
            this.time = FP.Zero;
            StateTracker.AddTracking(this, "time");
        }
Esempio n. 6
0
        public static TSRandom New(int seed)
        {
            TSRandom tSRandom = new TSRandom(seed);

            StateTracker.AddTracking(tSRandom, "mt");
            StateTracker.AddTracking(tSRandom, "mti");
            return(tSRandom);
        }
Esempio n. 7
0
        /**
         *  @brief Generates a new instance based on a given seed.
         **/
        public static TSRandom New(int seed)
        {
            TSRandom r = new TSRandom(seed);

            StateTracker.AddTracking(r, "mt");
            StateTracker.AddTracking(r, "mti");

            return(r);
        }
        void Awake()
        {
            TrueSyncConfig currentConfig = ActiveConfig;
            lockedTimeStep = currentConfig.lockedTimeStep;

            StateTracker.Init(currentConfig.rollbackWindow);
            TSRandom.Init();

            if (currentConfig.physics2DEnabled || currentConfig.physics3DEnabled) {
                PhysicsManager.New(currentConfig);
                PhysicsManager.instance.LockedTimeStep = lockedTimeStep;
                PhysicsManager.instance.Init();
            }

            StateTracker.AddTracking(this, "time");
        }
Esempio n. 9
0
        /**
         *  @brief Initializes internal properties based on whether there is a {@link TSCollider} attached.
         **/
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            rb             = GetComponent <TSRigidBody>();
            transformCache = transform;

            tsCollider = GetComponent <TSCollider>();
            if (transformCache.parent != null)
            {
                tsParent = transformCache.parent.GetComponent <TSTransform>();
            }

            foreach (Transform child in transformCache)
            {
                TSTransform tsChild = child.GetComponent <TSTransform>();
                if (tsChild != null)
                {
                    tsChildren.Add(tsChild);
                }
            }

            if (!_serialized)
            {
                UpdateEditMode();
            }

            if (tsCollider != null)
            {
                if (tsCollider.IsBodyInitialized)
                {
                    tsCollider.Body.TSPosition    = _position + scaledCenter;
                    tsCollider.Body.TSOrientation = TSMatrix.CreateFromQuaternion(_rotation);
                }
            }
            else
            {
                StateTracker.AddTracking(this);
            }

            initialized = true;
        }
Esempio n. 10
0
        /**
         *  @brief Initializes internal properties based on whether there is a {@link TSCollider} attached.
         **/
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            tsCollider = GetComponent <TSCollider>();
            if (transform.parent != null)
            {
                tsParent = transform.parent.GetComponent <TSTransform>();
            }

            foreach (Transform child in transform)
            {
                TSTransform tsChild = child.GetComponent <TSTransform>();
                if (tsChild != null)
                {
                    tsChildren.Add(tsChild);
                }
            }

            if (!_serialized)
            {
                UpdateEditMode();
            }

            if (tsCollider != null)
            {
                if (tsCollider.IsBodyInitialized)
                {
                    tsCollider.Body.TSPosition    = transform.position.ToTSVector() + scaledCenter;
                    tsCollider.Body.TSOrientation = transform.rotation.ToTSMatrix();
                    localScale = transform.localScale.ToTSVector();
                }
            }
            else
            {
                StateTracker.AddTracking(this);
            }

            initialized = true;
        }
        /**
         *  @brief Initializes internal properties based on whether there is a {@link TSCollider} attached.
         **/
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            tsCollider = GetComponent <TSCollider>();
            if (transform.parent != null)
            {
                tsParent = transform.parent.GetComponent <TSTransform>();
            }

            foreach (Transform child in transform)
            {
                TSTransform tsChild = child.GetComponent <TSTransform>();
                if (tsChild != null)
                {
                    tsChildren.Add(tsChild);
                }
            }

            if (!_serialized)
            {
                UpdateEditMode();
            }

            if (tsCollider != null)
            {
                if (tsCollider.IsBodyInitialized)
                {
                    tsCollider.Body.TSPosition    = _position + scaledCenter;
                    tsCollider.Body.TSOrientation = TSMatrix.CreateFromQuaternion(_rotation);
                }
            }
            else
            {
                //配合 [AddTracking] Attribute 使用, StateTracker.AddTracking(object obj)通过反射获取obj的成员变量
                StateTracker.AddTracking(this);
            }

            initialized = true;
        }
Esempio n. 12
0
        //=================================================================================================================
        void Awake()
        {
            TrueSyncConfig currentConfig = ActiveConfig;

            lockedTimeStep = currentConfig.lockedTimeStep;

            // 初始化状态跟踪
            StateTracker.Init(currentConfig.rollbackWindow);
            // 初始化随机数
            TSRandom.Init(randomseed);

            // 初始化物理管理器
            if (currentConfig.physics2DEnabled || currentConfig.physics3DEnabled)
            {
                PhysicsManager.New(currentConfig);
                PhysicsManager.instance.LockedTimeStep = lockedTimeStep;
                PhysicsManager.instance.Init();
            }
            // 跟踪 时间
            StateTracker.AddTracking(this, "time");
        }
Esempio n. 13
0
 public TrueSyncManagedBehaviour(ITrueSyncBehaviour trueSyncBehavior)
 {
     StateTracker.AddTracking(this);
     StateTracker.AddTracking(trueSyncBehavior);
     this.trueSyncBehavior = trueSyncBehavior;
 }
Esempio n. 14
0
 public void Initialize()
 {
     StateTracker.AddTracking(this);
     InitTransformCache();
 }
        // LOGIC

        public void Init()
        {
            StateTracker.AddTracking(this);
        }