public static bool RemoveComponentReference(ComponentBoardBase componentBoard, ComponentType componentType, EntityBoardContainer entityBoard, GameEntityHandle entityHandle) { // todo: we need to have a real method for removing the component metadata on the column. var previousComponentId = entityBoard.AssignComponentReference(entityHandle.Id, componentType.Id, 0); if (previousComponentId > 0) { var refs = componentBoard.RemoveReference(previousComponentId, entityHandle); // nobody reference this component anymore, let's remove the row if (refs == 0) { componentBoard.DeleteRow(previousComponentId); } return(true); } return(false); }
public static bool AssignComponent(ComponentBoardBase componentBoard, ComponentReference componentReference, EntityBoardContainer entityBoard, GameEntityHandle entityHandle) { componentBoard.AddReference(componentReference.Id, entityHandle); var previousComponentId = entityBoard.AssignComponentReference(entityHandle.Id, componentReference.Type.Id, componentReference.Id); if (previousComponentId > 0) { var refs = componentBoard.RemoveReference(previousComponentId, entityHandle); // nobody reference this component anymore, let's remove the row if (refs == 0) { componentBoard.DeleteRow(previousComponentId); } return(false); } return(true); }
public static Span <GameEntityHandle> GetReferences(ComponentBoardBase componentBoard, ComponentReference componentReference) { return(componentBoard.GetReferences(componentReference.Id)); }
public static GameEntityHandle GetOwner(ComponentBoardBase componentBoard, ComponentReference componentReference) { return(componentBoard.OwnerColumn[(int)componentReference.Id]); }
public static void SetOwner(ComponentBoardBase componentBoard, ComponentReference componentReference, GameEntityHandle entityHandle) { componentBoard.OwnerColumn[(int)componentReference.Id] = entityHandle; }
public static uint CreateComponent(ComponentBoardBase componentBoard) { return(componentBoard.CreateRow()); }
public void SerializeBoard(ref DataBufferWriter buffer, GameWorld world, Span <GameEntityHandle> entities, ComponentBoardBase board) { Passed = 0; foreach (var entity in entities) { if (world.HasComponent <IntComponent>(entity)) { Passed++; } } }
public bool CanSerialize(GameWorld world, Span <GameEntityHandle> entities, ComponentBoardBase board) { return(true); }