fix: Codegens more misc items (#1216)
This commit is contained in:
parent
32a5825ddd
commit
39e6f62ec9
81 changed files with 3042 additions and 3780 deletions
|
|
@ -1,143 +1,103 @@
|
|||
namespace Server.Items
|
||||
using System;
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class MorphItem : Item
|
||||
{
|
||||
public class MorphItem : Item
|
||||
[SerializableField(1)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private int _inactiveItemId;
|
||||
|
||||
[SerializableField(2)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private int _activeItemId;
|
||||
|
||||
[Constructible]
|
||||
public MorphItem(int inactiveItemID, int activeItemID, int range) : this(inactiveItemID, activeItemID, range, range)
|
||||
{
|
||||
private int m_InsideRange;
|
||||
private int m_OutsideRange;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MorphItem(int inactiveItemID, int activeItemID, int range) : this(inactiveItemID, activeItemID, range, range)
|
||||
[Constructible]
|
||||
public MorphItem(int inactiveItemID, int activeItemID, int inRange, int outRange) : base(inactiveItemID)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
_inactiveItemId = inactiveItemID;
|
||||
_activeItemId = activeItemID;
|
||||
_insideRange = inRange;
|
||||
_outsideRange = outRange;
|
||||
}
|
||||
|
||||
[SerializableProperty(0)]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int OutsideRange
|
||||
{
|
||||
get => _outsideRange;
|
||||
set => _outsideRange = Math.Clamp(value, 0, 18);
|
||||
}
|
||||
|
||||
[SerializableProperty(3)]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int InsideRange
|
||||
{
|
||||
get => _insideRange;
|
||||
set => _insideRange = Math.Clamp(value, 0, 18);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CurrentRange => ItemID == _inactiveItemId ? _insideRange : _outsideRange;
|
||||
|
||||
public override bool HandlesOnMovement => true;
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (Utility.InRange(m.Location, Location, CurrentRange) || Utility.InRange(oldLocation, Location, CurrentRange))
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MorphItem(int inactiveItemID, int activeItemID, int inRange, int outRange) : base(inactiveItemID)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
InactiveItemID = inactiveItemID;
|
||||
ActiveItemID = activeItemID;
|
||||
InsideRange = inRange;
|
||||
OutsideRange = outRange;
|
||||
}
|
||||
|
||||
public MorphItem(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int InactiveItemID { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ActiveItemID { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int InsideRange
|
||||
{
|
||||
get => m_InsideRange;
|
||||
set => m_InsideRange = value > 18 ? 18 :
|
||||
value < 0 ? 0 : value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int OutsideRange
|
||||
{
|
||||
get => m_OutsideRange;
|
||||
set => m_OutsideRange = value > 18 ? 18 :
|
||||
value < 0 ? 0 : value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CurrentRange => ItemID == InactiveItemID ? InsideRange : OutsideRange;
|
||||
|
||||
public override bool HandlesOnMovement => true;
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (Utility.InRange(m.Location, Location, CurrentRange) || Utility.InRange(oldLocation, Location, CurrentRange))
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
if (!Deleted)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange(Point3D oldLoc)
|
||||
{
|
||||
if (!Deleted)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
var found = false;
|
||||
var eable = GetMobilesInRange(CurrentRange);
|
||||
foreach (var mob in eable)
|
||||
{
|
||||
if (!mob.Hidden || mob.AccessLevel <= AccessLevel.Player)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
ItemID = found ? ActiveItemID : InactiveItemID;
|
||||
|
||||
Visible = ItemID != 0x1;
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write(m_OutsideRange);
|
||||
|
||||
writer.Write(InactiveItemID);
|
||||
writer.Write(ActiveItemID);
|
||||
writer.Write(m_InsideRange);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_OutsideRange = reader.ReadInt();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
InactiveItemID = reader.ReadInt();
|
||||
ActiveItemID = reader.ReadInt();
|
||||
m_InsideRange = reader.ReadInt();
|
||||
|
||||
if (version < 1)
|
||||
{
|
||||
m_OutsideRange = m_InsideRange;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Timer.StartTimer(Refresh);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
if (!Deleted)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange(Point3D oldLoc)
|
||||
{
|
||||
if (!Deleted)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
var found = false;
|
||||
var eable = GetMobilesInRange(CurrentRange);
|
||||
foreach (var mob in eable)
|
||||
{
|
||||
if (!mob.Hidden || mob.AccessLevel <= AccessLevel.Player)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
ItemID = found ? _activeItemId : _inactiveItemId;
|
||||
|
||||
Visible = ItemID != 0x1;
|
||||
}
|
||||
|
||||
[AfterDeserialization]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue