Summoning
This commit is contained in:
@@ -204,7 +204,7 @@ public sealed partial class DungeonHandler
|
||||
}
|
||||
}
|
||||
|
||||
var simulation = new DungeonSimulation(layout, tier, _mobDefinitions, bracketMin, null, _mobSpriteConfigs);
|
||||
var simulation = new DungeonSimulation(layout, tier, _mobDefinitions, bracketMin, _abilityDefinitions, _mobSpriteConfigs);
|
||||
|
||||
var instance = new DungeonInstance
|
||||
{
|
||||
@@ -497,7 +497,7 @@ public sealed partial class DungeonHandler
|
||||
try
|
||||
{
|
||||
var layout = DungeonGenerator.Generate(persisted.Seed, persisted.Tier);
|
||||
var simulation = new DungeonSimulation(layout, persisted.Tier, _mobDefinitions, persisted.LevelBracketMin, null, _mobSpriteConfigs);
|
||||
var simulation = new DungeonSimulation(layout, persisted.Tier, _mobDefinitions, persisted.LevelBracketMin, _abilityDefinitions, _mobSpriteConfigs);
|
||||
|
||||
// NOTE: We intentionally do NOT restore mob state here.
|
||||
// When a dungeon is restored (all players left), ALL mobs respawn fresh.
|
||||
@@ -571,7 +571,7 @@ public sealed partial class DungeonHandler
|
||||
// Using DungeonGenerator.Generate() would create a V1 layout which has different
|
||||
// room geometry than V2/V3, causing mobs to spawn in wrong positions.
|
||||
var layout = instance.Simulation.Layout;
|
||||
var freshSimulation = new DungeonSimulation(layout, instance.Tier, _mobDefinitions, instance.LevelBracketMin, null, _mobSpriteConfigs);
|
||||
var freshSimulation = new DungeonSimulation(layout, instance.Tier, _mobDefinitions, instance.LevelBracketMin, _abilityDefinitions, _mobSpriteConfigs);
|
||||
|
||||
// Clear and rebuild mobs, keeping those with loot
|
||||
instance.Simulation.Mobs.Clear();
|
||||
|
||||
@@ -25,6 +25,7 @@ public sealed partial class DungeonHandler
|
||||
|
||||
var mobs = await db.Set<DungeonMobDefinition>()
|
||||
.Where(m => m.IsEnabled)
|
||||
.Include(m => m.AbilityAssignments)
|
||||
.ToListAsync();
|
||||
|
||||
if (mobs.Count == 0)
|
||||
@@ -34,12 +35,22 @@ public sealed partial class DungeonHandler
|
||||
|
||||
_mobDefinitions = mobs.ToDictionary(m => m.Id);
|
||||
|
||||
var abilities = await db.Set<MobAbilityDefinition>()
|
||||
.Where(a => a.IsEnabled)
|
||||
.ToListAsync();
|
||||
|
||||
_abilityDefinitions = abilities.ToDictionary(a => a.Id);
|
||||
|
||||
// Build sprite configs from animation assignments
|
||||
var spriteConfigBuilder = new MobSpriteConfigBuilder(db);
|
||||
_mobSpriteConfigs = await spriteConfigBuilder.BuildSpriteConfigsAsync(mobs.Select(m => m.Id));
|
||||
|
||||
// Count animation assignments for debugging
|
||||
var assignmentCount = await db.Set<MobAnimationAssignment>().CountAsync();
|
||||
_log.LogInformation("Refreshed mob cache: {MobCount} mobs, {AssignmentCount} animation assignments", mobs.Count, assignmentCount);
|
||||
_log.LogInformation(
|
||||
"Refreshed mob cache: {MobCount} mobs, {AbilityCount} abilities, {AssignmentCount} animation assignments",
|
||||
mobs.Count,
|
||||
_abilityDefinitions.Count,
|
||||
assignmentCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
|
||||
// Mob definitions cache
|
||||
private Dictionary<int, DungeonMobDefinition> _mobDefinitions = new();
|
||||
private Dictionary<int, MobAbilityDefinition> _abilityDefinitions = new();
|
||||
private Dictionary<int, string?> _mobSpriteConfigs = new(); // MobDefinitionId -> SpriteConfig JSON
|
||||
private bool _initialized = false;
|
||||
|
||||
@@ -677,7 +678,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
var simulation = new DungeonSimulation(layout, tier, _mobDefinitions, bracketMin, null, _mobSpriteConfigs);
|
||||
var simulation = new DungeonSimulation(layout, tier, _mobDefinitions, bracketMin, _abilityDefinitions, _mobSpriteConfigs);
|
||||
|
||||
instance = new DungeonInstance
|
||||
{
|
||||
|
||||
@@ -439,7 +439,8 @@ public partial class DungeonSimulation
|
||||
if (ability == null) return;
|
||||
|
||||
float distance = Distance(mob.X, mob.Y, target.X, target.Y);
|
||||
if (ability.Definition.Range > 0 && distance > ability.Definition.Range) return;
|
||||
bool isSummonAbility = ability.Definition.AbilityType is MobAbilityType.SummonSingle or MobAbilityType.SummonBulk;
|
||||
if (!isSummonAbility && ability.Definition.Range > 0 && distance > ability.Definition.Range) return;
|
||||
|
||||
// Put ability on cooldown
|
||||
ability.CooldownRemaining = ability.Definition.Cooldown;
|
||||
|
||||
Reference in New Issue
Block a user