Admin Fix
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using DataServer.Data.Entities;
|
||||
|
||||
namespace GameServer.Dungeon;
|
||||
|
||||
@@ -67,6 +68,89 @@ public partial class DungeonHandler
|
||||
BossesKilled = dungeons.Count(d => d.BossKilled)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the pre-built sprite config for a mob definition (admin use)
|
||||
/// </summary>
|
||||
public string? GetMobSpriteConfig(int mobDefinitionId)
|
||||
{
|
||||
if (_mobSpriteConfigs.TryGetValue(mobDefinitionId, out var config))
|
||||
return config;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a mob definition by ID (admin use)
|
||||
/// </summary>
|
||||
public DungeonMobDefinition? GetMobDefinition(int mobDefinitionId)
|
||||
{
|
||||
if (_mobDefinitions.TryGetValue(mobDefinitionId, out var def))
|
||||
return def;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawn a mob in a dungeon (admin action)
|
||||
/// Uses the same sprite config system as dungeon generation
|
||||
/// </summary>
|
||||
public MobInstance? SpawnMobInDungeon(Guid dungeonId, int mobDefinitionId, float x, float y)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return null;
|
||||
|
||||
if (!_mobDefinitions.TryGetValue(mobDefinitionId, out var mobDef))
|
||||
return null;
|
||||
|
||||
// Get sprite config from pre-built cache (same as dungeon generation uses)
|
||||
string? spriteConfig = null;
|
||||
if (_mobSpriteConfigs.TryGetValue(mobDefinitionId, out var cachedConfig) && !string.IsNullOrEmpty(cachedConfig))
|
||||
{
|
||||
spriteConfig = cachedConfig;
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteConfig = mobDef.SpriteConfigJson;
|
||||
}
|
||||
|
||||
// Generate unique mob ID
|
||||
var maxId = dungeon.Simulation.Mobs.Keys.DefaultIfEmpty(0).Max();
|
||||
var newMobId = maxId + 1;
|
||||
|
||||
// Use bracket-aware stat scaling
|
||||
var stats = mobDef.GetStatsForBracket(dungeon.LevelBracketMin);
|
||||
|
||||
var mob = new MobInstance
|
||||
{
|
||||
Id = newMobId,
|
||||
DefinitionId = mobDef.Id,
|
||||
Name = mobDef.Name,
|
||||
Type = mobDef.Type,
|
||||
X = x,
|
||||
Y = y,
|
||||
SpawnX = x,
|
||||
SpawnY = y,
|
||||
Health = stats.MaxHealth,
|
||||
MaxHealth = stats.MaxHealth,
|
||||
Mana = mobDef.BaseMana,
|
||||
MaxMana = mobDef.BaseMana,
|
||||
Stats = stats,
|
||||
State = MobState.Idle,
|
||||
StateTime = 0,
|
||||
IsAlive = true,
|
||||
Behavior = mobDef.Behavior,
|
||||
PreferredRange = mobDef.PreferredRange,
|
||||
FleeThreshold = mobDef.FleeThreshold,
|
||||
SpriteConfigJson = spriteConfig,
|
||||
TintColor = mobDef.TintColor ?? "#ffffff",
|
||||
Scale = mobDef.Scale,
|
||||
CurrentAnimation = "idle_down",
|
||||
FacingDirection = "down"
|
||||
};
|
||||
|
||||
dungeon.Simulation.Mobs[newMobId] = mob;
|
||||
|
||||
return mob;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user