Beispiel #1
0
        public void SetPosition(int x, int y)
        {
            if (this.m_parent != null)
            {
                if (!this.m_parent.IsFlying() &&
                    !this.m_parent.IsUnderground() &&
                    this.m_parent.GetJump() <= 0 &&
                    !this.m_ignorePush)
                {
                    this.ValidatePos();

                    if (this.m_position.m_x >> 8 == x >> 8)
                    {
                        if ((this.m_position.m_y ^ (uint)y) < 256)
                        {
                            goto set;
                        }
                    }

                    LogicTileMap tileMap = this.m_parent.GetParent().GetLevel().GetTileMap();

                    int pathFinderX = x >> 8;
                    int pathFinderY = y >> 8;

                    if (!tileMap.IsPassablePathFinder(pathFinderX, pathFinderY))
                    {
                        LogicTile tile = tileMap.GetTile(pathFinderX / 2, pathFinderY / 2);

                        if (LogicDataTables.GetGlobals().JumpWhenHitJumpable())
                        {
                            bool allowJump = false;

                            for (int i = 0; i < tile.GetGameObjectCount(); i++)
                            {
                                LogicGameObject gameObject = tile.GetGameObject(i);

                                if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING)
                                {
                                    LogicBuilding building = (LogicBuilding)gameObject;

                                    if (building.GetHitWallDelay() > 0)
                                    {
                                        allowJump = true;
                                    }
                                }
                            }

                            if (allowJump)
                            {
                                this.m_position.m_x = x;
                                this.m_position.m_y = y;

                                this.m_parent.EnableJump(128);

                                return;
                            }
                        }

                        if (LogicDataTables.GetGlobals().SlideAlongObstacles())
                        {
                            throw new NotImplementedException(); // TODO: Implement this.
                        }
                        else
                        {
                            x = LogicMath.Clamp(x, (int)(this.m_position.m_x & 0xFFFFFF00), this.m_position.m_x | 0xFF);
                            y = LogicMath.Clamp(y, (int)(this.m_position.m_y & 0xFFFFFF00), this.m_position.m_y | 0xFF);
                        }

                        this.m_position.m_x = x;
                        this.m_position.m_y = y;

                        this.ValidatePos();
                        return;
                    }
                }
            }

set:

            this.m_position.m_x = x;
            this.m_position.m_y = y;
        }