fix: Codegens Khaldun and Doom (#1521)
This commit is contained in:
parent
5dc2d09392
commit
145c93ccf7
35 changed files with 4405 additions and 4528 deletions
|
|
@ -1,461 +1,430 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Items;
|
||||
using Server.Utilities;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
namespace Server.Engines.Doom;
|
||||
|
||||
public enum GauntletSpawnerState
|
||||
{
|
||||
public enum GauntletSpawnerState
|
||||
InSequence,
|
||||
InProgress,
|
||||
Completed
|
||||
}
|
||||
|
||||
[SerializationGenerator(2, false)]
|
||||
public partial class GauntletSpawner : Item
|
||||
{
|
||||
public const int PlayersPerSpawn = 5;
|
||||
|
||||
public const int InSequenceItemHue = 0x000;
|
||||
public const int InProgressItemHue = 0x676;
|
||||
public const int CompletedItemHue = 0x455;
|
||||
|
||||
[SerializableField(0)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private Rectangle2D _regionBounds;
|
||||
|
||||
[SerializableField(1)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private List<BaseTrap> _traps;
|
||||
|
||||
[SerializableField(2)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private List<Mobile> _creatures;
|
||||
|
||||
[SerializableField(3)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private string _typeName;
|
||||
|
||||
[SerializableField(4)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private BaseDoor _door;
|
||||
|
||||
[SerializableField(5)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private BaseAddon _addon;
|
||||
|
||||
[SerializableField(6)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private GauntletSpawner _sequence;
|
||||
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public GauntletSpawner(string typeName = null) : base(0x36FE)
|
||||
{
|
||||
InSequence,
|
||||
InProgress,
|
||||
Completed
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
TypeName = typeName;
|
||||
Creatures = new List<Mobile>();
|
||||
Traps = new List<BaseTrap>();
|
||||
}
|
||||
|
||||
public class GauntletSpawner : Item
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool HasCompleted
|
||||
{
|
||||
public const int PlayersPerSpawn = 5;
|
||||
|
||||
public const int InSequenceItemHue = 0x000;
|
||||
public const int InProgressItemHue = 0x676;
|
||||
public const int CompletedItemHue = 0x455;
|
||||
|
||||
private GauntletSpawnerState m_State;
|
||||
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public GauntletSpawner(string typeName = null) : base(0x36FE)
|
||||
get
|
||||
{
|
||||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
TypeName = typeName;
|
||||
Creatures = new List<Mobile>();
|
||||
Traps = new List<BaseTrap>();
|
||||
}
|
||||
|
||||
public GauntletSpawner(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string TypeName { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseDoor Door { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseAddon Addon { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GauntletSpawner Sequence { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool HasCompleted
|
||||
{
|
||||
get
|
||||
if (Creatures.Count == 0)
|
||||
{
|
||||
if (Creatures.Count == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < Creatures.Count; ++i)
|
||||
{
|
||||
var mob = Creatures[i];
|
||||
|
||||
if (!mob.Deleted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < Creatures.Count; ++i)
|
||||
{
|
||||
var mob = Creatures[i];
|
||||
|
||||
if (!mob.Deleted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Rectangle2D RegionBounds { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GauntletSpawnerState State
|
||||
[SerializableProperty(7)]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public GauntletSpawnerState State
|
||||
{
|
||||
get => _state;
|
||||
set
|
||||
{
|
||||
get => m_State;
|
||||
set
|
||||
if (_state != value)
|
||||
{
|
||||
if (m_State != value)
|
||||
{
|
||||
m_State = value;
|
||||
Update();
|
||||
}
|
||||
_state = value;
|
||||
Update();
|
||||
}
|
||||
|
||||
this.MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Mobile> Creatures { get; set; }
|
||||
public Region Region { get; set; }
|
||||
|
||||
public List<BaseTrap> Traps { get; set; }
|
||||
private void Update(bool shouldSpawn = true)
|
||||
{
|
||||
var lockDoors = _state == GauntletSpawnerState.InProgress;
|
||||
|
||||
public Region Region { get; set; }
|
||||
|
||||
private void Update(bool shouldSpawn = true)
|
||||
var hue = _state switch
|
||||
{
|
||||
var lockDoors = m_State == GauntletSpawnerState.InProgress;
|
||||
GauntletSpawnerState.InSequence => InSequenceItemHue,
|
||||
GauntletSpawnerState.InProgress => InProgressItemHue,
|
||||
GauntletSpawnerState.Completed => CompletedItemHue,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
var hue = m_State switch
|
||||
{
|
||||
GauntletSpawnerState.InSequence => InSequenceItemHue,
|
||||
GauntletSpawnerState.InProgress => InProgressItemHue,
|
||||
GauntletSpawnerState.Completed => CompletedItemHue,
|
||||
_ => 0
|
||||
};
|
||||
if (Door != null)
|
||||
{
|
||||
Door.Hue = hue;
|
||||
Door.Locked = lockDoors;
|
||||
|
||||
if (Door != null)
|
||||
if (lockDoors)
|
||||
{
|
||||
Door.Hue = hue;
|
||||
Door.Locked = lockDoors;
|
||||
Door.KeyValue = Key.RandomValue();
|
||||
Door.Open = false;
|
||||
}
|
||||
|
||||
if (Door.Link?.Deleted == false)
|
||||
{
|
||||
Door.Link.Hue = hue;
|
||||
Door.Link.Locked = lockDoors;
|
||||
|
||||
if (lockDoors)
|
||||
{
|
||||
Door.KeyValue = Key.RandomValue();
|
||||
Door.Link.KeyValue = Key.RandomValue();
|
||||
Door.Open = false;
|
||||
}
|
||||
|
||||
if (Door.Link?.Deleted == false)
|
||||
{
|
||||
Door.Link.Hue = hue;
|
||||
Door.Link.Locked = lockDoors;
|
||||
|
||||
if (lockDoors)
|
||||
{
|
||||
Door.Link.KeyValue = Key.RandomValue();
|
||||
Door.Open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Addon != null)
|
||||
{
|
||||
Addon.Hue = hue;
|
||||
}
|
||||
|
||||
if (m_State == GauntletSpawnerState.InProgress)
|
||||
{
|
||||
CreateRegion();
|
||||
|
||||
if (shouldSpawn)
|
||||
{
|
||||
FullSpawn();
|
||||
}
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Slice, out _timerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "doom spawner";
|
||||
|
||||
public virtual void CreateRegion()
|
||||
if (Addon != null)
|
||||
{
|
||||
if (Region != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var map = Map;
|
||||
|
||||
if (map == null || map == Map.Internal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Region = new GauntletRegion(this, map);
|
||||
Addon.Hue = hue;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
if (_state == GauntletSpawnerState.InProgress)
|
||||
{
|
||||
ClearCreatures();
|
||||
ClearTraps();
|
||||
DestroyRegion();
|
||||
CreateRegion();
|
||||
|
||||
_timerToken.Cancel();
|
||||
if (shouldSpawn)
|
||||
{
|
||||
FullSpawn();
|
||||
}
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Slice, out _timerToken);
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
else
|
||||
{
|
||||
base.OnDelete();
|
||||
Stop();
|
||||
|
||||
Door?.Link?.Delete();
|
||||
Door?.Delete();
|
||||
Addon?.Delete();
|
||||
}
|
||||
|
||||
public virtual void DestroyRegion()
|
||||
{
|
||||
Region?.Unregister();
|
||||
|
||||
Region = null;
|
||||
}
|
||||
|
||||
public virtual int ComputeTrapCount()
|
||||
{
|
||||
var area = RegionBounds.Width * RegionBounds.Height;
|
||||
|
||||
return area / 100;
|
||||
}
|
||||
|
||||
public virtual void ClearTraps()
|
||||
{
|
||||
for (var i = 0; i < Traps.Count; ++i)
|
||||
{
|
||||
Traps[i].Delete();
|
||||
}
|
||||
|
||||
Traps.Clear();
|
||||
}
|
||||
|
||||
public virtual void SpawnTrap()
|
||||
{
|
||||
var map = Map;
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var random = Utility.Random(100);
|
||||
|
||||
BaseTrap trap = random switch
|
||||
{
|
||||
< 22 => new SawTrap(Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor),
|
||||
< 44 => new SpikeTrap(Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor),
|
||||
< 66 => new GasTrap(Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall),
|
||||
< 88 => new FireColumnTrap(),
|
||||
_ => new MushroomTrap()
|
||||
};
|
||||
|
||||
if (trap is FireColumnTrap or MushroomTrap)
|
||||
{
|
||||
trap.Hue = 0x451;
|
||||
}
|
||||
|
||||
// try 10 times to find a valid location
|
||||
for (var i = 0; i < 10; ++i)
|
||||
{
|
||||
var x = Utility.Random(RegionBounds.X, RegionBounds.Width);
|
||||
var y = Utility.Random(RegionBounds.Y, RegionBounds.Height);
|
||||
var z = Z;
|
||||
|
||||
if (!map.CanFit(x, y, z, 16, false, false))
|
||||
{
|
||||
z = map.GetAverageZ(x, y);
|
||||
}
|
||||
|
||||
if (!map.CanFit(x, y, z, 16, false, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
trap.MoveToWorld(new Point3D(x, y, z), map);
|
||||
Traps.Add(trap);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trap.Delete();
|
||||
}
|
||||
|
||||
public virtual int ComputeSpawnCount()
|
||||
{
|
||||
var playerCount = 0;
|
||||
|
||||
var map = Map;
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
var loc = GetWorldLocation();
|
||||
|
||||
var reg = Region.Find(loc, map).GetRegion("Doom Gauntlet");
|
||||
|
||||
if (reg != null)
|
||||
{
|
||||
playerCount = reg.GetPlayerCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (playerCount == 0 && Region != null)
|
||||
{
|
||||
playerCount = Region.GetPlayerCount();
|
||||
}
|
||||
|
||||
return Math.Max((playerCount + PlayersPerSpawn - 1) / PlayersPerSpawn, 1);
|
||||
}
|
||||
|
||||
public virtual void ClearCreatures()
|
||||
{
|
||||
for (var i = 0; i < Creatures.Count; ++i)
|
||||
{
|
||||
Creatures[i].Delete();
|
||||
}
|
||||
|
||||
Creatures.Clear();
|
||||
}
|
||||
|
||||
public virtual void FullSpawn()
|
||||
{
|
||||
ClearCreatures();
|
||||
|
||||
var count = ComputeSpawnCount();
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
Spawn();
|
||||
}
|
||||
|
||||
ClearTraps();
|
||||
|
||||
count = ComputeTrapCount();
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
SpawnTrap();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Spawn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TypeName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var type = AssemblyHandler.FindTypeByName(TypeName);
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var mob = type.CreateEntityInstance<Mobile>();
|
||||
|
||||
if (mob != null)
|
||||
{
|
||||
mob.MoveToWorld(GetWorldLocation(), Map);
|
||||
Creatures.Add(mob);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RecurseReset()
|
||||
{
|
||||
if (m_State != GauntletSpawnerState.InSequence)
|
||||
{
|
||||
State = GauntletSpawnerState.InSequence;
|
||||
|
||||
if (Sequence?.Deleted == false)
|
||||
{
|
||||
Sequence.RecurseReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Slice()
|
||||
{
|
||||
if (m_State != GauntletSpawnerState.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var count = ComputeSpawnCount();
|
||||
|
||||
for (var i = Creatures.Count; i < count; ++i)
|
||||
{
|
||||
Spawn();
|
||||
}
|
||||
|
||||
if (HasCompleted)
|
||||
{
|
||||
State = GauntletSpawnerState.Completed;
|
||||
|
||||
if (Sequence?.Deleted == false)
|
||||
{
|
||||
if (Sequence.State == GauntletSpawnerState.Completed)
|
||||
{
|
||||
RecurseReset();
|
||||
}
|
||||
|
||||
Sequence.State = GauntletSpawnerState.InProgress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(RegionBounds);
|
||||
|
||||
writer.Write(Traps);
|
||||
|
||||
writer.Write(Creatures);
|
||||
|
||||
writer.Write(TypeName);
|
||||
writer.Write(Door);
|
||||
writer.Write(Addon);
|
||||
writer.Write(Sequence);
|
||||
|
||||
writer.Write((int)m_State);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
RegionBounds = reader.ReadRect2D();
|
||||
Traps = reader.ReadEntityList<BaseTrap>();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
if (version < 1)
|
||||
{
|
||||
Traps = new List<BaseTrap>();
|
||||
RegionBounds = new Rectangle2D(X - 40, Y - 40, 80, 80);
|
||||
}
|
||||
|
||||
Creatures = reader.ReadEntityList<Mobile>();
|
||||
|
||||
TypeName = reader.ReadString();
|
||||
Door = reader.ReadEntity<BaseDoor>();
|
||||
Addon = reader.ReadEntity<BaseAddon>();
|
||||
Sequence = reader.ReadEntity<GauntletSpawner>();
|
||||
|
||||
m_State = (GauntletSpawnerState)reader.ReadInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(() => Update(false));
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "doom spawner";
|
||||
|
||||
public virtual void CreateRegion()
|
||||
{
|
||||
if (Region != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var map = Map;
|
||||
|
||||
if (map == null || map == Map.Internal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Region = new GauntletRegion(this, map);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
ClearCreatures();
|
||||
ClearTraps();
|
||||
DestroyRegion();
|
||||
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
base.OnDelete();
|
||||
Stop();
|
||||
|
||||
Door?.Link?.Delete();
|
||||
Door?.Delete();
|
||||
Addon?.Delete();
|
||||
}
|
||||
|
||||
public virtual void DestroyRegion()
|
||||
{
|
||||
Region?.Unregister();
|
||||
|
||||
Region = null;
|
||||
}
|
||||
|
||||
public virtual int ComputeTrapCount()
|
||||
{
|
||||
var area = RegionBounds.Width * RegionBounds.Height;
|
||||
|
||||
return area / 100;
|
||||
}
|
||||
|
||||
public virtual void ClearTraps()
|
||||
{
|
||||
for (var i = 0; i < Traps.Count; ++i)
|
||||
{
|
||||
Traps[i].Delete();
|
||||
}
|
||||
|
||||
Traps.Clear();
|
||||
}
|
||||
|
||||
public virtual void SpawnTrap()
|
||||
{
|
||||
var map = Map;
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var random = Utility.Random(100);
|
||||
|
||||
BaseTrap trap = random switch
|
||||
{
|
||||
< 22 => new SawTrap(Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor),
|
||||
< 44 => new SpikeTrap(Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor),
|
||||
< 66 => new GasTrap(Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall),
|
||||
< 88 => new FireColumnTrap(),
|
||||
_ => new MushroomTrap()
|
||||
};
|
||||
|
||||
if (trap is FireColumnTrap or MushroomTrap)
|
||||
{
|
||||
trap.Hue = 0x451;
|
||||
}
|
||||
|
||||
// try 10 times to find a valid location
|
||||
for (var i = 0; i < 10; ++i)
|
||||
{
|
||||
var x = Utility.Random(RegionBounds.X, RegionBounds.Width);
|
||||
var y = Utility.Random(RegionBounds.Y, RegionBounds.Height);
|
||||
var z = Z;
|
||||
|
||||
if (!map.CanFit(x, y, z, 16, false, false))
|
||||
{
|
||||
z = map.GetAverageZ(x, y);
|
||||
}
|
||||
|
||||
if (!map.CanFit(x, y, z, 16, false, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
trap.MoveToWorld(new Point3D(x, y, z), map);
|
||||
Traps.Add(trap);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trap.Delete();
|
||||
}
|
||||
|
||||
public virtual int ComputeSpawnCount()
|
||||
{
|
||||
var playerCount = 0;
|
||||
|
||||
var map = Map;
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
var loc = GetWorldLocation();
|
||||
|
||||
var reg = Region.Find(loc, map).GetRegion("Doom Gauntlet");
|
||||
|
||||
if (reg != null)
|
||||
{
|
||||
playerCount = reg.GetPlayerCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (playerCount == 0 && Region != null)
|
||||
{
|
||||
playerCount = Region.GetPlayerCount();
|
||||
}
|
||||
|
||||
return Math.Max((playerCount + PlayersPerSpawn - 1) / PlayersPerSpawn, 1);
|
||||
}
|
||||
|
||||
public virtual void ClearCreatures()
|
||||
{
|
||||
for (var i = 0; i < Creatures.Count; ++i)
|
||||
{
|
||||
Creatures[i].Delete();
|
||||
}
|
||||
|
||||
Creatures.Clear();
|
||||
}
|
||||
|
||||
public virtual void FullSpawn()
|
||||
{
|
||||
ClearCreatures();
|
||||
|
||||
var count = ComputeSpawnCount();
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
Spawn();
|
||||
}
|
||||
|
||||
ClearTraps();
|
||||
|
||||
count = ComputeTrapCount();
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
SpawnTrap();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Spawn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TypeName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var type = AssemblyHandler.FindTypeByName(TypeName);
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var mob = type.CreateEntityInstance<Mobile>();
|
||||
|
||||
if (mob != null)
|
||||
{
|
||||
mob.MoveToWorld(GetWorldLocation(), Map);
|
||||
Creatures.Add(mob);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RecurseReset()
|
||||
{
|
||||
if (_state != GauntletSpawnerState.InSequence)
|
||||
{
|
||||
State = GauntletSpawnerState.InSequence;
|
||||
|
||||
if (Sequence?.Deleted == false)
|
||||
{
|
||||
Sequence.RecurseReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Slice()
|
||||
{
|
||||
if (_state != GauntletSpawnerState.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var count = ComputeSpawnCount();
|
||||
|
||||
for (var i = Creatures.Count; i < count; ++i)
|
||||
{
|
||||
Spawn();
|
||||
}
|
||||
|
||||
if (HasCompleted)
|
||||
{
|
||||
State = GauntletSpawnerState.Completed;
|
||||
|
||||
if (Sequence?.Deleted == false)
|
||||
{
|
||||
if (Sequence.State == GauntletSpawnerState.Completed)
|
||||
{
|
||||
RecurseReset();
|
||||
}
|
||||
|
||||
Sequence.State = GauntletSpawnerState.InProgress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Deserialize(IGenericReader reader, int version)
|
||||
{
|
||||
RegionBounds = reader.ReadRect2D();
|
||||
Traps = reader.ReadEntityList<BaseTrap>();
|
||||
|
||||
Creatures = reader.ReadEntityList<Mobile>();
|
||||
|
||||
TypeName = reader.ReadString();
|
||||
Door = reader.ReadEntity<BaseDoor>();
|
||||
Addon = reader.ReadEntity<BaseAddon>();
|
||||
Sequence = reader.ReadEntity<GauntletSpawner>();
|
||||
|
||||
_state = (GauntletSpawnerState)reader.ReadInt();
|
||||
}
|
||||
|
||||
[AfterDeserialization(false)]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
Update(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,215 +1,149 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Engines.Doom
|
||||
namespace Server.Engines.Doom;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class LampRoomBox : Item
|
||||
{
|
||||
public class LampRoomBox : Item
|
||||
[SerializableField(0)]
|
||||
private LeverPuzzleController _controller;
|
||||
private Mobile _wanderer;
|
||||
|
||||
public LampRoomBox(LeverPuzzleController controller) : base(0xe80)
|
||||
{
|
||||
private LeverPuzzleController m_Controller;
|
||||
private Mobile m_Wanderer;
|
||||
_controller = controller;
|
||||
ItemID = 0xe80;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public LampRoomBox(LeverPuzzleController controller) : base(0xe80)
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (!m.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
m_Controller = controller;
|
||||
ItemID = 0xe80;
|
||||
Movable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
public LampRoomBox(Serial serial) : base(serial)
|
||||
if (_controller.Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
if (_wanderer?.Alive != true)
|
||||
{
|
||||
if (!m.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Controller.Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Wanderer?.Alive != true)
|
||||
{
|
||||
m_Wanderer = new WandererOfTheVoid();
|
||||
m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);
|
||||
m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002); // I am the guardian of...
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), CallBackMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public void CallBackMessage()
|
||||
{
|
||||
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060003); // You try to pry the box open...
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (m_Controller?.Deleted == false)
|
||||
{
|
||||
m_Controller.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
writer.Write(m_Controller);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
var version = reader.ReadInt();
|
||||
m_Controller = reader.ReadEntity<LeverPuzzleController>();
|
||||
_wanderer = new WandererOfTheVoid();
|
||||
_wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);
|
||||
_wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002); // I am the guardian of...
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), CallBackMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public class LeverPuzzleStatue : Item
|
||||
public void CallBackMessage()
|
||||
{
|
||||
private LeverPuzzleController m_Controller;
|
||||
|
||||
public LeverPuzzleStatue(int[] dat, LeverPuzzleController controller) : base(dat[0])
|
||||
{
|
||||
m_Controller = controller;
|
||||
Hue = 0x44E;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public LeverPuzzleStatue(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (m_Controller?.Deleted == false)
|
||||
{
|
||||
m_Controller.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
writer.Write(m_Controller);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
var version = reader.ReadInt();
|
||||
m_Controller = reader.ReadEntity<LeverPuzzleController>();
|
||||
}
|
||||
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060003); // You try to pry the box open...
|
||||
}
|
||||
|
||||
public class LeverPuzzleLever : Item
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
private LeverPuzzleController m_Controller;
|
||||
|
||||
public LeverPuzzleLever(ushort code, LeverPuzzleController controller) : base(0x108E)
|
||||
if (_controller?.Deleted == false)
|
||||
{
|
||||
m_Controller = controller;
|
||||
Code = code;
|
||||
Hue = 0x66D;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public LeverPuzzleLever(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public ushort Code { get; private set; }
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (m != null && m_Controller.Enabled)
|
||||
{
|
||||
ItemID ^= 2;
|
||||
Effects.PlaySound(Location, Map, 0x3E8);
|
||||
m_Controller.LeverPulled(Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
m?.SendLocalizedMessage(1060001); // You throw the switch, but the mechanism cannot be engaged again so soon.
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (m_Controller?.Deleted == false)
|
||||
{
|
||||
m_Controller.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
writer.Write(Code);
|
||||
writer.Write(m_Controller);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
var version = reader.ReadInt();
|
||||
Code = reader.ReadUShort();
|
||||
m_Controller = reader.ReadEntity<LeverPuzzleController>();
|
||||
}
|
||||
}
|
||||
|
||||
[TypeAlias("Server.Engines.Doom.LampRoomTelePorter")]
|
||||
public class LampRoomTeleporter : Item
|
||||
{
|
||||
public LampRoomTeleporter(int[] dat)
|
||||
{
|
||||
Hue = dat[1];
|
||||
ItemID = dat[0];
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public LampRoomTeleporter(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandlesOnMovement => true;
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
if (SpellHelper.CheckCombat(m))
|
||||
{
|
||||
m.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCreature.TeleportPets(m, LeverPuzzleController.lr_Exit, Map.Malas);
|
||||
m.MoveToWorld(LeverPuzzleController.lr_Exit, Map.Malas);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
var version = reader.ReadInt();
|
||||
_controller.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class LeverPuzzleStatue : Item
|
||||
{
|
||||
private LeverPuzzleController _controller;
|
||||
|
||||
public LeverPuzzleStatue(int[] dat, LeverPuzzleController controller) : base(dat[0])
|
||||
{
|
||||
_controller = controller;
|
||||
Hue = 0x44E;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (_controller?.Deleted == false)
|
||||
{
|
||||
_controller.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class LeverPuzzleLever : Item
|
||||
{
|
||||
[SerializableField(0, setter: "private")]
|
||||
private ushort _code;
|
||||
|
||||
[SerializableField(1)]
|
||||
private LeverPuzzleController _controller;
|
||||
|
||||
public LeverPuzzleLever(ushort code, LeverPuzzleController controller) : base(0x108E)
|
||||
{
|
||||
_controller = controller;
|
||||
_code = code;
|
||||
Hue = 0x66D;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (m != null && _controller.Enabled)
|
||||
{
|
||||
ItemID ^= 2;
|
||||
Effects.PlaySound(Location, Map, 0x3E8);
|
||||
_controller.LeverPulled(Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
m?.SendLocalizedMessage(1060001); // You throw the switch, but the mechanism cannot be engaged again so soon.
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (_controller?.Deleted == false)
|
||||
{
|
||||
_controller.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TypeAlias("Server.Engines.Doom.LampRoomTelePorter")]
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class LampRoomTeleporter : Item
|
||||
{
|
||||
public LampRoomTeleporter(int[] dat)
|
||||
{
|
||||
Hue = dat[1];
|
||||
ItemID = dat[0];
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public override bool HandlesOnMovement => true;
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
if (SpellHelper.CheckCombat(m))
|
||||
{
|
||||
m.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCreature.TeleportPets(m, LeverPuzzleController.lr_Exit, Map.Malas);
|
||||
m.MoveToWorld(LeverPuzzleController.lr_Exit, Map.Malas);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue