More Dungeon Features
This commit is contained in:
@@ -39,10 +39,6 @@ public partial class DungeonHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
// Send them back to town
|
||||
// Note: This is a simplified version - in production you'd want to
|
||||
// properly handle player state transitions
|
||||
//dungeon.Simulation.RemovePlayer(player.CharacterId);
|
||||
Console.WriteLine("Remove Player - Not Implemented.");
|
||||
}
|
||||
catch { /* Ignore errors during cleanup */ }
|
||||
@@ -171,6 +167,197 @@ public partial class DungeonHandler
|
||||
|
||||
return mob;
|
||||
}
|
||||
|
||||
// ==================== TILE EDITING ====================
|
||||
|
||||
/// <summary>
|
||||
/// Set a tile's walkability (admin action)
|
||||
/// </summary>
|
||||
public bool SetTileWalkable(Guid dungeonId, int x, int y, bool walkable)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
var layout = dungeon.LayoutV2;
|
||||
if (layout == null)
|
||||
return false;
|
||||
|
||||
if (x < 0 || x >= layout.Width || y < 0 || y >= layout.Height)
|
||||
return false;
|
||||
|
||||
layout.Walkable[x, y] = walkable;
|
||||
|
||||
// Also update the Tiles array (0 = wall, 1 = floor typically)
|
||||
layout.Tiles[x, y] = walkable ? 1 : 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set multiple tiles at once (for painting)
|
||||
/// </summary>
|
||||
public int SetTilesWalkable(Guid dungeonId, List<(int x, int y, bool walkable)> tiles)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return 0;
|
||||
|
||||
var layout = dungeon.LayoutV2;
|
||||
if (layout == null)
|
||||
return 0;
|
||||
|
||||
int count = 0;
|
||||
foreach (var (x, y, walkable) in tiles)
|
||||
{
|
||||
if (x >= 0 && x < layout.Width && y >= 0 && y < layout.Height)
|
||||
{
|
||||
layout.Walkable[x, y] = walkable;
|
||||
layout.Tiles[x, y] = walkable ? 1 : 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill a rectangle with walkable or wall tiles
|
||||
/// </summary>
|
||||
public int FillTileRect(Guid dungeonId, int x1, int y1, int x2, int y2, bool walkable)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return 0;
|
||||
|
||||
var layout = dungeon.LayoutV2;
|
||||
if (layout == null)
|
||||
return 0;
|
||||
|
||||
int minX = Math.Max(0, Math.Min(x1, x2));
|
||||
int maxX = Math.Min(layout.Width - 1, Math.Max(x1, x2));
|
||||
int minY = Math.Max(0, Math.Min(y1, y2));
|
||||
int maxY = Math.Min(layout.Height - 1, Math.Max(y1, y2));
|
||||
|
||||
int count = 0;
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
{
|
||||
layout.Walkable[x, y] = walkable;
|
||||
layout.Tiles[x, y] = walkable ? 1 : 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// ==================== PLAYER MANIPULATION ====================
|
||||
|
||||
/// <summary>
|
||||
/// Get detailed player info (admin)
|
||||
/// </summary>
|
||||
public PlayerInstance? GetPlayer(Guid dungeonId, ulong characterId)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return null;
|
||||
|
||||
dungeon.Simulation.Players.TryGetValue(characterId, out var player);
|
||||
return player;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Teleport a player to a position
|
||||
/// </summary>
|
||||
public bool TeleportPlayer(Guid dungeonId, ulong characterId, float x, float y)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
if (!dungeon.Simulation.Players.TryGetValue(characterId, out var player))
|
||||
return false;
|
||||
|
||||
player.X = x;
|
||||
player.Y = y;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Heal a player to full
|
||||
/// </summary>
|
||||
public bool HealPlayer(Guid dungeonId, ulong characterId)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
if (!dungeon.Simulation.Players.TryGetValue(characterId, out var player))
|
||||
return false;
|
||||
|
||||
player.Health = player.MaxHealth;
|
||||
player.Mana = player.MaxMana;
|
||||
player.Stamina = player.MaxStamina;
|
||||
player.StatusEffects.Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kill a player (admin action)
|
||||
/// </summary>
|
||||
public bool KillPlayer(Guid dungeonId, ulong characterId)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
if (!dungeon.Simulation.Players.TryGetValue(characterId, out var player))
|
||||
return false;
|
||||
|
||||
player.Health = 0;
|
||||
player.IsAlive = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set player health to a specific value
|
||||
/// </summary>
|
||||
public bool SetPlayerHealth(Guid dungeonId, ulong characterId, float health)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
if (!dungeon.Simulation.Players.TryGetValue(characterId, out var player))
|
||||
return false;
|
||||
|
||||
player.Health = Math.Clamp(health, 0, player.MaxHealth);
|
||||
if (player.Health <= 0)
|
||||
player.IsAlive = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a player from the dungeon (kick)
|
||||
/// </summary>
|
||||
public bool KickPlayer(Guid dungeonId, ulong characterId)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
return dungeon.Simulation.Players.TryRemove(characterId, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Give player invulnerability (god mode)
|
||||
/// </summary>
|
||||
public bool SetPlayerInvulnerable(Guid dungeonId, ulong characterId, bool invulnerable)
|
||||
{
|
||||
if (!_dungeons.TryGetValue(dungeonId, out var dungeon))
|
||||
return false;
|
||||
|
||||
if (!dungeon.Simulation.Players.TryGetValue(characterId, out var player))
|
||||
return false;
|
||||
|
||||
// Use a very high armor value for invulnerability
|
||||
// This is a simple approach - a proper implementation would add an Invulnerable flag
|
||||
player.Armor = invulnerable ? 999999 : 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user