From 95c165ac0784b2ecdb14ba5b2c50ad3de7a6730a Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 1 Feb 2026 10:00:38 -0500 Subject: [PATCH] Summoning --- Game/Dungeon/DungeonHandler.Dungeons.cs | 6 +++--- Game/Dungeon/DungeonHandler.MobCache.cs | 13 ++++++++++++- Game/Dungeon/DungeonHandler.cs | 3 ++- Game/Dungeon/DungeonSimulation.cs | 3 ++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Game/Dungeon/DungeonHandler.Dungeons.cs b/Game/Dungeon/DungeonHandler.Dungeons.cs index 1661742..b08a868 100644 --- a/Game/Dungeon/DungeonHandler.Dungeons.cs +++ b/Game/Dungeon/DungeonHandler.Dungeons.cs @@ -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(); diff --git a/Game/Dungeon/DungeonHandler.MobCache.cs b/Game/Dungeon/DungeonHandler.MobCache.cs index 898f485..3bd23f3 100644 --- a/Game/Dungeon/DungeonHandler.MobCache.cs +++ b/Game/Dungeon/DungeonHandler.MobCache.cs @@ -25,6 +25,7 @@ public sealed partial class DungeonHandler var mobs = await db.Set() .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() + .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().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); } } diff --git a/Game/Dungeon/DungeonHandler.cs b/Game/Dungeon/DungeonHandler.cs index b37776a..3b1ff5a 100644 --- a/Game/Dungeon/DungeonHandler.cs +++ b/Game/Dungeon/DungeonHandler.cs @@ -40,6 +40,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler // Mob definitions cache private Dictionary _mobDefinitions = new(); + private Dictionary _abilityDefinitions = new(); private Dictionary _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 { diff --git a/Game/Dungeon/DungeonSimulation.cs b/Game/Dungeon/DungeonSimulation.cs index f34e0dd..394a711 100644 --- a/Game/Dungeon/DungeonSimulation.cs +++ b/Game/Dungeon/DungeonSimulation.cs @@ -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;