Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
135
Projects/Scripts/Items/Games/BaseBoard.cs
Normal file
135
Projects/Scripts/Items/Games/BaseBoard.cs
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public abstract class BaseBoard : Container, ISecurable
|
||||
{
|
||||
public BaseBoard(int itemID) : base(itemID)
|
||||
{
|
||||
CreatePieces();
|
||||
|
||||
Weight = 5.0;
|
||||
}
|
||||
|
||||
public BaseBoard(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DisplaysContent => false; // Do not display (x items, y stones)
|
||||
|
||||
public override bool IsDecoContainer => false;
|
||||
|
||||
public override TimeSpan DecayTime => TimeSpan.FromDays(1.0);
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public SecureLevel Level{ get; set; }
|
||||
|
||||
public abstract void CreatePieces();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
for (int i = Items.Count - 1; i >= 0; --i)
|
||||
if (i < Items.Count)
|
||||
Items[i].Delete();
|
||||
|
||||
CreatePieces();
|
||||
}
|
||||
|
||||
public void CreatePiece(BasePiece piece, int x, int y)
|
||||
{
|
||||
AddItem(piece);
|
||||
piece.Location = new Point3D(x, y, 0);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write((int)Level);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (version == 1)
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
|
||||
if (Weight == 1.0)
|
||||
Weight = 5.0;
|
||||
}
|
||||
|
||||
public override bool OnDragDrop(Mobile from, Item dropped)
|
||||
{
|
||||
return dropped is BasePiece piece && piece.Board == this && base.OnDragDrop(from, dropped);
|
||||
}
|
||||
|
||||
public override bool OnDragDropInto(Mobile from, Item dropped, Point3D point)
|
||||
{
|
||||
if (dropped is BasePiece piece && piece.Board == this && base.OnDragDropInto(from, dropped, point))
|
||||
{
|
||||
Packet p = new PlaySound(0x127, GetWorldLocation());
|
||||
|
||||
p.Acquire();
|
||||
|
||||
if (RootParent == from)
|
||||
from.Send(p);
|
||||
else
|
||||
foreach (NetState state in GetClientsInRange(2))
|
||||
state.Send(p);
|
||||
|
||||
p.Release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if (ValidateDefault(from, this))
|
||||
list.Add(new DefaultEntry(from, this));
|
||||
|
||||
SetSecureLevelEntry.AddTo(from, this, list);
|
||||
}
|
||||
|
||||
public static bool ValidateDefault(Mobile from, BaseBoard board)
|
||||
{
|
||||
// Fixed this because it implies you can use it from your bank, if you can access your bank
|
||||
// while in your house. (!(board.RootParent is Mobile) || board.RootParent == from)
|
||||
return !board.Deleted && (from.AccessLevel >= AccessLevel.GameMaster || from.Alive &&
|
||||
(board.IsChildOf(from.Backpack) || !(board.RootParent is Mobile) &&
|
||||
board.Map == from.Map && from.InRange(board.GetWorldLocation(), 1) &&
|
||||
BaseHouse.FindHouseAt(board)?.IsOwner(from) == true));
|
||||
}
|
||||
|
||||
public class DefaultEntry : ContextMenuEntry
|
||||
{
|
||||
private BaseBoard m_Board;
|
||||
private Mobile m_From;
|
||||
|
||||
public DefaultEntry(Mobile from, BaseBoard board) : base(6162,
|
||||
from.AccessLevel >= AccessLevel.GameMaster ? -1 : 1)
|
||||
{
|
||||
m_From = from;
|
||||
m_Board = board;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if (ValidateDefault(m_From, m_Board))
|
||||
m_Board.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue