protected override void CheckPendingActions(IThing thingChanged, ThingStateChangedEventArgs eventArgs) { if (PendingAction == null || thingChanged != this || eventArgs.PropertyChanged != nameof(Location)) { return; } if (Location == PendingAction.RetryLocation) { Task.Delay(CalculateRemainingCooldownTime(CooldownType.Action, DateTime.Now) + TimeSpan.FromMilliseconds(500)) .ContinueWith(previous => { PendingAction.Perform(); }); } }
public void CheckInventoryContainerProximity(IThing thingChanging, ThingStateChangedEventArgs eventArgs) { for (byte i = 0; i < OpenContainers.Length; i++) { if (OpenContainers[i] == null) { continue; } var containerSourceLoc = OpenContainers[i].Location; switch (containerSourceLoc.Type) { case LocationType.Ground: var locDiff = Location - containerSourceLoc; if (locDiff.MaxValueIn2D > 1) { var container = GetContainer(i); CloseContainerWithId(i); if (container != null) { container.OnThingChanged -= CheckInventoryContainerProximity; } var containerId = i; Game.Instance.NotifySinglePlayer(this, conn => new GenericNotification(conn, new ContainerClosePacket { ContainerId = containerId })); } break; case LocationType.Container: break; case LocationType.Slot: break; } } }
public void CheckAutoAttack(IThing thingChanged, ThingStateChangedEventArgs eventAgrs) { if (AutoAttackTargetId == 0) { return; } var attackTarget = Game.Instance.GetCreatureWithId(AutoAttackTargetId); if (attackTarget == null || (thingChanged != this && thingChanged != attackTarget) || eventAgrs.PropertyChanged != nameof(Thing.Location)) { return; } var locationDiff = Location - attackTarget.Location; var inRange = CanSee(attackTarget) && locationDiff.Z == 0 && locationDiff.MaxValueIn2D <= AutoAttackRange; if (inRange) { Game.Instance.SignalAttackReady(); } }
protected virtual void CheckPendingActions(IThing thingChanged, ThingStateChangedEventArgs eventAgrs) { }