12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using CommonAI.Zone;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CommonAI.ZoneClient
- {
- public class ZoneItem : ZoneObject
- {
- public readonly ItemTemplate Info;
- public readonly SyncItemInfo SyncInfo;
- public int Force { get; private set; }
- public string Alias { get; private set; }
- public int ExpireTimeMS { get; private set; }
- public int TotalTimeMS { get; private set; }
- public int PassTimeMS { get { return TotalTimeMS - ExpireTimeMS; } }
- public override string Name { get { return null; } }
- public override string DisplayName { get { return Info.Name; } }
- public override float RadiusSize { get { return Info.BodySize; } }
- public ZoneItem(ItemTemplate info, SyncItemInfo syn, ZoneLayer parent, AddItemEvent add)
- : base(syn.ObjectID, parent)
- {
- this.SyncInfo = syn;
- this.mPos.SetX(syn.x);
- this.mPos.SetY(syn.y);
- this.Direction = syn.direction;
- this.Info = info;
- this.Force = syn.Force;
- this.Alias = syn.Alias;
- this.ExpireTimeMS = syn.ItemExpireTimeMS;
- this.TotalTimeMS = syn.ItemTotalTimeMS;
- }
- protected internal override void OnAdded()
- {
- base.OnAdded();
- if (Info.DropEffect != null)
- {
- Parent.PreQueueEvent(new AddEffectEvent(0, X, Y, Direction, Info.DropEffect));
- }
- }
- internal protected override void DoEvent(ObjectEvent e)
- {
- if (e is ObjectForceSyncPosEvent)
- {
- var oe = e as ObjectForceSyncPosEvent;
- this.ForceSyncPos(oe.X, oe.Y);
- this.Direction = oe.Direction;
- }
- }
- internal protected override void Update()
- {
- if (ExpireTimeMS > 0)
- {
- ExpireTimeMS -= Parent.CurrentIntervalMS;
- if (ExpireTimeMS < 0)
- {
- ExpireTimeMS = 0;
- }
- }
- }
- }
- }
|