| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- namespace ET
- {
- [FriendOf(typeof(Room))]
- public static class RoomSystem
- {
- public static void Init(this Room self, Room2C_Start room2CStart)
- {
- self.StartTime = room2CStart.StartTime;
-
- self.FixedTimeCounter = new FixedTimeCounter(self.StartTime, 0, LSConstValue.UpdateInterval);
- LSWorld lsWorld = self.GetComponent<LSWorld>();
- lsWorld.AddComponent<LSUnitComponent>();
- for (int i = 0; i < room2CStart.UnitInfo.Count; ++i)
- {
- LockStepUnitInfo unitInfo = room2CStart.UnitInfo[i];
- LSUnitFactory.Init(lsWorld, unitInfo);
- self.PlayerIds.Add(unitInfo.PlayerId);
- }
- }
- public static void Update(this Room self, OneFrameMessages oneFrameMessages, int frame)
- {
- LSWorld lsWorld = self.GetComponent<LSWorld>();
- // 保存当前帧场景数据
- self.FrameBuffer.SaveLSWorld(frame, lsWorld);
-
- // 设置输入到每个LSUnit身上
- LSUnitComponent unitComponent = lsWorld.GetComponent<LSUnitComponent>();
- foreach (var kv in oneFrameMessages.Inputs)
- {
- LSUnit lsUnit = unitComponent.GetChild<LSUnit>(kv.Key);
- LSInputComponent lsInputComponent = lsUnit.GetComponent<LSInputComponent>();
- lsInputComponent.LSInput = kv.Value;
- }
-
- lsWorld.Update();
- }
- }
- }
|