示例#1
0
 private void ProcessMovingAnims()
 {
     for (int i = 0; i < movingControllerInfos.Count; i++)
     {
         MovingControllerInfo value = movingControllerInfos[i];
         if (!((UnityEngine.Object)value.controller == (UnityEngine.Object)null))
         {
             Vector2I vector2I = PosToChunkXY(value.controller.PositionIncludingOffset);
             if (value.chunkXY != vector2I)
             {
                 ControllerChunkInfo value2 = default(ControllerChunkInfo);
                 bool test = controllerChunkInfos.TryGetValue(value.controllerInstanceId, out value2);
                 DebugUtil.Assert(test);
                 DebugUtil.Assert((UnityEngine.Object)value.controller == (UnityEngine.Object)value2.controller);
                 DebugUtil.Assert(value2.chunkXY == value.chunkXY);
                 List <KBatchedAnimController> controllerList = GetControllerList(value2.chunkXY);
                 if (controllerList != null)
                 {
                     DebugUtil.Assert(controllerList.Contains(value2.controller));
                     controllerList.Remove(value2.controller);
                 }
                 controllerList = GetControllerList(vector2I);
                 if (controllerList != null)
                 {
                     DebugUtil.Assert(!controllerList.Contains(value2.controller));
                     controllerList.Add(value2.controller);
                 }
                 value.chunkXY            = vector2I;
                 movingControllerInfos[i] = value;
                 value2.chunkXY           = vector2I;
                 controllerChunkInfos[value.controllerInstanceId] = value2;
                 if (controllerList != null)
                 {
                     value2.controller.SetVisiblity(visibleChunkGrid[vector2I.x, vector2I.y]);
                 }
                 else
                 {
                     value2.controller.SetVisiblity(false);
                 }
             }
         }
     }
 }
示例#2
0
 public void OnMovementStateChanged(Transform transform, bool is_moving)
 {
     if (!((UnityEngine.Object)transform == (UnityEngine.Object)null))
     {
         KBatchedAnimController component = transform.GetComponent <KBatchedAnimController>();
         int controller_instance_id       = component.GetInstanceID();
         ControllerChunkInfo value        = default(ControllerChunkInfo);
         bool test = controllerChunkInfos.TryGetValue(controller_instance_id, out value);
         DebugUtil.Assert(test);
         if (is_moving)
         {
             movingControllerInfos.Add(new MovingControllerInfo
             {
                 controllerInstanceId = controller_instance_id,
                 controller           = component,
                 chunkXY = value.chunkXY
             });
         }
         else
         {
             movingControllerInfos.RemoveAll((MovingControllerInfo x) => x.controllerInstanceId == controller_instance_id);
         }
     }
 }
示例#3
0
    private void ProcessRegistrations()
    {
        ListPool <KBatchedAnimController, KBatchedAnimUpdater> .PooledList pooledList = ListPool <KBatchedAnimController, KBatchedAnimUpdater> .Allocate();

        for (int i = 0; i < queuedRegistrations.Count; i++)
        {
            RegistrationInfo info = queuedRegistrations[i];
            if (info.register)
            {
                if (!((UnityEngine.Object)info.controller == (UnityEngine.Object)null))
                {
                    int instanceID = info.controller.GetInstanceID();
                    DebugUtil.Assert(!controllerChunkInfos.ContainsKey(instanceID));
                    ControllerChunkInfo controllerChunkInfo = default(ControllerChunkInfo);
                    controllerChunkInfo.controller = info.controller;
                    controllerChunkInfo.chunkXY    = PosToChunkXY(info.controller.PositionIncludingOffset);
                    ControllerChunkInfo value = controllerChunkInfo;
                    controllerChunkInfos[instanceID] = value;
                    Singleton <CellChangeMonitor> .Instance.RegisterMovementStateChanged(info.controller.transform, OnMovementStateChanged);

                    List <KBatchedAnimController> controllerList = GetControllerList(value.chunkXY);
                    if (controllerList != null)
                    {
                        DebugUtil.Assert(!controllerList.Contains(info.controller));
                        controllerList.Add(info.controller);
                    }
                    if (Singleton <CellChangeMonitor> .Instance.IsMoving(info.controller.transform))
                    {
                        movingControllerInfos.Add(new MovingControllerInfo
                        {
                            controllerInstanceId = instanceID,
                            controller           = info.controller,
                            chunkXY = value.chunkXY
                        });
                    }
                    if (controllerList != null && visibleChunkGrid[value.chunkXY.x, value.chunkXY.y])
                    {
                        pooledList.Add(info.controller);
                    }
                }
            }
            else
            {
                ControllerChunkInfo value2 = default(ControllerChunkInfo);
                if (controllerChunkInfos.TryGetValue(info.controllerInstanceId, out value2))
                {
                    if ((UnityEngine.Object)info.controller != (UnityEngine.Object)null)
                    {
                        List <KBatchedAnimController> controllerList2 = GetControllerList(value2.chunkXY);
                        if (controllerList2 != null)
                        {
                            DebugUtil.Assert(controllerList2.Contains(info.controller));
                            controllerList2.Remove(info.controller);
                        }
                    }
                    movingControllerInfos.RemoveAll((MovingControllerInfo x) => x.controllerInstanceId == info.controllerInstanceId);
                    Singleton <CellChangeMonitor> .Instance.UnregisterMovementStateChanged(info.transformId, OnMovementStateChanged);

                    controllerChunkInfos.Remove(info.controllerInstanceId);
                    pooledList.Remove(info.controller);
                }
            }
        }
        queuedRegistrations.Clear();
        foreach (KBatchedAnimController item in pooledList)
        {
            if ((UnityEngine.Object)item != (UnityEngine.Object)null)
            {
                item.SetVisiblity(true);
            }
        }
        pooledList.Recycle();
    }