ModernUO/Projects/UOContent/Items/Misc/MoonstoneGate.cs
Jack 6745cf2075
feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355)
## Summary

- Adds `public virtual bool Murderer => Kills >= 5` property to `Mobile`, replacing ~30 scattered `Kills >= 5` / `Kills < 5` magic-number checks across the codebase
- `BaseCreature` overrides `Murderer` to also return `true` when `AlwaysMurderer` is set
- Updates `Corpse` serialization to v15, storing `_murderer` as a `bool` field (migrated from `int Kills >= 5` in earlier versions)
2026-03-06 08:36:41 -08:00

66 lines
1.5 KiB
C#

using System;
using ModernUO.Serialization;
using Server.Engines.PartySystem;
namespace Server.Items;
[SerializationGenerator(0, false)]
public partial class MoonstoneGate : Moongate
{
private Mobile _caster;
public MoonstoneGate(Point3D loc, Map map, Map targetMap, Mobile caster, int hue) : base(loc, targetMap)
{
MoveToWorld(loc, map);
Dispellable = false;
Hue = hue;
_caster = caster;
new InternalTimer(this).Start();
Effects.PlaySound(loc, map, 0x20E);
}
public override bool SkipSerialization => true;
public override void CheckGate(Mobile m, int range)
{
if (m.Murderer)
{
return;
}
var casterParty = Party.Get(_caster);
var userParty = Party.Get(m);
if (m == _caster || casterParty != null && userParty == casterParty)
{
base.CheckGate(m, range);
}
}
public override void UseGate(Mobile m)
{
if (m.Murderer)
{
return;
}
var casterParty = Party.Get(_caster);
var userParty = Party.Get(m);
if (m == _caster || casterParty != null && userParty == casterParty)
{
base.UseGate(m);
}
}
private class InternalTimer : Timer
{
private Item _item;
public InternalTimer(Item item) : base(TimeSpan.FromSeconds(30.0)) => _item = item;
protected override void OnTick() => _item.Delete();
}
}