示例#1
0
        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();
                });
            }
        }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        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();
            }
        }
示例#4
0
 protected virtual void CheckPendingActions(IThing thingChanged, ThingStateChangedEventArgs eventAgrs)
 {
 }