public bool IsTraversable(Vector2Int destination, MovementType movementType, int pushStrength = 1) { if (!this.HasGround(destination)) { return(false); } var direction = movementType.GetAngle(); if (!this.HasOccupant(destination) || this.GetOccupant(destination).IsPassiveOccupant || this.GetOccupant(destination).isMoving || this.GetOccupant(destination).GetType() == typeof(Player)) { return(true); } var origin = destination - direction.AsVector2Int(); pushStrength = Mathf.Max( pushStrength, this.GetOccupant(origin)?.PushStrength ?? 0, this.GetInboundOccupant(origin)?.PushStrength ?? 0); --pushStrength; if (this.GetOccupant(destination).IsPushable&& pushStrength >= 0 && this.IsTraversable(destination + direction.AsVector2Int(), movementType, pushStrength)) { return(true); } return(false); }
private void OnStartDestination(Ground destination, BaseItem item, MovementType movement) { if (destination.occupant != null && !destination.occupant.IsPassiveOccupant) { destination.occupant.warehouseDestination = this.warehouseManager.GetGround(destination.occupant.WarehouseIndex.Value + movement.GetAngle().AsVector2Int()); } }