// 0: valid // -1: cell not valid // -2: not in range int validatePos(Character hero, int x, int y) { CentralController cc = CentralController.inst; TerrainGrid tg = cc.getGlobalTerainGrid(); // check if it out of range Vector2 pos = CentralController.getPosFromCord(hero.gameObject.transform.position); int dist_x = (int)pos.x - x; int dist_y = (int)pos.y - y; //print ("dist:" + dist_x + "," + dist_y); int max = hero.getEffectMaxMoveDistance(); if (dist_x > max || dist_x < -max || dist_y > max || dist_y < -max) { return(-2); } // check if is shown as a valid cell if (!tg.IsCellValid(x, y)) { return(-1); } //GameObject cell = tg.getCell (x, y); return(0); }
public override void Generate(Map map, GenStepParams parms) { //RoadsOfTheRim.DebugLog("Cleaning up roads if I can"); TerrainGrid terrainGrid = map.terrainGrid; foreach (IntVec3 current in map.AllCells) { List <Thing> thingList = current.GetThingList(map); TerrainDef terrainDefHere = terrainGrid.TerrainAt(current); if (isBuiltRoad(terrainDefHere)) { map.roofGrid.SetRoof(current, null); // remove any roof if (map.fogGrid.IsFogged(current)) { map.fogGrid.Unfog(current); // no fog on road } if (thingList.Count > 0) { //RoadsOfTheRim.DebugLog("Placed " + thingList.Count + " things on top of " + terrainDefHere.label); MoveThings(map, current); } /* * Quick and dirty hack because classes in the Bridge.cs file do not handle all cases properly. Terrain needs to be set again over water & MarshyTerrain as below. */ if (map.terrainGrid.UnderTerrainAt(current).IsWater) { if (terrainDefHere == TerrainDefOf.GlitterRoad) { map.terrainGrid.SetTerrain(current, TerrainDefOf.GlitterRoad); } if (terrainDefHere == TerrainDefOf.AsphaltRecent) { map.terrainGrid.SetTerrain(current, TerrainDefOf.ConcreteBridge); } if (terrainDefHere == TerrainDefOf.StoneRecent) { map.terrainGrid.SetTerrain(current, TerrainDefOf.ConcreteBridge); } } if (map.terrainGrid.UnderTerrainAt(current) == TerrainDefOf.MarshyTerrain) { if (terrainDefHere == TerrainDefOf.GlitterRoad) { map.terrainGrid.SetTerrain(current, TerrainDefOf.GlitterRoad); } if (terrainDefHere == TerrainDefOf.AsphaltRecent) { map.terrainGrid.SetTerrain(current, TerrainDefOf.AsphaltRecent); } if (terrainDefHere == TerrainDefOf.StoneRecent) { map.terrainGrid.SetTerrain(current, TerrainDefOf.StoneRecent); } } } } }
private bool ShouldDrawPropsBelow(IntVec3 c, TerrainGrid terrGrid) { TerrainDef terrainDef = terrGrid.TerrainAt(c); bool result; if (terrainDef == null || terrainDef != TerrainDefOf.Bridge) { result = false; } else { IntVec3 c2 = c; c2.z--; Map map = base.Map; if (!c2.InBounds(map)) { result = false; } else { TerrainDef terrainDef2 = terrGrid.TerrainAt(c2); result = (terrainDef2 != TerrainDefOf.Bridge && (terrainDef2.passability == Traversability.Impassable || c2.SupportsStructureType(map, TerrainDefOf.Bridge.terrainAffordanceNeeded))); } } return(result); }
private bool ShouldDrawPropsBelow(IntVec3 c, TerrainGrid terrGrid) { TerrainDef terrainDef = terrGrid.TerrainAt(c); if (terrainDef == null || terrainDef != TerrainDefOf.Bridge) { return(false); } IntVec3 c2 = c; c2.z--; Map map = base.Map; if (!c2.InBounds(map)) { return(false); } TerrainDef terrainDef2 = terrGrid.TerrainAt(c2); if (terrainDef2 == TerrainDefOf.Bridge) { return(false); } if (terrainDef2.passability != Traversability.Impassable && !c2.SupportsStructureType(map, TerrainDefOf.Bridge.terrainAffordanceNeeded)) { return(false); } return(true); }
void Start() { instance = this; manager = SceneManager.GetInstance(); terrainGrid = TerrainGrid.GetInstance(); ui = InterfaceManager.GetInstance(); }
public override void Generate(Map map, GenStepParams parms) { BeachMaker.Init(map); RiverMaker riverMaker = GenerateRiver(map); List <IntVec3> list = new List <IntVec3>(); MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid fertility = MapGenerator.Fertility; MapGenFloatGrid caves = MapGenerator.Caves; TerrainGrid terrainGrid = map.terrainGrid; foreach (IntVec3 allCell in map.AllCells) { Building edifice = allCell.GetEdifice(map); TerrainDef terrainDef = null; terrainDef = (((edifice == null || edifice.def.Fillage != FillCategory.Full) && !(caves[allCell] > 0f)) ? TerrainFrom(allCell, map, elevation[allCell], fertility[allCell], riverMaker, preferSolid: false) : TerrainFrom(allCell, map, elevation[allCell], fertility[allCell], riverMaker, preferSolid: true)); if (terrainDef.IsRiver && edifice != null) { list.Add(edifice.Position); edifice.Destroy(); } terrainGrid.SetTerrain(allCell, terrainDef); } riverMaker?.ValidatePassage(map); RemoveIslands(map); RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map); BeachMaker.Cleanup(); foreach (TerrainPatchMaker terrainPatchMaker in map.Biome.terrainPatchMakers) { terrainPatchMaker.Cleanup(); } }
public override void Regenerate() { ClearSubMeshes(MeshParts.All); Map map = base.Map; TerrainGrid terrainGrid = map.terrainGrid; CellRect cellRect = section.CellRect; float y = AltitudeLayer.TerrainScatter.AltitudeFor(); foreach (IntVec3 item in cellRect) { if (ShouldDrawPropsBelow(item, terrainGrid)) { IntVec3 c = item; c.x++; Material material = ((!c.InBounds(map) || !ShouldDrawPropsBelow(c, terrainGrid)) ? PropsRightMat : PropsLoopMat); LayerSubMesh subMesh = GetSubMesh(material); int count = subMesh.verts.Count; subMesh.verts.Add(new Vector3(item.x, y, item.z - 1)); subMesh.verts.Add(new Vector3(item.x, y, item.z)); subMesh.verts.Add(new Vector3(item.x + 1, y, item.z)); subMesh.verts.Add(new Vector3(item.x + 1, y, item.z - 1)); subMesh.uvs.Add(new Vector2(0f, 0f)); subMesh.uvs.Add(new Vector2(0f, 1f)); subMesh.uvs.Add(new Vector2(1f, 1f)); subMesh.uvs.Add(new Vector2(1f, 0f)); subMesh.tris.Add(count); subMesh.tris.Add(count + 1); subMesh.tris.Add(count + 2); subMesh.tris.Add(count); subMesh.tris.Add(count + 2); subMesh.tris.Add(count + 3); } } FinalizeMesh(MeshParts.All); }
static void Main(string[] args) { //Console.Write("Grid dimentions(x,y): "); string input = Console.ReadLine(); var parts = input.Split(' '); int x = Convert.ToInt32(parts[0]); int y = Convert.ToInt32(parts[1]); var terrain = new TerrainGrid(x, y); //Console.Write("Number of robots: "); int numRobots = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < numRobots; i++) { string robotPosition = Console.ReadLine(); var robotPositionParts = robotPosition.Split(' '); int robotPositionX = Convert.ToInt32(robotPositionParts[0]); int robotPositionY = Convert.ToInt32(robotPositionParts[1]); string robotPositionOrientation = robotPositionParts[2]; var robot = new Robot(terrain, new GridPoint(robotPositionX, robotPositionY), CompassDirection.NORTH); switch (robotPositionOrientation) { case "S": robot = new Robot(terrain, new GridPoint(robotPositionX, robotPositionY), CompassDirection.SOUTH); break; case "E": robot = new Robot(terrain, new GridPoint(robotPositionX, robotPositionY), CompassDirection.EAST); break; case "W": robot = new Robot(terrain, new GridPoint(robotPositionX, robotPositionY), CompassDirection.WEST); break; } string commands = Console.ReadLine(); foreach (char letter in commands) { switch (letter) { case 'M': robot.MoveForward(); break; case 'L': robot.TurnLeft(); break; case 'R': robot.TurnRight(); break; } } Console.WriteLine($"{robot.CurrentGridPosition.X} {robot.CurrentGridPosition.Y} {robot.CurrentCompassOrientation.ToString()}"); } Console.ReadKey(); }
void hideTerrainGrid() { CentralController cc = CentralController.inst; TerrainGrid tg = cc.getGlobalTerainGrid(); tg.inactiveAllCells(); }
/// <summary> /// Convert Config to user friendly string /// </summary> /// <returns>string</returns> public override string ToString() { //Start cfg string var basicConfig = ""; basicConfig += "language=\"" + DLL.HelperFunctions.Capitalize(System.Enum.GetName(typeof(Language), language)) + "\";" + Helpers.NewLine() + "MaxMsgSend = " + MaxMsgSend + ";" + Helpers.NewLine() + "MaxSizeGuaranteed = " + MaxSizeGuaranteed + ";" + Helpers.NewLine() + "MaxSizeNonguaranteed = " + MaxSizeNonguaranteed + ";" + Helpers.NewLine() + "MinBandwidth = " + MinBandwidth + ";" + Helpers.NewLine() + "MaxBandwidth = " + MaxBandwidth + ";" + Helpers.NewLine() + "MinErrorToSend = " + MinErrorToSend.ToString(CultureInfo.InvariantCulture) + ";" + Helpers.NewLine() + "MinErrorToSendNear = " + MinErrorToSendNear.ToString(CultureInfo.InvariantCulture) + ";" + Helpers.NewLine() + "MaxCustomFileSize = " + MaxCustomFileSize + ";" + Helpers.NewLine() + "class sockets{maxPacketSize = " + MaxPacketSize + ";};" + Helpers.NewLine() + "adapter=" + adapter + ";" + Helpers.NewLine() + "3D_Performance=" + Performance_3D + ";" + Helpers.NewLine() + "Resolution_W= " + Resolution_W + ";" + Helpers.NewLine() + "Resolution_H=" + Resolution_H + ";" + Helpers.NewLine() + "Resolution_Bpp=" + Resolution_Bpp + ";" + Helpers.NewLine() + "terrainGrid=" + TerrainGrid.ToString(CultureInfo.InvariantCulture) + ";" + Helpers.NewLine() + "viewDistance=" + ViewDistance + ";" + Helpers.NewLine() + "Windowed=" + Windowed + ";"; return(basicConfig); }
public bool ShouldDrawPropsBelow(IntVec3 c, TerrainGrid terrGrid) { TerrainDef terrainDef = terrGrid.TerrainAt(c); if (terrainDef == null || !terrainDef.IsBiomesBridge() || terrainDef.BiomesBridgeLoopMat() == null || terrainDef.BiomesBridgeRightMat() == null) { return(false); } IntVec3 c2 = c; c2.z--; Map map = base.Map; if (!c2.InBounds(map)) { return(false); } TerrainDef terrainDef2 = terrGrid.TerrainAt(c2); if (terrainDef2.IsBiomesBridge()) { return(false); } if (terrainDef2.passability != Traversability.Impassable && !c2.SupportsStructureType(map, terrainDef.terrainAffordanceNeeded)) { return(false); } return(true); }
/// <summary> /// This is a heavily simplified version of the vanilla GenStep_Terrain /// Most of the original isn't needed, and there are several changes to the parts that are left /// </summary> /// <param name="map"></param> /// <param name="parms"></param> public override void Generate(Map map, GenStepParams parms) { //check if it's our biome. If not, skip if (map.Biome.defName != "RockMoonBiome") { return; } mapRadiusSize = map.Size.x / 2; List <IntVec3> list = new List <IntVec3>(); MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid fertility = MapGenerator.Fertility; MapGenFloatGrid caves = MapGenerator.Caves; TerrainGrid terrainGrid = map.terrainGrid; foreach (IntVec3 current in map.AllCells) { Building edifice = current.GetEdifice(map); TerrainDef terrainDef; terrainDef = this.TerrainFrom(current, fertility[current]); terrainGrid.SetTerrain(current, terrainDef); } RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map); BeachMaker.Cleanup(); foreach (TerrainPatchMaker current2 in map.Biome.terrainPatchMakers) { current2.Cleanup(); } }
private void DecrementsTerrainDef(IntVec3 pos, TerrainDef terrain, TerrainDef originalTerrain) { TerrainGrid terrainGrid = this.Map.terrainGrid; if (terrainGrid == null) { return; } bool ex = (terrain is TerrainDefEx); if (!ex) { return; } TerrainDefEx terrainEx = (TerrainDefEx)terrain; if (terrainEx.BuffCount <= 1) { terrainGrid.SetTerrain(pos, originalTerrain); } else { terrainGrid.SetTerrain(pos, new TerrainDef1(terrain, terrainEx.BuffCount, false)); } }
// Token: 0x0600000A RID: 10 RVA: 0x00002320 File Offset: 0x00000520 private bool ShouldDrawPropsBelow(IntVec3 c, TerrainGrid terrGrid) { TerrainDef terrainDef = terrGrid.TerrainAt(c); bool result; if (terrainDef == null || !this.IsTerrainThisBridge(terrainDef)) { result = false; } else { IntVec3 c2 = c; c2.z--; if (!c2.InBounds(base.Map)) { result = false; } else { TerrainDef terrain = terrGrid.TerrainAt(c2); result = (!this.IsTerrainThisBridge(terrain) && (c2.SupportsStructureType(base.Map, TerrainAffordanceDefOf.Bridgeable) || c2.SupportsStructureType(base.Map, TerrainAffordanceDefOf.BridgeableDeep))); } } return(result); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; TerrainGrid terrainGrid = map.terrainGrid; TerrainDef terrainDef = rp.floorDef ?? BaseGenUtility.RandomBasicFloorDef(rp.faction, false); bool? floorOnlyIfTerrainSupports = rp.floorOnlyIfTerrainSupports; bool flag = floorOnlyIfTerrainSupports.HasValue && floorOnlyIfTerrainSupports.Value; CellRect.CellRectIterator iterator = rp.rect.GetIterator(); while (!iterator.Done()) { if (!rp.chanceToSkipFloor.HasValue || !Rand.Chance(rp.chanceToSkipFloor.Value)) { if (!flag || GenConstruct.CanBuildOnTerrain(terrainDef, iterator.Current, map, Rot4.North, null)) { terrainGrid.SetTerrain(iterator.Current, terrainDef); if (rp.filthDef != null) { FilthMaker.MakeFilth(iterator.Current, map, rp.filthDef, (!rp.filthDensity.HasValue) ? 1 : Mathf.RoundToInt(rp.filthDensity.Value.RandomInRange)); } } } iterator.MoveNext(); } }
void Awake() { Instance = this; Totems.Add(ServerPlayerId, new List <Totem>()); Totems.Add(ClientPlayerId, new List <Totem>()); }
public override void Build(ref TerrainGrid terrain, Random rand=null) { rand = rand ?? new Random(); var notConnected = _pointFinder.Find(terrain).ToList(); var connected = new List<Vector>(); var randPoint = notConnected[rand.Next(notConnected.Count)]; connected.Add(randPoint); notConnected.Remove(randPoint); while (notConnected.Any()) { var lhs = notConnected[rand.Next(notConnected.Count)]; var rhs = connected[rand.Next(connected.Count)]; var path = _router.Route(lhs, rhs, terrain); foreach (var point in path) terrain[point] = TerrainTypes.Path; connected.Add(lhs); notConnected.Remove(lhs); } }
// Token: 0x060000E4 RID: 228 RVA: 0x0000715C File Offset: 0x0000535C public void BurnSurface() { foreach (IntVec3 intVec in this.cellsToAffect) { if (!intVec.IsValid) { continue; } try { TerrainGrid terrainGrid = base.Map.terrainGrid; TerrainDef terrain = intVec.GetTerrain(base.Map); if (terrain.burnedDef != null && intVec.TerrainFlammableNow(base.Map)) { terrainGrid.RemoveTopLayer(intVec, false); terrainGrid.SetTerrain(intVec, terrain.burnedDef); } if (base.Map.snowGrid.GetDepth(intVec) > 0f) { base.Map.snowGrid.SetDepth(intVec, 0f); } } catch (Exception ex) { Log.Warning(string.Concat(new object[] { "BurnSurface could not affect cell ", intVec, ": ", ex }), false); } } }
/* void OnMouseUp(){ * print ("i am selected:"+this.gameObject.name); * if (CentralController.inst.currentSelectedChar) { * print ("last selectd:" + CentralController.inst.currentSelectedChar.name); * //hideTerrainGrid (CentralController.inst.currentSelectedChar); * } * CentralController.inst.currentSelectedChar = this.gameObject; * showTerrainGrid (CentralController.inst.currentSelectedChar); * CentralController.inst.state = 100; * }*/ void showTerrainGrid(GameObject go) { CentralController cc = CentralController.inst; TerrainGrid tg = cc.getGlobalTerainGrid(); tg.inactiveAllCells(); Vector2 pos = CentralController.getPosFromCord(go.transform.position); print("ch pos:" + pos); int range = this.GetComponent <Character>().max_move_distance; int start_x = (int)(pos.x - range); int x = start_x; int start_y = (int)(pos.y + range); int y = start_y; for (int k = 0; k < range * 2; k++) { for (int i = 0; i < range * 2; i++) { tg.activeCell(x, y); y -= 1; } y = start_y; x += 1; } }
private void Awake() { instance = this; CreateGrid(); CreateMouseCollider(); control = amp + freq + seed; }
public override HashSet<Vector> Find(TerrainGrid terrain) { var interestPoints = new HashSet<Vector>(); var blocking = new Grid<bool>(terrain.Size); foreach (var point in terrain.GetPoints()) { var terrainType = terrain[point]; blocking[point] = TerrainTypes.Blocking.Contains(terrainType); } blocking = _filters.Close(blocking); var areas = _areaFinder.Find(blocking).ToList(); areas.RemoveAll((area) => area.Count <= 20); foreach (var area in areas) { var areaList = area.ToList(); int xMean = (int)areaList.Average((p) => p.x); int yMean = (int)areaList.Average((p) => p.y); Vector centroid = new Vector(xMean, yMean); interestPoints.Add(centroid); } return interestPoints; }
public BasicTerrain(int sideVertexCount) { grid = new TerrainGrid(sideVertexCount); //texture = new TerrainTexture(TextureUnit.Texture0, sideVertexCount, "l{0}.bmp", MaxLevels); texture = new TerrainTexture(TextureUnit.Texture0, sideVertexCount, "island{0}.bt", MaxLevels); program = new TerrainProgram(); }
public static void Postfix(TerrainGrid __instance, IntVec3 c) { Map map = (Map)typeof(TerrainGrid). GetField("map", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); (map.haulDestinationManager.SlotGroupAt(c)?.parent as Building_Shelf)?.RecalcMaxStockWeight(); }
public void OnSceneGUI() { // get the chosen game object TerrainGrid t = target as TerrainGrid; if (t == null) { return; } if (mTerrainGrid == null) { foreach (GameObject obj in Object.FindObjectsOfType(typeof(GameObject))) { Terrain terrain = obj.GetComponent <Terrain>(); if (terrain != null) { mTerrainGrid = obj.GetComponent <TerrainGrid>(); mTerrain = terrain; break; } } } if (mTerrainGrid == null) { return; } if (mTerrainGrid.显示编号 == false) { return; } int grids = (int)mTerrainGrid.Grid_NxN; grids = (int)System.Math.Pow(2, grids); float skipX = mTerrain.terrainData.size.x / grids; float skipY = mTerrain.terrainData.size.z / grids; for (int y = 0; y < grids; y++) { for (int x = 0; x < grids; x++) { int terrainNumber = y * grids + x; Vector3 center = new Vector3(t.transform.position.x + x * skipX + skipX / 2.0f, 0, t.transform.position.z + y * skipY + skipY / 2.0f); Handles.DrawLine(center, new Vector3(center.x, 100, center.z)); Handles.Label(new Vector3(center.x, 103, center.z), terrainNumber.ToString()); } } // grab the center of the parent // Vector3 center = t.transform.position; //Handles.DrawLine(new Vector3(0, 0, 0), new Vector3(100, 200, 200)); // Handles.Label(new Vector3(100, 200, 200), "2"); }
static void Prefix(IntVec3 c, TerrainGrid __instance) { if (__instance.TerrainAt(c) is SpecialTerrain special) { var specialTerrainList = Traverse.Create(__instance).Field("map").GetValue <Map>().GetComponent <SpecialTerrainList>(); specialTerrainList.Notify_RemovedTerrainAt(c); } }
static void Postfix(IntVec3 c, TerrainDef newTerr, TerrainGrid __instance) { if (newTerr is SpecialTerrain special) { var specialTerrainList = Traverse.Create(__instance).Field("map").GetValue <Map>().GetComponent <SpecialTerrainList>(); specialTerrainList.RegisterAt(special, c); } }
static void Prefix(IntVec3 c, TerrainGrid __instance, Map ___map) { if (__instance.TerrainAt(c) is ActiveTerrainDef special) { var specialTerrainList = ___map.GetComponent <SpecialTerrainList>(); specialTerrainList.Notify_RemovedTerrainAt(c); } }
static void Postfix(IntVec3 c, TerrainDef newTerr, TerrainGrid __instance, Map ___map) { if (newTerr is ActiveTerrainDef special) { var specialTerrainList = ___map.GetComponent <SpecialTerrainList>(); specialTerrainList.RegisterAt(special, c); } }
public static bool Prefix(TerrainGrid __instance, IntVec3 c, bool doLeavings, Map ___map, ref TerrainDef[] ___underGrid) { try { var ZTracker = ZUtils.ZTracker; if (ZTracker.GetZIndexFor(___map) > 0) { int num = ___map.cellIndices.CellToIndex(c); if (doLeavings) { GenLeaving.DoLeavingsFor(__instance.topGrid[num], c, ___map); } if (___underGrid[num] != null) { __instance.topGrid[num] = ___underGrid[num]; ___underGrid[num] = null; Traverse.Create(__instance).Method("DoTerrainChangedEffects", new object[] { c }).GetValue(); } if (c.GetTerrain(___map) == TerrainDefOf.Sand) { __instance.SetTerrain(c, ZLevelsDefOf.ZL_OutsideTerrain); } Map lowerMap = ZTracker.GetLowerLevel(___map.Tile, ___map); bool firstTime = false; if (lowerMap == null) { return(false); //lowerMap = ZTracker.CreateLowerLevel(___map, c); firstTime = true; } var thingList = c.GetThingList(___map); if (thingList.Where(x => x is Blueprint || x is Frame).Count() == 0) { for (int i = thingList.Count - 1; i >= 0; i--) { if (!(thingList[i] is Mineable || thingList[i] is Blueprint || thingList[i] is Frame)) { //Log.Message(thingList[i] + " going down 1"); ZTracker.SimpleTeleportThing(thingList[i], c, lowerMap, firstTime, 10); } } } return(false); } } catch (Exception ex) { Log.Error("[Z-Levels] DestroyedTerrain patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex, true); } return(true); }
static void Prefix(IntVec3 c, TerrainDef newTerr, TerrainGrid __instance, Map ___map) { var oldTerr = ___map.terrainGrid.TerrainAt(c); if (oldTerr is ActiveTerrainDef special) { ___map.GetComponent <SpecialTerrainList>().Notify_RemovedTerrainAt(c); } }
void check_fight2(Character character, Vector2 pos) { print("check_fight"); TerrainGrid tg = CentralController.inst.getGlobalTerainGrid(); Character enemy = null; Vector2 _pos = new Vector2(pos.x, pos.y); _pos.x = pos.x + 1; enemy = tg.getCell(_pos).GetComponent <Cell>().character; print("enemy:" + enemy); if (enemy != null) { print("enemy faction:" + enemy.getFaction()); } if (enemy != null && enemy.getFaction().factionID != 0) { start_fight(character, enemy); } _pos.x = pos.x - 1; enemy = tg.getCell(_pos).GetComponent <Cell>().character; print("enemy:" + enemy); if (enemy != null) { print("enemy faction:" + enemy.getFaction()); } if (enemy != null && enemy.getFaction().factionID != 0) { start_fight(character, enemy); } _pos.y = pos.y + 1; enemy = tg.getCell(_pos).GetComponent <Cell>().character; print("enemy:" + enemy); if (enemy != null) { print("enemy faction:" + enemy.getFaction()); } if (enemy != null && enemy.getFaction().factionID != 0) { start_fight(character, enemy); } _pos.y = pos.y - 1; enemy = tg.getCell(_pos).GetComponent <Cell>().character; print("enemy:" + enemy); if (enemy != null) { print("enemy faction:" + enemy.getFaction()); } if (enemy != null && enemy.getFaction().factionID != 0) { start_fight(character, enemy); } }
private static void Prefix(IntVec3 c, TerrainDef newTerr, TerrainGrid __instance) { var value = Traverse.Create(__instance).Field("map").GetValue <Map>(); var terrainDef = value.terrainGrid.TerrainAt(c); if (terrainDef is SpecialTerrain) { value.GetComponent <SpecialTerrainList>().Notify_RemovedTerrainAt(c); } }
private static void Prefix(IntVec3 c, TerrainGrid __instance) { bool flag = __instance.TerrainAt(c) is SpecialTerrain; if (flag) { SpecialTerrainList component = Traverse.Create(__instance).Field("map").GetValue <Map>().GetComponent <SpecialTerrainList>(); component.Notify_RemovedTerrainAt(c); } }
public override void Render(TerrainGrid grid) { for (int ii=0; ii<grid.Size.x; ii++) { for (int jj=0; jj<grid.Size.y; jj++) { TerrainType type = grid[ii,jj]; switch (type) { case TerrainTypes.Beach: SystemConsole.BackgroundColor = ConsoleColor.Green; SystemConsole.Write(" "); break; case TerrainTypes.Tree: SystemConsole.ForegroundColor = ConsoleColor.Black; SystemConsole.BackgroundColor = ConsoleColor.Green; SystemConsole.Write("TT"); break; case TerrainTypes.Water: SystemConsole.BackgroundColor = ConsoleColor.Blue; SystemConsole.Write(" "); break; case TerrainTypes.Grass: SystemConsole.BackgroundColor = ConsoleColor.Green; SystemConsole.Write(" "); break; case TerrainTypes.Desert: SystemConsole.BackgroundColor = ConsoleColor.Yellow; SystemConsole.Write(" "); break; case TerrainTypes.Mountain: SystemConsole.ForegroundColor = ConsoleColor.Black; SystemConsole.BackgroundColor = ConsoleColor.Gray; SystemConsole.Write("/\\"); break; case TerrainTypes.Path: SystemConsole.BackgroundColor = ConsoleColor.DarkGray; SystemConsole.Write(" "); break; } } SystemConsole.ResetColor(); SystemConsole.Write("\n"); } SystemConsole.ResetColor(); }
private void AddLandTiles(ref TerrainGrid terrain, List<Vector> landTiles, FreqDict freqs, Random rand) { var heightGrid = _topographyGenerator.Generate(terrain.Size, rand); heightGrid = _filters.OpenClose(heightGrid); landTiles.Sort((lhs, rhs) => (heightGrid[lhs] - heightGrid[rhs])); int numTiles = terrain.Size.x * terrain.Size.y; foreach (var terrainType in TerrainTypes.Land) { int numTerrainTiles = (int)(freqs[terrainType] * numTiles); var tiles = landTiles.Take(numTerrainTiles); foreach(var point in tiles) terrain[point] = terrainType; landTiles.RemoveRange(0, numTerrainTiles); } }