public static bool TerrainFrom_PreFix(Map map, IntVec3 c, ref TerrainDef __result) { //HarmonyInstance.DEBUG = true; //Log.Error("test"); //Log.Error(map.Biome.defName); if (map.Biome.defName == "RWBCavern") { //Log.Error("Called"); TerrainDef terrainDef2; for (int i = 0; i < map.Biome.terrainPatchMakers.Count; i++) { terrainDef2 = map.Biome.terrainPatchMakers[i].TerrainAt(c, map); if (terrainDef2 != null) { //Log.Error("Changed"); //Log.Error(terrainDef2.defName); if (c.GetFirstBuilding(map) != null) { c.GetFirstBuilding(map).Destroy(); } map.roofGrid.SetRoof(c, RoofDefOf.RoofRockThick); __result = terrainDef2; return(false); } } } return(true); }
public static void ClearObstacles(Map whichMap, IntVec3 position, int sizeX, int sizeZ) { for (int x = -sizeX; x < sizeX + 1; x++) { for (int z = -sizeZ; z < sizeZ + 1; z++) { IntVec3 currentPosition = new IntVec3(position.x + x, position.y, position.z + z); if (currentPosition.GetFirstBuilding(whichMap) != null) { currentPosition.GetFirstBuilding(whichMap).DeSpawn(); } } } }
private float GetPillarSpawnScore(IntVec3 c) { Map map = BaseGen.globalSettings.map; if (c.Impassable(map) || c.GetFirstBuilding(map) != null || c.GetFirstItem(map) != null || c.GetFirstPawn(map) != null) { return(0f); } bool flag = true; for (int i = 0; i < 8; i++) { IntVec3 c2 = c + GenAdj.AdjacentCells[i]; if (!c2.InBounds(map) || !c2.Walkable(map)) { flag = false; break; } } if (flag) { return(2f); } return(1f); }
// Attempted to add Extended Storage compatibility. static bool ContainsPartialThingWithSameDef(Thing t, IntVec3 c, Map m) { bool matchingStack = false; bool extendedStorageCell = false; bool matchingExtendedStorage = false; int totalExtendedStack = 0; var thingListDest = c.GetThingList(m); var tLimit = t.def.stackLimit; var storageExtended = c.GetFirstBuilding(m) as Building_Storage; if (storageExtended != null && StatDef.Named(ExtendedStorageStatName) != null) { var capacity = storageExtended.GetStatValue(StatDef.Named(ExtendedStorageStatName)); tLimit = (int)(tLimit * capacity); extendedStorageCell = true; } foreach (Thing q in thingListDest) { if (q == null) { continue; } if (q.def == null) { continue; } if (q == t) { continue; } if (q.def == t.def && !extendedStorageCell) { matchingStack |= q.stackCount + t.stackCount <= tLimit; } if (q.def == t.def && extendedStorageCell) { totalExtendedStack += q.stackCount; } } if (extendedStorageCell && totalExtendedStack < tLimit) { matchingExtendedStorage = true; } if (matchingStack || matchingExtendedStorage) { return(true); } return(false); }
private void CleanGrid(ResolveParams rp, Map map) { CGO.currentGenStep = "Preparing road generation"; int x = rp.rect.Corners.ElementAt(2).x, y = rp.rect.Corners.ElementAt(2).z; for (int i = 0; i < CGO.grid.Length; i++) { for (int j = 0; j < CGO.grid[i].Length; j++) { IntVec3 cell = new IntVec3(x + i, 0, y - j); if (CGO.grid[i][j].Type == CellType.BUILDING) { if (!cell.Roofed(map)) { CGO.currentGenStepMoreInfo = $"Changing {cell} value"; if (cell.GetFirstBuilding(map) is Building b && b != null) { if (b.def.passability != Traversability.Impassable) { CGO.grid[i][j].Type = CellType.BUILDINGPASSABLE; } } else { CGO.grid[i][j].Type = CellType.NONE; } } } } }
public void ShatterTerrain(IntVec3 center, TerrainDef terrainDef) { List <IntVec3> cellList = GenRadial.RadialCellsAround(center, 2f, true).ToList(); Building bldg = null; TerrainDef terrain = null; for (int i = 0; i < cellList.Count; i++) { IntVec3 cell = cellList[i]; bldg = cell.GetFirstBuilding(this.CasterPawn.Map); terrain = cell.GetTerrain(this.CasterPawn.Map); if (cell.InBounds(this.CasterPawn.Map) && bldg == null && terrain == terrainDef) { this.CasterPawn.Map.terrainGrid.SetTerrain(cell, TerrainDef.Named("Gravel")); MoteMaker.ThrowSmoke(cell.ToVector3Shifted(), this.CasterPawn.Map, Rand.Range(.8f, 1.2f)); Vector3 moteDirection = TM_Calc.GetVector(center, cell); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), cell.ToVector3Shifted(), this.CasterPawn.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(2f, 4f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, cell.ToVector3Shifted(), this.CasterPawn.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(2f, 4f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); } bldg = null; } TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_EarthCrack, center.ToVector3Shifted(), this.CasterPawn.Map, Rand.Range(.4f, .7f), .2f, .05f, .5f, 0, 0f, 0f, Rand.Range(0, 360)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_EarthCrack, center.ToVector3Shifted(), this.CasterPawn.Map, Rand.Range(1.6f, 3f), .2f, .05f, .7f, 0, 0f, 0f, Rand.Range(0, 360)); Find.CameraDriver.shaker.DoShake(5f); SoundInfo info = SoundInfo.InMap(new TargetInfo(center, this.CasterPawn.Map, false), MaintenanceType.None); info.pitchFactor = .3f; info.volumeFactor = 1.9f; SoundDef.Named("PunchThroughRoofMetal").PlayOneShot(info); }
public void Notify_TerrainDestroyed(IntVec3 c) { if (!this.CanRemoveTopLayerAt(c)) { return; } TerrainDef terrainDef = this.TerrainAt(c); this.RemoveTopLayer(c, false); if (terrainDef.destroyBuildingsOnDestroyed) { c.GetFirstBuilding(this.map)?.Kill(new DamageInfo?(), (Hediff)null); } if (terrainDef.destroyEffectWater != null && this.TerrainAt(c) != null && this.TerrainAt(c).IsWater) { Effecter effecter = terrainDef.destroyEffectWater.Spawn(); effecter.Trigger(new TargetInfo(c, this.map, false), new TargetInfo(c, this.map, false)); effecter.Cleanup(); } else { if (terrainDef.destroyEffect == null) { return; } Effecter effecter = terrainDef.destroyEffect.Spawn(); effecter.Trigger(new TargetInfo(c, this.map, false), new TargetInfo(c, this.map, false)); effecter.Cleanup(); } }
private float GetPillarSpawnScore(IntVec3 c) { Map map = BaseGen.globalSettings.map; if (!c.Impassable(map) && c.GetFirstBuilding(map) == null && c.GetFirstItem(map) == null && c.GetFirstPawn(map) == null) { bool flag = true; int num = 0; while (num < 8) { IntVec3 c2 = c + GenAdj.AdjacentCells[num]; if (c2.InBounds(map) && c2.Walkable(map)) { num++; continue; } flag = false; break; } if (flag) { return(2f); } return(1f); } return(0f); }
public static bool AnyBuildingBlockingFloorRemoval(IntVec3 c, Map map) { if (!map.terrainGrid.CanRemoveTopLayerAt(c)) { return(false); } Building firstBuilding = c.GetFirstBuilding(map); return(firstBuilding != null && firstBuilding.def.terrainAffordanceNeeded != null && !map.terrainGrid.UnderTerrainAt(c).affordances.Contains(firstBuilding.def.terrainAffordanceNeeded)); }
public static int ApparentPathCost(ThingDef def, IntVec3 c, Map map) { Building b = c.GetFirstBuilding(map); if (b is Building_MassStorageUnit) { return((b.def == def) ? b.def.pathCost : 0); } return(def.pathCost); }
public static bool IsBuilingHere(Map whichMap, IntVec3 location) { if (location.GetFirstBuilding(whichMap) != null) { return(true); } else { return(false); } }
public static bool PreFix(ref Building __result, IntVec3 c, Map map) { var pod = c.GetFirstBuilding(map); if (pod == null || pod.def.defName != "MSRecoveryPod") { return(true); } __result = pod; return(false); }
public static bool Prefix(IntVec3 c, Map map, ref bool __result) { if (checkLevels) { __result = true; return(false); } if (checkLevels && c.GetTerrain(upperMap) == ZLevelsDefOf.ZL_OutsideTerrain) { ZLogger.Message(c + " - Return true: upper - " + c.GetFirstBuilding(upperMap) + " - " + c.GetTerrain(upperMap), true); ZLogger.Message(c + " - Return true: lower - " + c.GetFirstBuilding(lowerMap) + " - " + c.GetTerrain(lowerMap), true); __result = true; return(false); } else if (checkLevels && c != caster.positionInt) { ZLogger.Message(caster + " - " + c + " - Return false: upper - " + c.GetFirstBuilding(upperMap) + " - " + c.GetTerrain(upperMap), true); ZLogger.Message(caster + " - " + c + " - Return false: lower - " + c.GetFirstBuilding(lowerMap) + " - " + c.GetTerrain(lowerMap), true); } else if (checkLevels && c == caster.positionInt) { ZLogger.Message(c + " - Return true: upper - " + c.GetFirstBuilding(upperMap) + " - " + c.GetTerrain(upperMap), true); ZLogger.Message(c + " - Return true: lower - " + c.GetFirstBuilding(lowerMap) + " - " + c.GetTerrain(lowerMap), true); __result = true; return(false); } return(true); }
public static void Prefix(Thing __instance, out Building_MassStorageUnit __state) { __state = null; IntVec3 pos = __instance.Position; if (__instance.def.category == ThingCategory.Item && pos.IsValid && __instance.Map != null) { if (pos.GetFirstBuilding(__instance.Map) is Building_MassStorageUnit b) { __state = b; } } }
public static IPlantToGrowSettable GetIPlantToGrowSettable(IntVec3 c, Map map) { var zone = c.GetZone(map); var building = c.GetFirstBuilding(map); if (building is IPlantToGrowSettable b) { return(b); } if (zone is IPlantToGrowSettable z) { return(z); } return(null); }
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { ResetProgress(); Map mapBefore = Map; // Do not remove ToList - It evaluates the enumerable List <IntVec3> list = GenAdj.CellsAdjacent8Way(this).ToList(); base.DeSpawn(); for (int i = 0; i < list.Count; i++) { IntVec3 cell = list[i]; if (cell.GetFirstBuilding(mapBefore) is Building_SmartAssembler building) { building.Notify_RecipeHolderRemoved(); } } }
public void DamageBuildings(int amt) { IntVec3 c = this.RandomAdjacentCell8Way(); if (c.InBounds(base.Map)) { Building firstBuilding = c.GetFirstBuilding(base.Map); DamageInfo dinfo = new DamageInfo(DamageDef, (float)amt, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null); if (firstBuilding != null) { // if (Find.Selector.SelectedObjects.Contains(firstBuilding)) Log.Message("Damaging firstBuilding " + firstBuilding); firstBuilding.TakeDamage(dinfo); if (Def.damageMote) { FleckMaker.ThrowDustPuff(firstBuilding.Position, base.Map, 0.2f); } } } }
protected void GenRoof(IntVec3 current, ModuleBase roof, Map map) { //Log.Error(roof.GetValue(current).ToString()); if (roof.GetValue(current) > 0.6 && current.GetFirstBuilding(map) == null) { //for (int i = -2; i < 3; i++) //{ // for (int j = -2; j < 3; j++) // { // IntVec3 tvec = new IntVec3(current.x + i, current.y, current.z + j); // if (tvec.GetFirstBuilding(map) != null) // { // return; // } // } //} map.roofGrid.SetRoof(current, null); } }
public static void Postfix(PowerNetManager __instance, ref IntVec3 cell) { if (__instance.map.powerNetGrid.TransmittedPowerNetAt(cell) == null && cell.GetFirstBuilding(__instance.map).TryGetComp <CompSteamAlternator>() != null) { Building_Steam alternator = null; foreach (Thing thing in cell.GetThingList(__instance.map)) { if (thing.TryGetComp <CompSteamAlternator>() != null) { alternator = (Building_Steam)thing; break; } } PowerNet powerNet = new PowerNet(new List <CompPower> { alternator.PowerComp }); __instance.RegisterPowerNet(powerNet); PowerConnectionMaker.ConnectAllConnectorsToTransmitter(powerNet.transmitters[0]); } }
public void Aura(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { if (props.aura != null && props.aura.GetCompProperties <CompProperties_AuraParticle>() != null) { for (int i = pos.x - props.auraSize; i <= pos.x + props.auraSize; i++) { for (int j = pos.z - props.auraSize; j <= pos.z + props.auraSize; j++) { IntVec3 vec = new IntVec3(i, 0, j); if (vec != pos && vec.InBounds(map)) { List <ThingDef> thingDefs = vec.GetThingList(map).Select(x => x.def).ToList(); if (vec.GetFirstBuilding(map) == null && !thingDefs.Contains(props.aura)) { props.aura.GetCompProperties <CompProperties_AuraParticle>().duration = props.duration; GenSpawn.Spawn(props.aura, vec, map); } } } } } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef def = (rp.faction != null && (int)rp.faction.def.techLevel < 4) ? ThingDefOf.TorchLamp : ThingDefOf.StandingLamp; this.FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; if (randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null) { Region region = randomCell.GetRegion(map, RegionType.Set_Passable); if (region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature && !this.AnyGlowerNearby(randomCell) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map)) { Thing thing = GenSpawn.Spawn(def, randomCell, map); if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction, null); } SymbolResolver_OutdoorLighting.nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } } SymbolResolver_OutdoorLighting.nearbyGlowers.Clear(); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef = ((rp.faction != null && (int)rp.faction.def.techLevel < 4) ? ThingDefOf.TorchLamp : ThingDefOf.StandingLamp); FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; if (!randomCell.Standable(map) || randomCell.GetFirstItem(map) != null || randomCell.GetFirstPawn(map) != null || randomCell.GetFirstBuilding(map) != null) { continue; } Region region = randomCell.GetRegion(map); if (region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature && !AnyGlowerNearby(randomCell) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map)) { if (!rp.spawnBridgeIfTerrainCantSupportThing.HasValue || rp.spawnBridgeIfTerrainCantSupportThing.Value) { BaseGenUtility.CheckSpawnBridgeUnder(thingDef, randomCell, Rot4.North); } Thing thing = GenSpawn.Spawn(thingDef, randomCell, map); if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction); } nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } nearbyGlowers.Clear(); }
private void GenerateAura(float explosionRadius, IntVec3 pos, Map map) { CompPropertiesProjectileAura props; if (base.GetComp <CompProjectileAura>() != null) { props = base.GetComp <CompProjectileAura>().Props; } else { return; } if (props.aura != null) { for (int i = (int)(pos.x - explosionRadius); i <= pos.x + explosionRadius; i++) { for (int j = (int)(pos.z - explosionRadius); j <= pos.z + explosionRadius; j++) { IntVec3 temp = new IntVec3(i, 0, j); if ((Math.Abs(pos.x - i) * Math.Abs(pos.x - i) + Math.Abs(pos.z - j) * Math.Abs(pos.z - j) < explosionRadius * explosionRadius) && temp.InBounds(map)) { ThingDef particle = ThingDef.Named(props.aura); List <ThingDef> thingdefs = new List <ThingDef>(); foreach (Thing t in temp.GetThingList(map)) { thingdefs.Add(t.def); } if (particle.GetCompProperties <CompProperties_AuraParticle>() != null && temp.GetFirstBuilding(map) == null && !thingdefs.Contains(ThingDef.Named(props.aura))) { particle.GetCompProperties <CompProperties_AuraParticle>().duration = props.duration; GenSpawn.Spawn(ThingDef.Named(props.aura), temp, map); } } } } } }
public override void Generate(Map map) { if (map.Biome.defName != "RWBCavern") { return; } ModuleBase roof = new Perlin(0.04, 2.0, 0.5, 4, Rand.Int, QualityMode.Medium); MapGenFloatGrid arg_3B_0 = MapGenerator.Elevation; //Log.Error("Called"); foreach (IntVec3 current in map.AllCells) { map.roofGrid.SetRoof(current, RoofDefOf.RoofRockThick); //Thing thing = map.edificeGrid.InnerArray[map.cellIndices.CellToIndex(current)]; if (current.GetFirstBuilding(map) == null) { if (current.GetTerrain(map) == TerrainDefOf.Soil || current.GetTerrain(map) == TerrainDefOf.Gravel) { map.terrainGrid.SetTerrain(current, GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain); } //Log.Error("change?"); } if (isWater(current, map)) { for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { IntVec3 tvec = new IntVec3(current.x + i, current.y, current.z + j); if (tvec.InBounds(map) && !isWater(tvec, map) && tvec.GetTerrain(map).defName != "Mud") { if (tvec.GetFirstBuilding(map) != null) { tvec.GetFirstBuilding(map).Destroy(); } map.terrainGrid.SetTerrain(tvec, TerrainDefOf.Soil); //map.roofGrid.SetRoof(tvec, RoofDefOf.RoofRockThick); } } } } } foreach (IntVec3 current in map.AllCells) { if (current.GetTerrain(map).defName == "SoilRich") { map.terrainGrid.SetTerrain(current, GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain); //map.roofGrid.SetRoof(current, RoofDefOf.RoofRockThick); } if (current.GetTerrain(map) == TerrainDefOf.WaterShallow) { for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { IntVec3 tvec = new IntVec3(current.x + i, current.y, current.z + j); if (tvec.InBounds(map) && tvec.GetTerrain(map) == GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain) { if (tvec.GetFirstBuilding(map) != null) { tvec.GetFirstBuilding(map).Destroy(); } map.terrainGrid.SetTerrain(tvec, TerrainDefOf.Soil); //map.roofGrid.SetRoof(tvec, RoofDefOf.RoofRockThick); } } } } if (current.GetTerrain(map).defName == "Mud") { map.terrainGrid.SetTerrain(current, TerrainDefOf.Soil); } if (current.GetTerrain(map) == TerrainDefOf.Soil) { int count = 0; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { IntVec3 tvec = new IntVec3(current.x + i, current.y, current.z + j); if (tvec.InBounds(map) && (tvec.GetTerrain(map) == TerrainDefOf.WaterMovingDeep || tvec.GetTerrain(map) == TerrainDefOf.WaterMovingShallow)) { count++; } } } if (count > 1) { map.terrainGrid.SetTerrain(current, TerrainDefOf.WaterMovingShallow); } } GenRoof(current, roof, map); if (isStone(current, map) && current.GetFirstBuilding(map) == null) { System.Random rand = new System.Random(); int r2 = rand.Next(0, 1001); //for (int i = 0; i < 100; i++) //{ // r2 = rand.Next(0, 1001); // //r2 = r2 + 0; // //Log.Error(r2.ToString()); //} rand = new System.Random(); r2 = Rand.RangeInclusive(0, 1000); if (r2 < 10) { //Log.Error(r2.ToString()); string str = "RWBStalagmite"; //int r = rand.Next(1, 5); //for (int i = 0; i < 100; i++) //{ // r = Rand.RangeInclusive(1,4); // //Log.Error(r.ToString()); // r = r + 0; //} //if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Sand")) //{ // str = str + "A"; //} //if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Marble")) //{ // str = str + "E"; //} //if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Slate")) //{ // str = str + "D"; //} //if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Granite")) //{ // str = str + "B"; //} //if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Lime")) //{ // str = str + "C"; //} //if (r == 1) //{ // str = str + "A"; //} //if (r == 2) //{ // str = str + "B"; //} //if (r == 3) //{ // str = str + "C"; //} //if (r == 4) //{ // str = str + "D"; //} GenSpawn.Spawn(ThingDef.Named(str), current, map); } } if (current.GetTerrain(map) == RWBTerrainDefOf.RockySoil) { if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Sand")) { map.terrainGrid.SetTerrain(current, RWBTerrainDefOf.SandstoneSoil); } if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Marble")) { map.terrainGrid.SetTerrain(current, RWBTerrainDefOf.MarbleSoil); } if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Slate")) { map.terrainGrid.SetTerrain(current, RWBTerrainDefOf.SlateSoil); } if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Granite")) { map.terrainGrid.SetTerrain(current, RWBTerrainDefOf.GraniteSoil); } if (GenStep_RocksFromGrid.RockDefAt(current).naturalTerrain.defName.Contains("Lime")) { map.terrainGrid.SetTerrain(current, RWBTerrainDefOf.LimestoneSoil); } } } map.regionAndRoomUpdater.Enabled = true; map.regionAndRoomUpdater.RebuildAllRegionsAndRooms(); }
// Token: 0x06000190 RID: 400 RVA: 0x0000F358 File Offset: 0x0000D558 public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef glowPod = RimWorld.ThingDefOf.GlowPod; this.FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; bool flag = randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null; if (flag) { Region region = randomCell.GetRegion(map, RegionType.Set_Passable); bool flag2 = region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature && !this.AnyGlowerNearby(randomCell) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map); if (flag2) { bool flag3 = rp.spawnBridgeIfTerrainCantSupportThing == null || rp.spawnBridgeIfTerrainCantSupportThing.Value; if (flag3) { BaseGenUtility.CheckSpawnBridgeUnder(glowPod, randomCell, Rot4.North); } Thing thing = GenSpawn.Spawn(glowPod, randomCell, map, WipeMode.Vanish); bool flag4 = thing.def.CanHaveFaction && thing.Faction != rp.faction; if (flag4) { thing.SetFaction(rp.faction, null); } SymbolResolver_OutdoorLightingHivebase.nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } } SymbolResolver_OutdoorLightingHivebase.nearbyGlowers.Clear(); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef; if (rp.faction == null || rp.faction.def.techLevel >= TechLevel.Industrial) { thingDef = ThingDefOf.StandingLamp; } else { thingDef = ThingDefOf.TorchLamp; } this.FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; if (randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null) { Region region = randomCell.GetRegion(map, RegionType.Set_Passable); if (region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature) { if (!this.AnyGlowerNearby(randomCell)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map)) { if (rp.spawnBridgeIfTerrainCantSupportThing == null || rp.spawnBridgeIfTerrainCantSupportThing.Value) { BaseGenUtility.CheckSpawnBridgeUnder(thingDef, randomCell, Rot4.North); } Thing thing = GenSpawn.Spawn(thingDef, randomCell, map, WipeMode.Vanish); if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction, null); } SymbolResolver_OutdoorLighting.nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } } } } SymbolResolver_OutdoorLighting.nearbyGlowers.Clear(); }
// Token: 0x0600018B RID: 395 RVA: 0x0000EC70 File Offset: 0x0000CE70 public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; Rand.PushState(); for (int i = 0; i < Rand.RangeInclusive(5, 20); i++) { Faction faction = rp.faction; IntVec3 randomCell = rp.rect.RandomCell; bool flag = randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null; if (flag) { bool flag2 = Rand.RangeInclusive(1, 4) < 3; if (flag2) { ThingDef hivedef = faction.HivedefsFor().RandomElement() ?? RimWorld.ThingDefOf.Hive; Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(hivedef, null), randomCell, map, WipeMode.Vanish); hive.SetFaction(faction, null); foreach (CompSpawner compSpawner in hive.GetComps <CompSpawner>()) { if (compSpawner.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly) { compSpawner.TryDoSpawn(); break; } } } else { ThingDef hivedef = faction.HivedefsFor().RandomElement() ?? RimWorld.ThingDefOf.Hive; Hive hive2 = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(hivedef, null), randomCell, map, WipeMode.Vanish); hive2.SetFaction(faction, null); foreach (CompSpawner compSpawner2 in hive2.GetComps <CompSpawner>()) { if (compSpawner2.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly) { compSpawner2.TryDoSpawn(); break; } } } } } Rand.PopState(); }
public void Aura(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { if (props.aura != null) { for (int i = pos.x - props.auraSize; i <= pos.x + props.auraSize; i++) { for (int j = pos.z - props.auraSize; j <= pos.z + props.auraSize; j++) { IntVec3 temp = new IntVec3(i, 0, j); if (temp != pos && temp.InBounds(map)) { ThingDef particle = ThingDef.Named(props.aura); List <ThingDef> thingdefs = new List <ThingDef>(); foreach (Thing t in temp.GetThingList(map)) { thingdefs.Add(t.def); } if (particle.GetCompProperties <CompProperties_AuraParticle>() != null && temp.GetFirstBuilding(map) == null && !thingdefs.Contains(ThingDef.Named(props.aura))) { particle.GetCompProperties <CompProperties_AuraParticle>().duration = props.duration; GenSpawn.Spawn(ThingDef.Named(props.aura), temp, map); } } } } } }
protected override void Impact(Thing hitThing) { Map map = base.Map; GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact); //base.Impact(hitThing); string msg; ThingDef def = this.def; Pawn victim = hitThing as Pawn; Thing item = hitThing as Thing; IntVec3 arg_pos_1; IntVec3 arg_pos_2; IntVec3 arg_pos_3; Pawn pawn = this.launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_Teleport.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Teleport_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_Teleport.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Teleport_ver"); pwrVal = pwr.level; verVal = ver.level; CellRect cellRect = CellRect.CenteredOn(base.Position, 1); cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; if (pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Wanderer) || (comp.customClass != null && comp.customClass.classMageAbilities.Contains(TorannMagicDefOf.TM_Cantrips))) { int tmpPwrVal = (int)((pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level) / 5); int tmpVerVal = (int)((pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level) / 5); pwrVal = (tmpPwrVal > pwrVal) ? tmpPwrVal : pwrVal; verVal = (tmpVerVal > verVal) ? tmpVerVal : verVal; } if (this.primed != false) { destructTimer = Mathf.RoundToInt((4800 + (pwrVal * 1200) + (pwrVal * 1200)) * comp.arcaneDmg); arg_pos_1 = centerCell; centerCell.x++; arg_pos_2 = centerCell; centerCell.z++; arg_pos_3 = centerCell; centerCell = cellRect.CenterCell; if ((arg_pos_1.IsValid && arg_pos_1.Standable(map)) && (arg_pos_2.IsValid && arg_pos_2.Standable(map)) && (arg_pos_3.IsValid && arg_pos_3.Standable(map))) { AbilityUser.SpawnThings tempPod = new SpawnThings(); IntVec3 shiftPos = centerCell; centerCell.x++; if (pwrVal == 1) { tempPod.def = ThingDef.Named("TM_Teleporter_I"); } else if (pwrVal == 2) { tempPod.def = ThingDef.Named("TM_Teleporter_II"); } else if (pwrVal == 3) { tempPod.def = ThingDef.Named("TM_Teleporter_III"); } else { tempPod.def = ThingDef.Named("TM_Teleporter"); } tempPod.spawnCount = 1; try { this.SingleSpawnLoop(tempPod, shiftPos, map); Building teleporter = shiftPos.GetFirstBuilding(map); int num = teleporter.TryGetComp <CompRefuelable>().GetFuelCountToFullyRefuel(); teleporter.TryGetComp <CompRefuelable>().Refuel(num); } catch { Log.Message("Attempted to create a portal but threw an unknown exception - recovering and ending attempt"); PortalCollapse(shiftPos, map, 3); if (pawn != null) { comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_Teleport); } this.age = this.destructTimer; return; } if (verVal == 1) { tempPod.def = ThingDef.Named("TM_TeleportPod_I"); } else if (verVal == 2) { tempPod.def = ThingDef.Named("TM_TeleportPod_II"); } else if (verVal == 3) { tempPod.def = ThingDef.Named("TM_TeleportPod_III"); } else { tempPod.def = ThingDef.Named("TM_TeleportPod"); } tempPod.spawnCount = 1; shiftPos = centerCell; centerCell.z++; try { this.SingleSpawnLoop(tempPod, shiftPos, map); } catch { Log.Message("Attempted to create a portal but threw an unknown exception - recovering and ending attempt"); PortalCollapse(shiftPos, map, 3); if (pawn != null) { comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_Teleport); } this.age = this.destructTimer; return; } //tempPod.def = ThingDef.Named("Portfuel"); //tempPod.spawnCount = 45 + (pwr.level * 15); //tempPod.factionDef = null; //shiftPos = centerCell; //for (int i = 0; i < tempPod.spawnCount; i++) //{ // try // { // this.SingleSpawnLoop(tempPod, shiftPos, map); // } // catch // { // Log.Message("Attempted to create a portal but threw an unknown exception - recovering and ending attempt"); // PortalCollapse(shiftPos, map, 3); // if (pawn != null) // { // comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_Teleport); // } // this.age = this.destructTimer; // i = tempPod.spawnCount; // return; // } //} msg = "PortalCollapseIn".Translate(((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); this.primed = false; } else { Messages.Message("InvalidPortal".Translate(), MessageTypeDefOf.RejectInput); comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_Teleport)); this.destructTimer = 0; } } //foreach (SpawnThings current in this.localSpawnThings) //{ // string msg = "spawned thing is " + current.def; // Messages.Message(msg, MessageSound.Standard); //} if (this.age < this.destructTimer) { if (this.age == (destructTimer * 0.5)) { msg = "PortalCollapseIn".Translate( ((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); } if (this.age == (destructTimer * 0.75)) { msg = "PortalCollapseIn".Translate( ((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); } if (this.age == (destructTimer * 0.95)) { //msg = "Portal collapses in " + ((destructTimer - this.age) / 60) + " seconds!!"; //Messages.Message(msg, MessageTypeDefOf.ThreatBig); msg = "PortalCollapseIn".Translate( ((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); } } else { //age expired, destroy teleport this.PortalCollapse(centerCell, map, 3); } Destroy(); }
public bool BuildingDesignatorControl() { if (Find.CurrentMap == null || Find.DesignatorManager == null) { return(true); } var Dem = Find.DesignatorManager.SelectedDesignator; if (Dem != null && Dem is Designator_Build) { if (Event.current.type == EventType.MouseDown && Event.current.button == 2) { //Better than UI.mousecell MiddleClickCell = Find.CameraDriver.MapPosition; } //Middle click to select designator if (Event.current.type == EventType.MouseUp && Event.current.button == 2 && MiddleClickCell == Find.CameraDriver.MapPosition) { Thing targetThing = null; IntVec3 UICell = UI.MouseCell(); Map map = Find.CurrentMap; if (map == null) { return(false); } if (!UICell.InBounds(map)) { return(false); } //Search for blueprints if (targetThing == null) { targetThing = UICell.GetFirstThing <Blueprint>(map); } //Search for frames if (targetThing == null) { targetThing = UICell.GetFirstThing <Frame>(map); } //Search for Buildings if (targetThing == null) { targetThing = UICell.GetFirstBuilding(map); } //Can't find things if (targetThing == null) { //SoundDefOf.ClickReject.PlayOneShotOnCamera(); Event.current.Use(); return(false); } //Find designator Designator_Build Desig = null; Desig = BuildCopyCommandUtility.FindAllowedDesignator(targetThing.def); if (Desig == null && (targetThing is Blueprint || targetThing is Frame)) { Desig = BuildCopyCommandUtility.FindAllowedDesignator(targetThing.def.entityDefToBuild); } if ((targetThing.def.BuildableByPlayer || targetThing.def.entityDefToBuild?.BuildableByPlayer == true) && Desig != null) { //Set stuff if (targetThing.Stuff != null) { Desig.SetStuffDef(targetThing.Stuff); } if ((targetThing as Blueprint_Build)?.stuffToUse != null) { Desig.SetStuffDef((targetThing as Blueprint_Build).stuffToUse); } if ((targetThing as Blueprint_Install)?.Stuff != null) { Desig.SetStuffDef((targetThing as Blueprint_Install).Stuff); } if ((targetThing as Frame)?.Stuff != null) { Desig.SetStuffDef((targetThing as Frame).Stuff); } Find.DesignatorManager.Select(Desig); SoundDefOf.Click.PlayOneShotOnCamera(); } else { //SoundDefOf.ClickReject.PlayOneShotOnCamera(); } Event.current.Use(); return(false); } //Cancel drag //First, absorb Right click event, handle it manually if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { Event.current.Use(); } if (IsCancelDragging) { GenUI.DrawMouseAttachment(CancelIcon, string.Empty, 0); } if (Input.GetMouseButton(1)) { if (IsCancelDragging) { //RenderCancelHighlights(); } else { //Start cancel dragging IsCancelDragging = true; DragStart = UI.MouseCell(); SoundDefOf.Click.PlayOneShotOnCamera(null); } } //Right click up else if (Event.current.type == EventType.MouseUp && Event.current.button == 1) { IsCancelDragging = false; selectedThings.Clear(); Event.current.Use(); if (selectedThings.Any()) { selectedThings.Do(delegate(Thing t) { t.Destroy(DestroyMode.Cancel); }); SoundDefOf.Designate_Cancel.PlayOneShotOnCamera(); } else { SoundDefOf.CancelMode.PlayOneShotOnCamera(null); Find.DesignatorManager.Deselect(); return(false); } } //While cancel dragging, left click to abort if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && IsCancelDragging) { selectedThings.Clear(); IsCancelDragging = false; SoundDefOf.CancelMode.PlayOneShotOnCamera(null); Find.DesignatorManager.Deselect(); Event.current.Use(); return(false); } //Drag to place blueprints var BuildDesignator = (Designator_Build)Dem; if (BuildDesignator.DraggableDimensions != 0) { return(true); } if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { PreviousCell = IntVec3.Invalid; ClickedFlag = true; Event.current.Use(); } if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { PreviousCell = IntVec3.Invalid; ClickedFlag = false; Event.current.Use(); } if (Input.GetMouseButton(0) && !Mouse.IsInputBlockedNow && PreviousCell != UI.MouseCell() && ClickedFlag) { var acceptanceReport = BuildDesignator.CanDesignateCell(UI.MouseCell()); if (DebugSettings.godMode && acceptanceReport.Accepted) //Handle god mode { Traverse t = Traverse.Create(BuildDesignator); BuildableDef entDef = t.Field("entDef").GetValue <BuildableDef>(); Rot4 rot = t.Field("placingRot").GetValue <Rot4>(); CellRect cellRect = GenAdj.OccupiedRect(UI.MouseCell(), rot, entDef.Size); foreach (IntVec3 c in cellRect) { var thinglist = c.GetThingList(Find.CurrentMap); for (int i = 0; i < thinglist.Count; i++) { var thing3 = thinglist[i]; if (!GenConstruct.CanPlaceBlueprintOver(entDef, thing3.def)) { acceptanceReport = new AcceptanceReport("SpaceAlreadyOccupied_DevFail"); } } } } if (acceptanceReport.Accepted) { BuildDesignator.DesignateSingleCell(UI.MouseCell()); BuildDesignator.Finalize(true); } else { //If this is first cell clicked if (PreviousCell == IntVec3.Invalid) { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.SilentInput, false); BuildDesignator.Finalize(false); } } PreviousCell = UI.MouseCell(); //Event.current.Use(); } return(false); } else //This is not Building designator { IsCancelDragging = false; return(true); } }