public override void OnEntityDestroy(EntityBase entity) { RecordComponent rc = m_world.GetSingletonComp <RecordComponent>(); ChangeRecordInfo info = new ChangeRecordInfo(); info.m_type = ChangeType.DestroyEntity; info.m_EnityID = entity.ID; rc.m_changeCache.Add(info); }
public override void OnEntityCompRemove(EntityBase entity, string compName, ComponentBase component) { RecordComponent rc = m_world.GetSingletonComp <RecordComponent>(); ChangeRecordInfo info = new ChangeRecordInfo(); info.m_type = ChangeType.RemoveComp; info.m_EnityID = entity.ID; info.m_compName = compName; info.m_comp = component; rc.m_changeCache.Add(info); }
public void RevertByChangeRecordInfo(ChangeRecordInfo info) { switch (info.m_type) { case ChangeType.AddComp: RevertAddComp(info); break; case ChangeType.ChangeComp: RevertChangeComp(info); break; case ChangeType.RemoveComp: RevertRemoveComp(info); break; case ChangeType.CreateEntity: RevertCreateEntity(info); break; case ChangeType.DestroyEntity: RevertDestroyEntity(info); break; } }
public void RevertDestroyEntity(ChangeRecordInfo info) { m_world.CreateEntity(info.m_EnityID); }
public void RevertRemoveComp(ChangeRecordInfo info) { EntityBase entity = m_world.GetEntity(info.m_EnityID); entity.AddComp(info.m_compName, info.m_comp); }