public void PushTrap(LogicVector2 position, int time, int id, bool ignorePrevPush, bool verifyPushPosition) { if (this.m_pushTime <= 0 || ignorePrevPush) { if (this.m_parent != null && this.m_parent.GetJump() <= 0 && !this.m_parent.GetParent().IsHero()) { LogicGameObject parent = this.m_parent.GetParent(); if (!parent.IsHero()) { if (id != 0 && !ignorePrevPush) { int idx = -1; for (int k = 0; k < 3; k++) { if (this.m_preventsPushId[k] == id) { return; } if (this.m_preventsPushTime[k] == 0) { idx = k; } } if (idx == -1) { return; } this.m_preventsPushId[idx] = id; this.m_preventsPushTime[idx] = 1500; } this.m_pushTime = time; this.m_pushInitTime = time; this.m_pushBackStartPosition.m_x = this.m_position.m_x; this.m_pushBackStartPosition.m_y = this.m_position.m_y; this.m_pushBackEndPosition.m_x = this.m_position.m_x + position.m_x; this.m_pushBackEndPosition.m_y = this.m_position.m_y + position.m_y; if (verifyPushPosition) { int pushBackEndPositionX = this.m_pushBackEndPosition.m_x; int pushBackEndPositionY = this.m_pushBackEndPosition.m_y; if (LogicMath.Max(LogicMath.Abs(position.m_x), LogicMath.Abs(position.m_y)) != 0) { LogicTileMap tileMap = parent.GetLevel().GetTileMap(); if (!tileMap.IsPassablePathFinder(pushBackEndPositionX >> 8, pushBackEndPositionY >> 8)) { LogicVector2 pos = new LogicVector2(); LogicRandom rnd = new LogicRandom(pushBackEndPositionX + pushBackEndPositionY); tileMap.GetNearestPassablePosition(pushBackEndPositionX + rnd.Rand(512) - 256, pushBackEndPositionY + rnd.Rand(512) - 256, pos, 2048); pushBackEndPositionX = pos.m_x; pushBackEndPositionY = pos.m_y; } if (!tileMap.IsPassablePathFinder(pushBackEndPositionX >> 8, pushBackEndPositionY >> 8)) { Debugger.Warning("PushTrap->ended on inmovable"); } } this.m_pushBackEndPosition.m_x = pushBackEndPositionX; this.m_pushBackEndPosition.m_y = pushBackEndPositionY; } this.m_ignorePush = verifyPushPosition; int angle = position.GetAngle(); this.m_direction = angle + (angle <= 180 ? 180 : -180); } } } }