예제 #1
0
 public override void Update(FrameSyncGame game, FrameSyncInput input, FrameSyncUpdateType updateType)
 {
     foreach (var pair in _behaviours)
     {
         StaticFrameSyncBehaviour behaviour = pair.Value;
         if (!behaviour._isInitialized)
         {
             behaviour.InvokeFrameSyncDataInitialize(game);
         }
         behaviour.InvokeFrameSyncFixedUpdate(input, updateType);
     }
 }
예제 #2
0
        public override int Export(SWBytes buffer)
        {
            int    size           = 0;
            UInt16 behaviourCount = (UInt16)_behaviours.Count;

            buffer.Push(behaviourCount);
            size += 2;

            foreach (var pair in _behaviours)
            {
                UInt16 id = pair.Key;
                StaticFrameSyncBehaviour behaviour = pair.Value;

                buffer.Push(id);
                size += 2;

                size += behaviour.ExportData(buffer);
            }

            return(size);
        }
예제 #3
0
        public override void Import(SWBytes buffer)
        {
            UInt16 behaviourCount = buffer.PopUInt16();

            if (behaviourCount != _behaviours.Count)
            {
                throw new Exception($"StaticFrameSyncBehaviourManager: Import importBehaviourCount={behaviourCount} behaviourCount={ _behaviours.Count}");
            }

            foreach (var pair in _behaviours)
            {
                UInt16 id = pair.Key;
                StaticFrameSyncBehaviour behaviour = pair.Value;

                UInt16 importId = buffer.PopUInt16();

                if (importId != id)
                {
                    throw new Exception($"StaticFrameSyncBehaviourManager: Import importID={importId} id={id}");
                }

                behaviour.ImportData(buffer);
            }
        }
예제 #4
0
 public static void Register(StaticFrameSyncBehaviour staticFrameSyncBehaviour)
 {
     SWConsole.Info($"StaticFrameSyncBehaviourManager: register {staticFrameSyncBehaviour.name}");
     _behaviours.Add(staticFrameSyncBehaviour.FrameSyncBehaviourID, staticFrameSyncBehaviour);
 }