/// <summary> /// Creates a new AiEntityManager from the provided WorldEntity and IMapManager instances. /// </summary> /// <param name="entity">The WorldEntity the created AiEntityManager will control.</param> /// <param name="mapManager">The MapManager for the map that the WorldEntity the AiEntityManager controls exists in.</param> /// <param name="mapBattleManager">The MapBattleManager for the map that the WorldEntity the AiEntityManager controls /// exists in.</param> /// <param name="spawnEntityData">An object containing spawn data for the type of WorldEntity the created manager controls.</param> /// <returns></returns> public AiEntityManager Create(WorldEntity entity, IMapManager mapManager, IMapBattleManager mapBattleManager, SpawnEntityData spawnEntityData) { return(new AiEntityManager(entity, mapManager, mapBattleManager, spawnEntityData)); }
public MapEntityManager(IMapManager mapManager, IMapBattleManager mapBattleManager, IWorldEntityFactory worldEntityFactory, AiEntityManagerFactory aiEntityManagerFactory) { _mapManager = mapManager; _mapBattleManager = mapBattleManager; _mapManager.GameTick += OnGameTick; _worldEntityFactory = worldEntityFactory; _aiEntityManagerFactory = aiEntityManagerFactory; _spawnData = _mapManager.Map.SpawnData; Initialize(); }
public AiEntityManager(WorldEntity entity, IMapManager mapManager, IMapBattleManager mapBattleManager, SpawnEntityData spawnEntityData) { _entity = entity; _mapManager = mapManager; _mapBattleManager = mapBattleManager; _spawnEntityData = spawnEntityData; _rand = new Random(); _mapBattleManager.OnCreatedBattle += OnCreatedBattle; AddToMap(); }
/// <summary> /// Enters the player's WorldEntity into it's last saved location in the last saved map. /// <para>Subscribes to all relevant events in that map.</para> /// </summary> public void BeginPlay() { lock (_lock) { if (!IsActive && _entity != null) { _currentMapManager = _worldState.MapManagers[Entity.CurrentMapId]; _currentMapManager.GameTick += OnGameTick; _mapBattleManager = _worldState.MapBattleManagers[Entity.CurrentMapId]; _mapBattleManager.OnCreatedBattle += OnCreatedBattle; _currentMapManager.TryAddEntity(Entity, Entity.Position); IsActive = true; LastAccessed = DateTime.Now; } // Player just finished battle and came back, request state in case there is no movement else if (IsActive && _entity != null) { _currentMapManager.RequestState(); } } }