## Summary - Replaces scan-based decay checking during world saves with an event-driven timer wheel scheduler - Removes virtual property checks from serialization hot path, achieving 6-8x faster world saves ## Changes ### DecayScheduler (new): - Timer wheel with 12 HashSet buckets (5-min intervals) + PriorityQueue for active processing - O(1) register/unregister vs O(n) scan of all items - Auto start/stop when items exist/empty - Configurable tick interval with jitter to prevent system synchronization ### Item.cs: - Added ScheduledDecayTime computed property - Added UpdateDecayRegistration() called from SetLastMoved(), property setters, AddItem()/RemoveItem() - Hooks in Visible, Movable, Spawner setters and Delete() ### World.cs: - Removed _decayQueue, EnqueueForDecay(), ProcessDecay() - ItemPersistence.Serialize() now tight loop without virtual calls ## Performance | Metric | Before | After | Improvement | |---------------|------------|-----------|-------------| | Items (230K) | 245K ticks | 34K ticks | 8x faster | | Mobiles (43K) | 56K ticks | 6K ticks | 9x faster | | Total | 302K ticks | 40K ticks | 7.5x faster | ## Configuration decay.maxItemsPerTick = 250 # Items processed per tick decay.tickInterval = 256ms # Base processing interval decay.bucketInterval = 5min # Timer wheel bucket size decay.jitterMaxMs = 25 # ±25ms tick jitter
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using System;
|
|
using ModernUO.Serialization;
|
|
|
|
namespace Server.Mobiles;
|
|
|
|
[SerializationGenerator(0, false)]
|
|
public partial class NatureFury : BaseCreature
|
|
{
|
|
[Constructible]
|
|
public NatureFury() : base(AIType.AI_Melee)
|
|
{
|
|
Body = 0x33;
|
|
Hue = 0x4001;
|
|
|
|
SetStr(150);
|
|
SetDex(150);
|
|
SetInt(100);
|
|
|
|
SetHits(80);
|
|
SetStam(250);
|
|
SetMana(0);
|
|
|
|
SetDamage(6, 8);
|
|
|
|
SetDamageType(ResistanceType.Poison, 100);
|
|
SetDamageType(ResistanceType.Physical, 0);
|
|
SetResistance(ResistanceType.Physical, 90);
|
|
|
|
SetSkill(SkillName.Wrestling, 90.0);
|
|
SetSkill(SkillName.MagicResist, 70.0);
|
|
SetSkill(SkillName.Tactics, 100.0);
|
|
|
|
Fame = 0;
|
|
Karma = 0;
|
|
|
|
ControlSlots = 1;
|
|
}
|
|
|
|
public override bool SkipSerialization => true;
|
|
|
|
public override bool DeleteCorpseOnDeath => Core.AOS;
|
|
public override bool IsHouseSummonable => true;
|
|
|
|
public override double DispelDifficulty => 125.0;
|
|
public override double DispelFocus => 90.0;
|
|
|
|
public override bool BleedImmune => true;
|
|
public override Poison PoisonImmune => Poison.Lethal;
|
|
|
|
public override bool AlwaysMurderer => true;
|
|
public override string DefaultName => "a nature's fury";
|
|
|
|
public override void MoveToWorld(Point3D loc, Map map)
|
|
{
|
|
base.MoveToWorld(loc, map);
|
|
Timer.StartTimer(DoEffects);
|
|
}
|
|
|
|
public void DoEffects()
|
|
{
|
|
FixedParticles(0x91C, 10, 180, 0x2543, 0, 0, EffectLayer.Waist);
|
|
PlaySound(0xE);
|
|
PlaySound(0x1BC);
|
|
|
|
if (Alive && !Deleted)
|
|
{
|
|
Timer.StartTimer(TimeSpan.FromSeconds(7.0), DoEffects);
|
|
}
|
|
}
|
|
}
|