Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
|
|
@ -0,0 +1,121 @@
|
|||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseFactionVendor : BaseVendor
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private Town m_Town;
|
||||
|
||||
public BaseFactionVendor(Town town, Faction faction, string title) : base(title)
|
||||
{
|
||||
Frozen = true;
|
||||
CantWalk = true;
|
||||
Female = false;
|
||||
BodyValue = 400;
|
||||
Name = NameList.RandomName("male");
|
||||
|
||||
RangeHome = 0;
|
||||
|
||||
m_Town = town;
|
||||
m_Faction = faction;
|
||||
Register();
|
||||
}
|
||||
|
||||
public BaseFactionVendor(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
{
|
||||
Unregister();
|
||||
m_Town = value;
|
||||
Register();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
Unregister();
|
||||
m_Faction = value;
|
||||
Register();
|
||||
}
|
||||
}
|
||||
|
||||
protected override List<SBInfo> SBInfos{ get; } = new List<SBInfo>();
|
||||
|
||||
public void Register()
|
||||
{
|
||||
if (m_Town != null && m_Faction != null)
|
||||
m_Town.RegisterVendor(this);
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (Core.ML)
|
||||
return true;
|
||||
|
||||
return base.OnMoveOver(m);
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
m_Town?.UnregisterVendor(this);
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
Unregister();
|
||||
}
|
||||
|
||||
public override bool CheckVendorAccess(Mobile from)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Town = Town.ReadReference(reader);
|
||||
m_Faction = Faction.ReadReference(reader);
|
||||
Register();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Frozen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue