void UpdateMove(EntityBase entity, int deltaTime) { MoveComponent mc = (MoveComponent)entity.GetComp("MoveComponent"); SyncVector3 newPos = mc.pos.DeepCopy(); newPos.x += (mc.dir.x * deltaTime / 1000) * mc.m_velocity / 1000; newPos.y += (mc.dir.y * deltaTime / 1000) * mc.m_velocity / 1000; newPos.z += (mc.dir.z * deltaTime / 1000) * mc.m_velocity / 1000; if (!entity.GetExistComp("FlyObjectComponent") && entity.GetExistComp("CollisionComponent")) { CollisionComponent cc = (CollisionComponent)entity.GetComp("CollisionComponent"); cc.area.position = newPos.ToVector(); if (!IsCollisionBlock(cc.area)) { mc.pos = newPos; } } else { mc.pos = newPos; } if (SyncDebugSystem.isDebug && SyncDebugSystem.IsFilter("MoveSystem")) { string content = "id: " + mc.Entity.ID + " m_pos " + mc.pos.ToVector() + " deltaTime " + deltaTime + " m_velocity " + mc.m_velocity + " m_dir " + mc.dir.ToVector(); //Debug.Log(content); //SyncDebugSystem.syncLog += content + "\n"; } }
public void ClearBefore(int frame) { for (int i = 0; i < m_record.Count; i++) { if (m_record[i].Frame < frame) { if (SyncDebugSystem.isDebug && SyncDebugSystem.IsFilter(typeof(T).Name)) { //Debug.Log(" ClearBefore Frame:" + m_record[i].Frame + " id: " + m_record[i].ID); } m_record.RemoveAt(i); i--; } } }
public override void RevertToFrame(int frame) { RecordComponent <T> rc = m_world.GetSingletonComp <RecordComponent <T> >(); List <T> list = rc.GetRecordList(frame); if (SyncDebugSystem.IsFilter(typeof(T).Name)) { Debug.Log("数据回滚 frame:" + frame + " Count:" + list.Count); } for (int i = 0; i < list.Count; i++) { if (m_world.GetEntityIsExist(list[i].ID)) { EntityBase entity = m_world.GetEntity(list[i].ID); entity.ChangeComp((T)list[i].DeepCopy()); } else if (m_world.GetIsExistCreateRollbackCache(list[i].ID)) { Debug.Log("GetIsExistCreateRollbackCache " + list[i].ID); EntityBase entity = m_world.GetCreateRollbackCache(list[i].ID); entity.ChangeComp((T)list[i].DeepCopy()); } else if (m_world.GetIsExistDestroyRollbackCache(list[i].ID)) { Debug.Log("GetIsExistDestroyRollbackCache " + list[i].ID); EntityBase entity = m_world.GetDestroyRollbackCache(list[i].ID); entity.ChangeComp((T)list[i].DeepCopy()); } else { Debug.Log("没有找到回滚对象 " + list[i].ID + " frame " + frame); } if (SyncDebugSystem.IsFilter(typeof(T).Name)) { Debug.Log("数据回滚 ID:" + list[i].ID + " frame:" + list[i].Frame + " conent:" + Serializer.Serialize(list[i])); } } }
public override void Record(int frame) { RecordComponent <T> rc = m_world.GetSingletonComp <RecordComponent <T> > (); List <EntityBase> list = GetEntityList(); for (int i = 0; i < list.Count; i++) { T record = (T)list[i].GetComp <T>().DeepCopy(); record.Frame = frame; record.ID = list[i].ID; rc.m_record.Add(record); if (SyncDebugSystem.IsFilter(typeof(T).Name)) { Debug.Log("数据记录 ID:" + list[i].ID + " frame:" + frame + " conent:" + Serializer.Serialize(record)); } } }