Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 public static Span <GameEntityHandle> GetReferences(ComponentBoardBase componentBoard, ComponentReference componentReference)
 {
     return(componentBoard.GetReferences(componentReference.Id));
 }
Example #4
0
 public static GameEntityHandle GetOwner(ComponentBoardBase componentBoard, ComponentReference componentReference)
 {
     return(componentBoard.OwnerColumn[(int)componentReference.Id]);
 }
Example #5
0
 public static void SetOwner(ComponentBoardBase componentBoard, ComponentReference componentReference, GameEntityHandle entityHandle)
 {
     componentBoard.OwnerColumn[(int)componentReference.Id] = entityHandle;
 }
Example #6
0
 public static uint CreateComponent(ComponentBoardBase componentBoard)
 {
     return(componentBoard.CreateRow());
 }
Example #7
0
 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++;
         }
     }
 }
Example #8
0
 public bool CanSerialize(GameWorld world, Span <GameEntityHandle> entities, ComponentBoardBase board)
 {
     return(true);
 }