Files
systemrevivalserver/Game/Dungeon/PlayerInstance.cs
T
2025-12-27 11:21:00 -05:00

102 lines
3.4 KiB
C#

namespace Server.Game.Dungeon;
/// <summary>
/// Runtime instance of a player in a dungeon
/// </summary>
public class PlayerInstance
{
public ulong CharacterId { get; set; }
public string CharacterName { get; set; } = "";
public float X { get; set; }
public float Y { get; set; }
public float Rotation { get; set; }
public float Health { get; set; }
public float MaxHealth { get; set; }
public float Mana { get; set; }
public float MaxMana { get; set; }
public float Stamina { get; set; }
public float MaxStamina { get; set; }
public float MoveSpeed { get; set; } = 100f;
public float AttackSpeed { get; set; } = 1f;
public int Strength { get; set; }
public int Intelligence { get; set; }
public int Wisdom { get; set; }
public int Endurance { get; set; }
public int Dexterity { get; set; }
// Defensive stats (from gear)
public int Armor { get; set; }
/// <summary>
/// Weapon damage type key (from equipped weapon, defaults to physical for unarmed)
/// </summary>
public string WeaponDamageTypeKey { get; set; } = "physical";
/// <summary>
/// Combined resistances from innate + gear
/// </summary>
public Dictionary<string, float> Resistances { get; set; } = new();
/// <summary>
/// Active status effects on this player
/// </summary>
public List<PlayerStatusEffect> StatusEffects { get; set; } = new();
public bool IsAlive { get; set; } = true;
public bool IsInCombat { get; set; }
// Session stats
public int XpGained { get; set; }
public int MobsKilled { get; set; }
public int PlayersKilled { get; set; }
// Tick tracking
public long LastAttackTick { get; set; }
public long LastCombatTick { get; set; }
// Input state (set by handler)
public float InputX { get; set; }
public float InputY { get; set; }
public bool WantsToAttack { get; set; }
public ulong? AttackTargetId { get; set; }
/// <summary>Check if player is stunned</summary>
public bool IsStunned => StatusEffects.Any(e => e.EffectType == "stun" && e.Duration > 0);
/// <summary>Check if player is rooted</summary>
public bool IsRooted => StatusEffects.Any(e => e.EffectType == "root" && e.Duration > 0);
/// <summary>Check if player is feared</summary>
public bool IsFeared => StatusEffects.Any(e => e.EffectType == "fear" && e.Duration > 0);
/// <summary>Check if player is silenced</summary>
public bool IsSilenced => StatusEffects.Any(e => e.EffectType == "silence" && e.Duration > 0);
/// <summary>Get current speed modifier from status effects</summary>
public float GetSpeedModifier()
{
float modifier = 1.0f;
foreach (var effect in StatusEffects.Where(e => e.EffectType == "slow" && e.Duration > 0))
{
modifier *= effect.Modifier;
}
return modifier;
}
}
/// <summary>
/// A status effect applied to a player
/// </summary>
public class PlayerStatusEffect
{
public string EffectType { get; set; } = ""; // poison, bleed, burn, slow, stun, root, fear, silence
public float Duration { get; set; }
public float TickInterval { get; set; }
public float NextTickIn { get; set; }
public int DamagePerTick { get; set; }
public float Modifier { get; set; } = 1.0f; // For slow, etc.
public int SourceMobId { get; set; }
}