private IHexCell BuildCell( CellTerrain terrain = CellTerrain.Grassland, CellShape shape = CellShape.Flatlands, CellVegetation vegetation = CellVegetation.None, CellFeature feature = CellFeature.None, bool hasRoads = false, bool hasRiver = false, ICity city = null ) { var mockCell = new Mock <IHexCell>(); mockCell.SetupAllProperties(); var newCell = mockCell.Object; newCell.Terrain = terrain; newCell.Shape = shape; newCell.Vegetation = vegetation; newCell.Feature = feature; newCell.HasRoads = hasRoads; MockRiverCanon.Setup(canon => canon.HasRiver(newCell)).Returns(hasRiver); MockCityLocationCanon.Setup(canon => canon.GetPossessionsOfOwner(newCell)) .Returns(city != null ? new List <ICity>() { city } : new List <ICity>()); return(newCell); }
public void SetActiveVegetation(int index) { IsPainting = index >= 0; if (IsPainting) { ActiveVegetation = (CellVegetation)index; } }
private IHexCell BuildCell(CellTerrain terrain, CellShape shape, CellVegetation vegetation) { var mockCell = new Mock <IHexCell>(); mockCell.Setup(cell => cell.Terrain).Returns(terrain); mockCell.Setup(cell => cell.Shape).Returns(shape); mockCell.Setup(cell => cell.Vegetation).Returns(vegetation); return(mockCell.Object); }
public CellYieldModificationData(bool mustBeUnderwater, YieldSummary bonusYield) { _propertyConsidered = CellPropertyType.CellIsUnderwater; _mustBeUnderwater = mustBeUnderwater; _bonusYield = bonusYield; _terrainRequired = CellTerrain.Grassland; _shapeRequired = CellShape.Flatlands; _vegetationRequired = CellVegetation.None; }
public CellYieldModificationData(CellVegetation featureRequired, YieldSummary bonusYield) { _propertyConsidered = CellPropertyType.Vegetation; _vegetationRequired = featureRequired; _bonusYield = bonusYield; _terrainRequired = CellTerrain.Grassland; _shapeRequired = CellShape.Flatlands; _mustBeUnderwater = false; }
public float GetVegetationDefensiveness(CellVegetation vegetation) { var index = (int)vegetation; if (index >= VegetationDefensiveness.Count) { return(0); } else { return(VegetationDefensiveness[index]); } }
public YieldSummary GetYieldOfVegetation(CellVegetation vegetation) { switch (vegetation) { case CellVegetation.None: return(YieldSummary.Empty); case CellVegetation.Forest: return(ForestYield); case CellVegetation.Jungle: return(JungleYield); case CellVegetation.Marsh: return(MarshYield); default: throw new NotImplementedException(); } }
public void ChangeVegetationOfCell(IHexCell cell, CellVegetation vegetation) { if (!CanChangeVegetationOfCell(cell, vegetation)) { throw new InvalidOperationException("CanChangeVegetationOfCell must return true on the given arguments"); } cell.Vegetation = vegetation; if (vegetation == CellVegetation.Marsh) { ChangeTerrainOfCell(cell, CellTerrain.Grassland); ChangeShapeOfCell(cell, CellShape.Flatlands); } }
public int GetBaseMoveCostOfVegetation(CellVegetation feature) { switch (feature) { case CellVegetation.None: return(0); case CellVegetation.Forest: return(ForestMoveCost); case CellVegetation.Jungle: return(JungleMoveCost); case CellVegetation.Marsh: return(MarshMoveCost); default: throw new NotImplementedException(); } }
public int GetWeightFromVegetation(CellVegetation vegetation) { switch (vegetation) { case CellVegetation.None: return(NoVegetationWeight); case CellVegetation.Forest: return(ForestWeight); case CellVegetation.Jungle: return(JungleWeight); case CellVegetation.Marsh: return(MarshWeight); default: throw new NotImplementedException(); } }
private IHexCell BuildCell( CellTerrain terrain = CellTerrain.Grassland, CellShape shape = CellShape.Flatlands, CellVegetation vegetation = CellVegetation.None, CellFeature feature = CellFeature.None ) { var mockCell = new Mock <IHexCell>(); mockCell.Setup(cell => cell.Terrain).Returns(terrain); mockCell.Setup(cell => cell.Shape).Returns(shape); mockCell.Setup(cell => cell.Vegetation).Returns(vegetation); mockCell.Setup(cell => cell.Feature).Returns(feature); return(mockCell.Object); }
private Func <IHexCell, int> GetTreeSeedWeightFunction( CellVegetation treeType, IRegionBiomeTemplate template ) { return(delegate(IHexCell cell) { if (cell.Vegetation == CellVegetation.Marsh || cell.Feature != CellFeature.None || !ModLogic.CanChangeVegetationOfCell(cell, treeType) ) { return 0; } else { int terrainCost = template.GetTreePlacementCostForTerrain(cell.Terrain); int shapeCost = template.GetTreePlacementCostForShape(cell.Shape); return 1000 - 200 * (terrainCost + shapeCost); } }); }
public bool CanChangeVegetationOfCell(IHexCell cell, CellVegetation vegetation) { if (cell.Terrain.IsWater() && vegetation != CellVegetation.None && vegetation != CellVegetation.Marsh) { return(false); } else if (vegetation == CellVegetation.Forest) { return(cell.Terrain != CellTerrain.Desert && cell.Terrain != CellTerrain.FloodPlains && cell.Terrain != CellTerrain.Snow && cell.Shape != CellShape.Mountains); } else if (vegetation == CellVegetation.Jungle) { return((cell.Terrain == CellTerrain.Grassland || cell.Terrain == CellTerrain.Plains) && cell.Shape != CellShape.Mountains); } else { return(true); } }
private CrawlingWeightFunction GetTreeCrawlingCostFunction( CellVegetation treeType, IRegionBiomeTemplate template ) { return(delegate(IHexCell cell, IHexCell seed, IEnumerable <IHexCell> acceptedCells) { if (cell.Vegetation == CellVegetation.Marsh || cell.Feature != CellFeature.None || !ModLogic.CanChangeVegetationOfCell(cell, treeType) ) { return -1; } else { int terrainCost = template.GetTreePlacementCostForTerrain(cell.Terrain); int shapeCost = template.GetTreePlacementCostForShape(cell.Shape); int distanceCost = Grid.GetDistance(seed, cell); return terrainCost + shapeCost + distanceCost; } }); }
private IHexCell BuildCell( CellFeature feature = CellFeature.None, CellVegetation vegetation = CellVegetation.None, bool hasRiver = false, bool hasRoads = false, IEnumerable <IImprovement> improvements = null, ICivilization civClaiming = null ) { var mockCell = new Mock <IHexCell>(); mockCell.Setup(cell => cell.Feature).Returns(feature); mockCell.Setup(cell => cell.Vegetation).Returns(vegetation); mockCell.Setup(cell => cell.HasRoads).Returns(hasRoads); var newCell = mockCell.Object; MockRiverCanon.Setup(canon => canon.HasRiver(newCell)).Returns(hasRiver); MockImprovementLocationCanon.Setup(canon => canon.GetPossessionsOfOwner(newCell)).Returns( improvements != null ? improvements : new List <IImprovement>() ); MockCivTerritoryLogic.Setup(logic => logic.GetCivClaimingCell(newCell)).Returns(civClaiming); return(newCell); }
public bool IsCostIgnoredOnVegetation(CellVegetation vegetation) { return(VegetationsWithIgnoredCosts.Contains(vegetation)); }
public bool DoesVegetationConsumeFullMovement(CellVegetation vegetation) { return(VegetationConsumingFullMovement.Contains(vegetation)); }