/// <inheritdoc/> public Mob CreateMob(ushort mobId, bool shouldRebirth, MoveArea moveArea) { var scope = _serviceProvider.CreateScope(); var mob = new Mob(mobId, shouldRebirth, moveArea, scope.ServiceProvider.GetRequiredService <ILogger <Mob> >(), scope.ServiceProvider.GetRequiredService <IDatabasePreloader>(), scope.ServiceProvider.GetRequiredService <IAIManager>(), scope.ServiceProvider.GetRequiredService <IItemEnchantConfiguration>(), scope.ServiceProvider.GetRequiredService <IItemCreateConfiguration>(), scope.ServiceProvider.GetRequiredService <ICountryProvider>(), scope.ServiceProvider.GetRequiredService <IStatsManager>(), scope.ServiceProvider.GetRequiredService <IHealthManager>(), scope.ServiceProvider.GetRequiredService <ILevelProvider>(), scope.ServiceProvider.GetRequiredService <ISpeedManager>(), scope.ServiceProvider.GetRequiredService <IAttackManager>(), scope.ServiceProvider.GetRequiredService <ISkillsManager>(), scope.ServiceProvider.GetRequiredService <IBuffsManager>(), scope.ServiceProvider.GetRequiredService <IElementProvider>(), scope.ServiceProvider.GetRequiredService <IMovementManager>(), scope.ServiceProvider.GetRequiredService <IUntouchableManager>(), scope.ServiceProvider.GetRequiredService <IMapProvider>()); mob.Scope = scope; return(mob); }
public Mob(ushort mobId, bool shouldRebirth, MoveArea moveArea, ILogger <Mob> logger, IDatabasePreloader databasePreloader, IAIManager aiManager, IItemEnchantConfiguration enchantConfig, IItemCreateConfiguration itemCreateConfig, ICountryProvider countryProvider, IStatsManager statsManager, IHealthManager healthManager, ILevelProvider levelProvider, ISpeedManager speedManager, IAttackManager attackManager, ISkillsManager skillsManager, IBuffsManager buffsManager, IElementProvider elementProvider, IMovementManager movementManager, IUntouchableManager untouchableManager, IMapProvider mapProvider) : base(databasePreloader, countryProvider, statsManager, healthManager, levelProvider, buffsManager, elementProvider, movementManager, untouchableManager, mapProvider) { _logger = logger; _enchantConfig = enchantConfig; _itemCreateConfig = itemCreateConfig; _dbMob = databasePreloader.Mobs[mobId]; _moveArea = moveArea; AIManager = aiManager; Exp = _dbMob.Exp; ShouldRebirth = shouldRebirth; SpeedManager = speedManager; AttackManager = attackManager; SkillsManager = skillsManager; ElementProvider.ConstAttackElement = _dbMob.Element; ElementProvider.ConstDefenceElement = _dbMob.Element; if (ShouldRebirth) { _rebirthTimer.Interval = RespawnTimeInMilliseconds; _rebirthTimer.Elapsed += RebirthTimer_Elapsed; HealthManager.OnDead += MobRebirth_OnDead; } HealthManager.OnGotDamage += OnDecreaseHP; AIManager.OnStateChanged += AIManager_OnStateChanged; }
public Mob(ushort mobId, bool shouldRebirth, MoveArea moveArea, Map map, ILogger <Mob> logger, IDatabasePreloader databasePreloader) : base(databasePreloader) { _logger = logger; _dbMob = databasePreloader.Mobs[mobId]; Id = map.GenerateId(); CurrentHP = _dbMob.HP; Level = _dbMob.Level; Exp = _dbMob.Exp; AI = _dbMob.AI; ShouldRebirth = shouldRebirth; MoveArea = moveArea; Map = map; PosX = new Random().NextFloat(MoveArea.X1, MoveArea.X2); PosY = new Random().NextFloat(MoveArea.Y1, MoveArea.Y2); PosZ = new Random().NextFloat(MoveArea.Z1, MoveArea.Z2); IsAttack1Enabled = _dbMob.AttackOk1 != 0; IsAttack2Enabled = _dbMob.AttackOk2 != 0; IsAttack3Enabled = _dbMob.AttackOk3 != 0; if (ShouldRebirth) { _rebirthTimer.Interval = RespawnTimeInMilliseconds; _rebirthTimer.Elapsed += RebirthTimer_Elapsed; OnDead += MobRebirth_OnDead; } SetupAITimers(); State = MobState.Idle; }
/// <inheritdoc/> public Mob CreateMob(ushort mobId, bool shouldRebirth, MoveArea moveArea, Map map) { return(new Mob(mobId, shouldRebirth, moveArea, map, _logger, _preloader)); }