예제 #1
0
        public bool AddEntity(RuntimeTerraEntity entity)
        {
            if (_entities.Contains(entity))
            {
                return(false);
            }
            else
            {
                _entities.Add(entity);

                foreach (string label in entity.Labels)
                {
                    EntityOnLabelAdded(entity, label);
                }

                if (entity.EntityID == TerraGameResources.Instance.TerraEntityPrefabConfig.PlayerConfig.Data.EntityID)
                {
                    Player = entity;
                }

                entity.OnLabelAdded   += EntityOnLabelAdded;
                entity.OnLabelRemoved += EntityOnLabelRemoved;
                OnAddEntity?.Invoke(entity);
            }

            return(true);
        }
예제 #2
0
        public RuntimeTerraEntity AddEntity(AssembledEntity entity)
        {
            RuntimeTerraEntity newRuntimeEntity = new RuntimeTerraEntity(entity, Game.Instance.GetService <TerraDBService>());

            OnAddEntity?.Invoke(newRuntimeEntity);
            return(newRuntimeEntity);
        }
예제 #3
0
        public bool AddEntity(TerraEntity entity)
        {
            if (_entities.Contains(entity))
            {
                return(false);
            }
            else
            {
                _entities.Add(entity);
                OnAddEntity?.Invoke(entity);
            }

            return(true);
        }
예제 #4
0
파일: EGroup.cs 프로젝트: kuviman/Q
 void Check(Entity entity)
 {
     if (filter(entity))
     {
         if (!entities.Contains(entity))
         {
             entities.Add(entity);
             OnAddEntity?.Invoke(entity);
         }
     }
     else
     {
         if (entities.Contains(entity))
         {
             entities.Remove(entity);
             OnRemoveEntity?.Invoke(entity);
         }
     }
 }
예제 #5
0
        public void AddEntity(long objectId, Guid userGuid, Guid?interactGuid, string name, GameObjectType objectType, GameObjectSubType objectSubType)
        {
            PlayerGameObject gameObject;

            if (_knownEntities.TryRemove(userGuid, out var oldEntity))
            {
                gameObject = new PlayerGameObject(objectId)
                {
                    Name               = name,
                    ObjectType         = objectType,
                    UserGuid           = userGuid,
                    InteractGuid       = interactGuid,
                    ObjectSubType      = objectSubType,
                    CharacterEquipment = oldEntity.CharacterEquipment,
                    CombatStart        = oldEntity.CombatStart,
                    CombatTime         = oldEntity.CombatTime,
                    Damage             = oldEntity.Damage
                }
            }
            ;
            else
            {
                gameObject = new PlayerGameObject(objectId)
                {
                    Name          = name,
                    ObjectType    = objectType,
                    UserGuid      = userGuid,
                    ObjectSubType = objectSubType
                }
            };

            if (_tempCharacterEquipmentData.TryGetValue(objectId, out var characterEquipmentData))
            {
                ResetTempCharacterEquipment();
                gameObject.CharacterEquipment = characterEquipmentData.CharacterEquipment;
                _tempCharacterEquipmentData.TryRemove(objectId, out _);
            }

            _knownEntities.TryAdd(gameObject.UserGuid, gameObject);
            OnAddEntity?.Invoke(gameObject);
        }
예제 #6
0
 public void Add(Entity entity)
 {
     entities[entity.Id] = entity;
     OnAddEntity?.Invoke(entity);
 }
예제 #7
0
 void AddEntity(int entity)
 {
     EntitiesDictionary[entity].was_added = true;
     entities_count++;
     OnAddEntity?.Invoke(entity);
 }