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