public bool IsCrushableBy(UnitMovementType umt, Player player) { if (player == self.Owner) return false; switch (umt) { case UnitMovementType.Track: return true; default: return false; } }
public float GetCost(UnitMovementType umt) { switch (umt) /* todo: make this nice */ { case UnitMovementType.Fly: return 1; case UnitMovementType.Foot: return 1 / Foot; case UnitMovementType.Wheel: return 1 / Wheel; case UnitMovementType.Track: return 1 / Track; case UnitMovementType.Float: return 1 / Float; default: throw new InvalidOperationException("wtf?"); } }
public void SetUnitMoveType(UnitMovementType newMoveType) { currentUnitMoveType = newMoveType; switch (currentUnitMoveType) { case UnitMovementType.CharacterController: if (controller) { deactivateOldMoveTypeController(); controller.gameObject.SetActive(true); } else { currentUnitMoveType = oldUnitMoveType; } break; case UnitMovementType.NavMeshAgent: if (navAgent) { deactivateOldMoveTypeController(); navAgent.gameObject.SetActive(true); } else { currentUnitMoveType = oldUnitMoveType; } break; case UnitMovementType.Rigidbody: if (rb) { deactivateOldMoveTypeController(); rb.gameObject.SetActive(true); } else { currentUnitMoveType = oldUnitMoveType; } break; } }
public static PathSearch FromPoints(World world, IEnumerable<int2> froms, int2 target, UnitMovementType umt, bool checkForBlocked) { var search = new PathSearch(world) { heuristic = DefaultEstimator(target), umt = umt, checkForBlocked = checkForBlocked }; foreach (var sl in froms) search.AddInitialCell(world, sl); return search; }
public static PathSearch FromPoint( World world, int2 from, int2 target, UnitMovementType umt, bool checkForBlocked ) { var search = new PathSearch(world) { heuristic = DefaultEstimator( target ), umt = umt, checkForBlocked = checkForBlocked }; search.AddInitialCell( world, from ); return search; }
public static bool IsPathableCell(this World world, int2 a, UnitMovementType umt) { if (world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(a) != null) return false; if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a).Any()) return false; return world.Map.IsInMap(a.X, a.Y) && Rules.TerrainTypes[world.TileSet.GetTerrainType(world.Map.MapTiles[a.X, a.Y])] .GetCost(umt) < float.PositiveInfinity; }
public static bool IsActorPathableToCrush(this World world, Actor a, UnitMovementType umt) { return a != null && a.traits.WithInterface<ICrushable>() .Any(c => c.IsPathableCrush(umt, a.Owner)); }
public bool IsPathableCrush(UnitMovementType umt, Player player) { return IsCrushableBy(umt, player); }
public float GetCost(int2 p, UnitMovementType umt) { return Rules.TerrainTypes[Templates[state].TerrainType[Tiles[p]]].GetCost(umt); }