wServer.realm.entities.Player.Move C# (CSharp) Method

Move() public method

public Move ( RealmTime time, MovePacket pkt ) : void
time RealmTime
pkt MovePacket
return void
        public void Move(RealmTime time, MovePacket pkt)
        {
            if (pkt.Position.X == -1 || pkt.Position.Y == -1) return;

            double newX = X; double newY = Y;
            if (newX != pkt.Position.X)
            {
                newX = pkt.Position.X;
                UpdateCount++;
            }
            if (newY != pkt.Position.Y)
            {
                newY = pkt.Position.Y;
                UpdateCount++;
            }

            if (HasConditionEffect(ConditionEffects.Paused) == true)
            {
                ApplyConditionEffect(new ConditionEffect()
                {
                    Effect = ConditionEffectIndex.Paused,
                    DurationMS = -1
                });
            }
            else if (HasConditionEffect(ConditionEffects.Paused) == false)
            {
                ApplyConditionEffect(new ConditionEffect()
                {
                    Effect = ConditionEffectIndex.Paused,
                    DurationMS = 0
                });
            }
            Move((float)newX, (float)newY);
        }

Usage Example

        protected override bool Process(Player player, RealmTime time, string args)
        {
            if (args.Length == 0)
            {
                player.SendHelp("Usage: /tpPos <X> <Y>");
                return false;
            }
            string[] coordinates = args.Split(' ');
            if (coordinates.Length != 2)
            {
                player.SendError("Invalid coordinates!");
                return false;
            }

            int x, y;
            if (!int.TryParse(coordinates[0], out x) ||
                !int.TryParse(coordinates[1], out y))
            {
                player.SendError("Invalid coordinates!");
                return false;
            }

            player.Move(x + 0.5f, y + 0.5f);
            player.SetNewbiePeriod();
            player.UpdateCount++;
            player.Owner.BroadcastPacket(new GotoPacket()
            {
                ObjectId = player.Id,
                Position = new Position()
                {
                    X = player.X,
                    Y = player.Y
                }
            }, null);
            return true;
        }