Пример #1
0
        public virtual bool Teleport(ObjectPosition destination, bool performCheck = true)
        {
            if (IsMoving())
            {
                StopMove();
            }

            if (!CanChangeMap() && performCheck)
            {
                return(false);
            }

            if (Position.Map == destination.Map)
            {
                return(MoveInstant(destination));
            }

            NextMap = destination.Map;
            LastMap = Map;

            Position.Map.Leave(this);

            if (!NextMap.Area.IsRunning)
            {
                NextMap.Area.Start();
            }

            NextMap.Area.ExecuteInContext(() =>
            {
                Position = destination.Clone();
                Position.Map.Enter(this);

                NextMap = null;
                LastMap = null;

                OnTeleported(Position);
            });

            return(true);
        }
Пример #2
0
        public virtual bool Teleport(ObjectPosition destination, bool performCheck = true)
        {
            if (this.IsMoving())
            {
                this.StopMove();
            }
            bool result;

            if (!this.CanChangeMap() && performCheck)
            {
                result = false;
            }
            else
            {
                if (this.Position.Map == destination.Map)
                {
                    result = this.MoveInstant(destination);
                }
                else
                {
                    base.NextMap = destination.Map;
                    base.LastMap = base.Map;
                    this.Position.Map.Leave(this);
                    base.NextMap.Area.ExecuteInContext(delegate
                    {
                        this.Position = destination.Clone();
                        this.Position.Map.Enter(this);
                        this.NextMap = null;
                        this.LastMap = null;
                        this.OnTeleported(this.Position);
                    });
                    result = true;
                }
            }
            return(result);
        }