using Preparation.Interface; using Preparation.Utility; using System.Threading; namespace GameClass.GameObj { public abstract class Moveable : GameObj, IMoveable { protected readonly object actionLock = new(); public object ActionLock => actionLock; //player.actionLock>其他.actionLock/其他Lock,应当避免两个player的actionlock互锁 private readonly ReaderWriterLockSlim moveReaderWriterLock = new(); public ReaderWriterLockSlim MoveReaderWriterLock => moveReaderWriterLock; //规定moveReaderWriterLock !IsMoving && CanMove && !IsRemoved; // 是否能接收移动指令 /// /// 移动速度 /// public AtomicInt MoveSpeed { get; } /// /// 原初移动速度 /// protected int orgMoveSpeed; public int OrgMoveSpeed => orgMoveSpeed; /* /// /// 复活时数据重置 /// public virtual void Reset(PlaceType place) { lock (gameObjLock) { this.FacingDirection = new XY(1, 0); isMoving = false; CanMove = false; IsRemoved = true; this.Position = birthPos; this.Place= place; } }*/ public Moveable(XY initPos, int initRadius, GameObjType initType) : base(initPos, initRadius, initType) { } } }