Esempio n. 1
0
        // 添加追踪
        public static void AddTracking(object obj, string path)
        {
            bool flag = StateTracker.instance != null;

            if (flag)
            {
                string item  = string.Format("{0}_{1}_{2}", obj.GetType().FullName, obj.GetHashCode(), path);
                bool   flag2 = !StateTracker.instance.trackedInfosAdded.Contains(item);
                if (flag2)
                {
                    StateTracker.TrackedInfo trackedInfo = StateTracker.GetTrackedInfo(obj, path);
                    StateTracker.instance.trackedInfos.Add(trackedInfo);
                    StateTracker.instance.trackedInfosAdded.Add(item);
                    int i    = 0;
                    int size = StateTracker.instance.states.size;
                    while (i < size)
                    {
                        StateTracker.State @new = StateTracker.resourcePool.GetNew();
                        @new.SetInfo(trackedInfo);
                        StateTracker.instance.states.Current().Add(@new);
                        StateTracker.instance.states.MoveNext();
                        i++;
                    }
                }
            }
        }
Esempio n. 2
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++;
                }
            }
        }
Esempio n. 3
0
        /**
         *  @brief Initializes internal properties based on whether there is a {@link TSCollider2D} attached.
         **/
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

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

            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. 4
0
        /**
         *  @brief Generates a new instance based on a given seed.
         **/
        public static FPRandom New(int seed)
        {
            FPRandom r = new FPRandom(seed);

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

            return(r);
        }
Esempio n. 5
0
        void Awake()
        {
            FrameSyncConfig currentConfig = ActiveConfig;

            lockedTimeStep = currentConfig.lockedTimeStep;

            StateTracker.Init(currentConfig.rollbackWindow);

            // TODO: 随机数种子在这里指定,需要修改为由 Server 统一指定
            FPRandom.Init();

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

            StateTracker.AddTracking(this, "time");
        }
 public FrameSyncManagedBehaviour(IFrameSyncBehaviour FrameSyncBehavior)
 {
     StateTracker.AddTracking(this);
     StateTracker.AddTracking(FrameSyncBehavior);
     this.FrameSyncBehavior = FrameSyncBehavior;
 }
Esempio n. 7
0
 // 初始化
 public static void Init(int rollbackWindow)
 {
     StateTracker.instance        = new StateTracker();
     StateTracker.instance.states = new GenericBufferWindow <List <StateTracker.State> >(rollbackWindow);
 }
Esempio n. 8
0
 // 清空
 public static void CleanUp()
 {
     StateTracker.instance = null;
 }
Esempio n. 9
0
 /**
  * @brief Clean up references to be collected by gc.
  **/
 public static void CleanUp()
 {
     ResourcePool.CleanUpAll();
     StateTracker.CleanUp();
     instance = null;
 }