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); }
public RuntimeTerraEntity AddEntity(AssembledEntity entity) { RuntimeTerraEntity newRuntimeEntity = new RuntimeTerraEntity(entity, Game.Instance.GetService <TerraDBService>()); OnAddEntity?.Invoke(newRuntimeEntity); return(newRuntimeEntity); }
public bool AddEntity(TerraEntity entity) { if (_entities.Contains(entity)) { return(false); } else { _entities.Add(entity); OnAddEntity?.Invoke(entity); } return(true); }
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); } } }
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); }
public void Add(Entity entity) { entities[entity.Id] = entity; OnAddEntity?.Invoke(entity); }
void AddEntity(int entity) { EntitiesDictionary[entity].was_added = true; entities_count++; OnAddEntity?.Invoke(entity); }