public static int Distance(VisibleObject obj, int x, int y) { return(Distance(obj.X, obj.Y, x, y)); }
/// <summary> /// Initializes a new instance of the <see cref="NavPoint"/> struct. /// </summary> /// <param name="location">The location.</param> /// <param name="timeOfArrival">The time of arrival.</param> public NavPoint(VisibleObject location = null) { this.TimeOfArrival = NavPoint.UNKNOWN_TIME_OF_ARRIVAL; this.Location = location; }
public ServerPacket GenerateBasePacket(User invoker, VisibleObject invokee) { byte color = 0; ushort sprite = 0; byte objType = 0; var dialogPacket = new ServerPacket(0x30); dialogPacket.WriteByte((byte)(DialogType)); if (invokee is Creature) { var creature = (Creature)invokee; sprite = (ushort)(0x4000 + creature.Sprite); objType = 1; } else if (invokee is ItemObject) { var item = (ItemObject)invokee; objType = 2; sprite = (ushort)(0x8000 + item.Sprite); color = item.Color; } else if (invokee is Reactor) { objType = 4; } if (Sprite != 0) { sprite = Sprite; } else { // If dialog sprite is unset, try using invokee's sprite; // then try user dialog state (global sequence) sprite = invokee?.DialogSprite ?? invoker.DialogState?.Associate?.DialogSprite ?? 0; } dialogPacket.WriteByte(objType); // If no invokee ID, we use 0xFFFFFFFF; 99.9% of the time this is an async dialog request dialogPacket.WriteUInt32(invokee?.Id ?? UInt32.MaxValue); dialogPacket.WriteByte(0); // Unknown value Log.Debug("Sprite is {Sprite}", sprite); dialogPacket.WriteUInt16(sprite); dialogPacket.WriteByte(color); dialogPacket.WriteByte(0); // Unknown value dialogPacket.WriteUInt16(sprite); dialogPacket.WriteByte(color); Log.Debug("Dialog group id {SequenceId}, index {Index}", Sequence.Id, Index); dialogPacket.WriteUInt16((ushort)Sequence.Id); dialogPacket.WriteUInt16((ushort)Index); dialogPacket.WriteBoolean(HasPrevDialog()); dialogPacket.WriteBoolean(HasNextDialog()); dialogPacket.WriteByte(0); // TODO: Allow override here from DialogSequence dialogPacket.WriteString8(invokee?.Name ?? invoker.DialogState?.Associate?.Name ?? Sequence.DisplayName); var displayText = EvaluateDisplayText(invoker, invokee); if (!string.IsNullOrEmpty(displayText)) { dialogPacket.WriteString16(displayText); } return(dialogPacket); }
public virtual void ShowTo(User invoker, VisibleObject invokee) { }
public void Insert(VisibleObject obj, byte x, byte y, bool updateClient = true) { if (Objects.Add(obj)) { obj.Map = this; obj.X = x; obj.Y = y; EntityTree.Add(obj); var user = obj as User; if (user != null) { if (updateClient) { obj.SendMapInfo(); obj.SendLocation(); } Users.Add(user.Name, user); } var value = obj as Reactor; if (value != null) { Reactors.Add(new Tuple<byte, byte>((byte)x,(byte)y), value); } var affectedObjects = EntityTree.GetObjects(obj.GetViewport()); foreach (var target in affectedObjects) { target.AoiEntry(obj); obj.AoiEntry(target); } } }
public void RunCallback(User target, VisibleObject associate) { ActiveDialog.RunCallback(target, associate); }
void Start() { PointableObject = Target.GetComponent <PointableObject>(); VisibleObject = Target.GetComponent <VisibleObject>(); }
public static int Distance(VisibleObject obj1, VisibleObject obj2) { return(Distance(obj1.X, obj1.Y, obj2.X, obj2.Y)); }
public void NotifyNearbyAoiEntry(VisibleObject objectToAdd) { foreach (var obj in EntityTree.GetObjects(objectToAdd.GetViewport())) { if (obj is User) { Logger.DebugFormat("Notifying {0} of item {1} at {2},{3} with sprite {4}", obj.Name, objectToAdd.Name, objectToAdd.X, objectToAdd.Y, objectToAdd.Sprite); var user = obj as User; user.AoiEntry(objectToAdd); } } }
public void Remove(VisibleObject obj) { if (Objects.Remove(obj)) { EntityTree.Remove(obj); if (obj is User) { var user = obj as User; Users.Remove(user.Name); if (user.ActiveExchange != null) user.ActiveExchange.CancelExchange(user); } var affectedObjects = EntityTree.GetObjects(obj.GetViewport()); foreach (var target in affectedObjects) { // If the target of a Remove is a player, we insert a 250ms delay to allow the animation // frame to complete. if (target is User) ((User)target).AoiDeparture(obj, 250); else target.AoiDeparture(obj); obj.AoiDeparture(target); } obj.Map = null; obj.X = 0; obj.Y = 0; } }
public void NotifyNearbyAoiDeparture(VisibleObject objectToRemove) { foreach (var obj in EntityTree.GetObjects(objectToRemove.GetViewport())) { if (obj is User) { var user = obj as User; user.AoiDeparture(objectToRemove); } } }
public static int Distance(VisibleObject obj, int x, int y) { return Distance(obj.X, obj.Y, x, y); }
public static int Distance(VisibleObject obj1, VisibleObject obj2) { return Distance(obj1.X, obj1.Y, obj2.X, obj2.Y); }
/// <summary> /// Initializes a new instance of the <see cref="NavPoint"/> struct. /// </summary> /// <param name="location">The location.</param> /// <param name="timeOfArrival">The time of arrival.</param> public NavPoint(VisibleObject location, DateTime timeOfArrival) { this.TimeOfArrival = timeOfArrival; this.Location = location; }
void Awake() { Collider = GetComponent <CircleCollider2D>(); VisibleObject = GetComponent <VisibleObject>(); }
public override void AoiEntry(VisibleObject obj) { ShowTo(obj); }
void Awake() { VisibleObject = GetComponent <VisibleObject>(); }
internal override VisibleObject Copy(VisibleObject parent) { Marker marker = new Circle(Cell); marker.Parent = (EntityCollection)parent; return marker; }
private void RequestLoadingIfNeeded(VisibleObject visibleObject) { visibleObject.VisualsRequest.RequestLoad(this); }