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); }