public Vector2 GetAllowedMovement(Vector2 wantsToMoveAmount, Vector2 deltaPosition = default, MoveMode mode = MoveMode.HorizontalFirst) { Vector2 movedAmount = Vector2.zero; foreach (MoveUnit moveUnit in mode.GetMoveUnits(wantsToMoveAmount)) { movedAmount[moveUnit.axis] = moveUnit.dir * GetAllowedMovementAt(moveUnit.distance, moveUnit.dir, deltaPosition); } return(movedAmount); }
public Vector2 ForceMove(Vector2 wantsToMoveAmount, MoveMode mode = MoveMode.HorizontalFirst) { Vector2 effectiveMove = Vector2.zero; foreach (MoveUnit moveUnit in mode.GetMoveUnits(wantsToMoveAmount)) { effectiveMove[moveUnit.axis] = ForceMove(moveUnit.distance, moveUnit.dir); } return(effectiveMove); }
public Vector2 TryToMove(Vector2 wantsToMoveAmount, Vector2 deltaPosition = default, MoveMode mode = MoveMode.HorizontalFirst) { Vector2 movedAmount = deltaPosition; foreach (MoveUnit moveUnit in mode.GetMoveUnits(wantsToMoveAmount)) { if (!RaycastHelpers.IsValidDistance(moveUnit.distance)) { continue; } movedAmount[moveUnit.axis] = moveUnit.dir * TryToMove(moveUnit.distance, moveUnit.dir, deltaPosition); } return(movedAmount - deltaPosition); }