Ejemplo n.º 1
0
 public EntityComponentInitializer BuildEntity <T>
     (uint entityID, BuildGroup groupStructId, T descriptorEntity, IEnumerable <object> implementors)
     where T : IEntityDescriptor
 {
     return(_enginesRoot.Target.BuildEntity(new EGID(entityID, groupStructId)
                                            , descriptorEntity.componentsToBuild, TypeCache <T> .type, implementors));
 }
Ejemplo n.º 2
0
        public void SwapEntity(EGID from, BuildGroup to, int threadIndex)
        {
            var simpleNativeBag = _swapQueue.GetBuffer(threadIndex);

            simpleNativeBag.Enqueue(_indexSwap);
            simpleNativeBag.Enqueue(new DoubleEGID(from, new EGID(from.entityID, to)));
        }
Ejemplo n.º 3
0
            public void RemoveEntitiesFromGroup(BuildGroup groupID)
            {
                DBC.ECS.Check.Require(groupID != 0, "invalid group detected");
                _enginesRoot.Target.RemoveGroupID(groupID);

                _enginesRoot.Target.QueueEntitySubmitOperation(
                    new EntitySubmitOperation(EntitySubmitOperationType.RemoveGroup, new EGID(0, groupID), new EGID()));
            }
Ejemplo n.º 4
0
        public NativeEntityComponentInitializer BuildEntity
            (uint eindex, BuildGroup BuildGroup, int threadIndex)
        {
            NativeBag unsafeBuffer = _addOperationQueue.GetBuffer(threadIndex + 1);

            unsafeBuffer.Enqueue(_index);
            unsafeBuffer.Enqueue(new EGID(eindex, BuildGroup));
            unsafeBuffer.ReserveEnqueue <uint>(out var index) = 0;

            return(new NativeEntityComponentInitializer(unsafeBuffer, index));
        }
Ejemplo n.º 5
0
            public void SwapEntityGroup <T>(EGID fromID, EGID toID
                                            , BuildGroup mustBeFromGroup)
                where T : IEntityDescriptor, new()
            {
                if (fromID.groupID != mustBeFromGroup)
                {
                    throw new ECSException("Entity is not coming from the expected group");
                }

                SwapEntityGroup <T>(fromID, toID);
            }
Ejemplo n.º 6
0
            public void SwapEntitiesInGroup <T>(BuildGroup fromGroupID, BuildGroup toGroupID)
                where T : IEntityDescriptor, new()
            {
                if (_enginesRoot.Target._groupEntityComponentsDB.TryGetValue(
                        fromGroupID.group, out FasterDictionary <RefWrapperType, ITypeSafeDictionary> entitiesInGroupPerType)
                    == true)
                {
#if DEBUG && !PROFILE_SVELTO
                    IComponentBuilder[] components = EntityDescriptorTemplate <T> .descriptor.componentsToBuild;
                    var dictionary = entitiesInGroupPerType[new RefWrapperType(components[0].GetEntityComponentType())];

                    dictionary.KeysEvaluator((key) =>
                    {
                        _enginesRoot.Target.CheckRemoveEntityID(new EGID(key, fromGroupID), TypeCache <T> .type);
                        _enginesRoot.Target.CheckAddEntityID(new EGID(key, toGroupID), TypeCache <T> .type);
                    });
#endif
                    _enginesRoot.Target.QueueEntitySubmitOperation(
                        new EntitySubmitOperation(EntitySubmitOperationType.SwapGroup, new EGID(0, fromGroupID)
                                                  , new EGID(0, toGroupID)));
                }
            }
Ejemplo n.º 7
0
 public EGID(uint entityID, BuildGroup groupID) : this()
 {
     _GID = MAKE_GLOBAL_ID(entityID, groupID.group);
 }
Ejemplo n.º 8
0
 void RemoveGroupID(BuildGroup groupID)
 {
     _idChecker.Remove(groupID);
 }
Ejemplo n.º 9
0
 public void RemoveEntity <T>(uint entityID, BuildGroup groupID) where T :
 IEntityDescriptor, new()
 {
     RemoveEntity <T>(new EGID(entityID, groupID));
 }
Ejemplo n.º 10
0
 public void SwapEntityGroup <T>(EGID fromID, BuildGroup toGroupID)
     where T : IEntityDescriptor, new()
 {
     SwapEntityGroup <T>(fromID, new EGID(fromID.entityID, (uint)toGroupID));
 }
Ejemplo n.º 11
0
 public void SwapEntityGroup <T>(uint entityID, BuildGroup fromGroupID,
                                 BuildGroup toGroupID)
     where T : IEntityDescriptor, new()
 {
     SwapEntityGroup <T>(new EGID(entityID, fromGroupID), toGroupID);
 }