Working on summoning
This commit is contained in:
@@ -26,6 +26,7 @@ public sealed partial class DungeonHandler
|
||||
var mobs = await db.Set<DungeonMobDefinition>()
|
||||
.Where(m => m.IsEnabled)
|
||||
.Include(m => m.AbilityAssignments)
|
||||
.ThenInclude(a => a.AbilityDefinition)
|
||||
.ToListAsync();
|
||||
|
||||
if (mobs.Count == 0)
|
||||
|
||||
@@ -237,26 +237,7 @@ public partial class DungeonSimulation
|
||||
FacingDirection = "down"
|
||||
};
|
||||
|
||||
// Load abilities for this mob
|
||||
if (_abilityDefinitions != null && mobDef.AbilityAssignments != null)
|
||||
{
|
||||
foreach (var assignment in mobDef.AbilityAssignments.Where(a => a.IsEnabled))
|
||||
{
|
||||
if (_abilityDefinitions.TryGetValue(assignment.AbilityDefinitionId, out var abilityDef))
|
||||
{
|
||||
mob.Abilities.Add(new MobAbilityState
|
||||
{
|
||||
AbilityId = abilityDef.Id,
|
||||
Definition = abilityDef,
|
||||
CooldownRemaining = 0,
|
||||
Priority = assignment.PriorityOverride ?? abilityDef.Priority,
|
||||
Phase = assignment.Phase,
|
||||
MinHpPercent = assignment.MinHpPercent,
|
||||
MaxHpPercent = assignment.MaxHpPercent
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadMobAbilities(mob, mobDef);
|
||||
|
||||
// If no abilities loaded, give a basic attack
|
||||
if (mob.Abilities.Count == 0)
|
||||
@@ -537,6 +518,40 @@ public partial class DungeonSimulation
|
||||
RequestMobSummon(summonMobId, spawnX, spawnY, Tier);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMobAbilities(MobInstance mob, DungeonMobDefinition mobDef)
|
||||
{
|
||||
if (mobDef.AbilityAssignments == null) return;
|
||||
|
||||
foreach (var assignment in mobDef.AbilityAssignments.Where(a => a.IsEnabled))
|
||||
{
|
||||
MobAbilityDefinition? abilityDef = null;
|
||||
if (_abilityDefinitions != null)
|
||||
{
|
||||
_abilityDefinitions.TryGetValue(assignment.AbilityDefinitionId, out abilityDef);
|
||||
}
|
||||
|
||||
abilityDef ??= assignment.AbilityDefinition;
|
||||
|
||||
if (abilityDef == null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[DungeonSimulation] Missing ability definition {assignment.AbilityDefinitionId} for mob {mobDef.Id} ({mobDef.Name})");
|
||||
continue;
|
||||
}
|
||||
|
||||
mob.Abilities.Add(new MobAbilityState
|
||||
{
|
||||
AbilityId = abilityDef.Id,
|
||||
Definition = abilityDef,
|
||||
CooldownRemaining = 0,
|
||||
Priority = assignment.PriorityOverride ?? abilityDef.Priority,
|
||||
Phase = assignment.Phase,
|
||||
MinHpPercent = assignment.MinHpPercent,
|
||||
MaxHpPercent = assignment.MaxHpPercent
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMeleeAbility(MobInstance mob, MobAbilityDefinition ability, PlayerInstance target)
|
||||
{
|
||||
@@ -1356,26 +1371,7 @@ public partial class DungeonSimulation
|
||||
Phases = mobDef.Phases
|
||||
};
|
||||
|
||||
// Load abilities for this mob
|
||||
if (_abilityDefinitions != null && mobDef.AbilityAssignments != null)
|
||||
{
|
||||
foreach (var assignment in mobDef.AbilityAssignments.Where(a => a.IsEnabled))
|
||||
{
|
||||
if (_abilityDefinitions.TryGetValue(assignment.AbilityDefinitionId, out var abilityDef))
|
||||
{
|
||||
mob.Abilities.Add(new MobAbilityState
|
||||
{
|
||||
AbilityId = abilityDef.Id,
|
||||
Definition = abilityDef,
|
||||
CooldownRemaining = 0,
|
||||
Priority = assignment.PriorityOverride ?? abilityDef.Priority,
|
||||
Phase = assignment.Phase,
|
||||
MinHpPercent = assignment.MinHpPercent,
|
||||
MaxHpPercent = assignment.MaxHpPercent
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadMobAbilities(mob, mobDef);
|
||||
|
||||
// If no abilities loaded, give a basic attack
|
||||
if (mob.Abilities.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user