public HarvesterTraitWrapper(Actor actor) { Actor = actor; Harvester = actor.Trait <Harvester>(); Parachutable = actor.TraitOrDefault <Parachutable>(); LocomotorInfo = actor.Info.TraitInfo <MobileInfo>().LocomotorInfo; }
internal WorldMovementInfo(World world, LocomotorInfo info) { // PERF: This struct allows us to cache the terrain info for the tileset used by the world. // This allows us to speed up some performance-sensitive pathfinding calculations. World = world; TerrainInfos = info.TilesetTerrainInfo[world.Map.Rules.TileSet]; }
public override void RulesetLoaded(Ruleset rules, ActorInfo ai) { var locomotorInfos = rules.Actors["world"].TraitInfos <LocomotorInfo>(); LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor); if (LocomotorInfo == null) { throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor)); } else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1) { throw new YamlException("There is more than one locomotor named '{0}'.".F(Locomotor)); } base.RulesetLoaded(rules, ai); }
bool ValidTransitionCell(CPos cell, LocomotorInfo li) { var terrainType = map.GetTerrainInfo(cell).Type; var sli = (SubterraneanLocomotorInfo)li; if (!sli.SubterraneanTransitionTerrainTypes.Contains(terrainType) && sli.SubterraneanTransitionTerrainTypes.Any()) { return(false); } if (sli.SubterraneanTransitionOnRamps) { return(true); } return(map.Ramp[cell] == 0); }
bool ValidTransitionCell(CPos cell, LocomotorInfo li) { var terrainType = map.GetTerrainInfo(cell).Type; var jli = (JumpjetLocomotorInfo)li; if (!jli.JumpjetTransitionTerrainTypes.Contains(terrainType) && jli.JumpjetTransitionTerrainTypes.Any()) { return(false); } if (jli.JumpjetTransitionOnRamps) { return(true); } return(map.Ramp[cell] == 0); }
public bool IsPassable(CPos p1, CPos p2, LocomotorInfo li) { // HACK: Work around units in other movement layers from being blocked // when the point in the main layer is not pathable if (p1.Layer != 0 || p2.Layer != 0) { return(true); } if (li.DisableDomainPassabilityCheck) { return(true); } var movementClass = li.GetMovementClass(tileSet); return(domainIndexes[movementClass].IsPassable(p1, p2)); }
public Locomotor(Actor self, LocomotorInfo info) { Info = info; sharesCell = info.SharesCell; world = self.World; var terrainInfo = world.Map.Rules.TerrainInfo; terrainInfos = new LocomotorInfo.TerrainInfo[terrainInfo.TerrainTypes.Length]; for (var i = 0; i < terrainInfos.Length; i++) { if (!info.TerrainSpeeds.TryGetValue(terrainInfo.TerrainTypes[i].Type, out terrainInfos[i])) { terrainInfos[i] = LocomotorInfo.TerrainInfo.Impassable; } } MovementClass = (uint)terrainInfos.Select(ti => ti.Cost < short.MaxValue).ToBits(); }
public override void RulesetLoaded(Ruleset rules, ActorInfo ai) { var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos <LocomotorInfo>(); LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor); if (LocomotorInfo == null) { throw new YamlException($"A locomotor named '{Locomotor}' doesn't exist."); } else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1) { throw new YamlException($"There is more than one locomotor named '{Locomotor}'."); } // We need to reset the reference to the locomotor between each worlds, otherwise we are reference the previous state. locomotor = null; base.RulesetLoaded(rules, ai); }
bool ValidTransitionCell(CPos cell, LocomotorInfo li) { var terrainType = map.GetTerrainInfo(cell).Type; var sli = (SubterraneanLocomotorInfo)li; if (!sli.SubterraneanTransitionTerrainTypes.Contains(terrainType) && sli.SubterraneanTransitionTerrainTypes.Any()) { return(false); } if (sli.SubterraneanTransitionOnRamps) { return(true); } var tile = map.Tiles[cell]; var ti = map.Rules.TileSet.GetTileInfo(tile); return(ti == null || ti.RampType == 0); }
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return(enabled); }
public Locomotor(Actor self, LocomotorInfo info) { Info = info; }
public MoveOrderTargeter(Actor self, Mobile unit) { mobile = unit; locomotorInfo = mobile.Info.LocomotorInfo; rejectMove = !self.AcceptsOrder("Move"); }
short ICustomMovementLayer.ExitMovementCost(LocomotorInfo li, CPos cell) { var sli = (SubterraneanLocomotorInfo)li; return(ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : PathGraph.MovementCostForUnreachableCell); }
bool ICustomMovementLayer.EnabledForLocomotor(LocomotorInfo li) { return(li is JumpjetLocomotorInfo); }
int ICustomMovementLayer.ExitMovementCost(ActorInfo a, LocomotorInfo li, CPos cell) { return(ends.Contains(cell) ? 0 : int.MaxValue); }
public Locomotor(Actor self, LocomotorInfo info) { Info = info; sharesCell = info.SharesCell; }
int ICustomMovementLayer.ExitMovementCost(ActorInfo a, LocomotorInfo li, CPos cell) { var sli = (SubterraneanLocomotorInfo)li; return(ValidTransitionCell(cell, sli) ? sli.SubterraneanTransitionCost : int.MaxValue); }
bool ICustomMovementLayer.EnabledForActor(ActorInfo a, LocomotorInfo li) { return(li is SubterraneanLocomotorInfo); }
short ICustomMovementLayer.ExitMovementCost(LocomotorInfo li, CPos cell) { var jli = (JumpjetLocomotorInfo)li; return(ValidTransitionCell(cell, jli) ? jli.JumpjetTransitionCost : PathGraph.MovementCostForUnreachableCell); }
int ICustomMovementLayer.ExitMovementCost(ActorInfo a, LocomotorInfo li, CPos cell) { var jli = (JumpjetLocomotorInfo)li; return(ValidTransitionCell(cell, jli) ? jli.JumpjetTransitionCost : int.MaxValue); }
int ICustomMovementLayer.EntryMovementCost(ActorInfo a, LocomotorInfo li, CPos cell) { return(portals.Contains(cell) ? 0 : int.MaxValue); }
short ICustomMovementLayer.ExitMovementCost(LocomotorInfo li, CPos cell) { return(ends.Contains(cell) ? (short)0 : PathGraph.MovementCostForUnreachableCell); }