private void StartSpray() { SnowUtility.AddSnowRadial(this.OccupiedRect().RandomCell, Map, 4, -0.06f); spraySustainer = SoundStarter.TrySpawnSustainer(SoundDefOf.GeyserSpray, new TargetInfo(Position, Map)); spraySustainerStartTick = Find.TickManager.TicksGame; }
protected override void Impact(Thing hitThing) { SnowUtility.AddSnowRadial(Position, Map, 2f, 1f); MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Smoke, null); moteThrown.Scale = Rand.Range(1.5f, 2.5f) * 2; moteThrown.rotationRate = Rand.Range(-30f, 30f); moteThrown.exactPosition = Position.ToVector3(); moteThrown.SetVelocity((float)Rand.Range(30, 40), Rand.Range(0.5f, 0.7f)); GenSpawn.Spawn(moteThrown, Position, Map, WipeMode.Vanish); base.Impact(hitThing); }
public override void CompTick() { base.CompTick(); if (parent.IsHashIntervalTick(60)) { if (Temperature > props.heatSuckMinTemperature) { GenTemperature.PushHeat(parent.Position, parent.MapHeld, -props.coldPerSecond); } SnowUtility.AddSnowRadial(parent.Position, parent.Map, props.snowRadius, props.snowDepth); } }
private void StartSpray() { SnowUtility.AddSnowRadial(this.OccupiedRect().RandomCell, base.Map, 4f, -0.06f); this.spraySustainer = SoundDefOf.GeyserSpray.TrySpawnSustainer(new TargetInfo(base.Position, base.Map, false)); this.spraySustainerStartTick = Find.TickManager.TicksGame; int Count = 0; foreach (Thing thing in GenRadial.RadialDistinctThingsAround(this.Position, this.Map, 10, true)) { if (thing.def.defName == "AB_TarPuddle") { Count++; } } if (Count < 15) { for (int iteration = 0; iteration < 3; iteration++) { IntVec3 intVec; if (!CellFinder.TryRandomClosewalkCellNear(this.Position, this.Map, 7, out intVec)) { break; } Plant plant = intVec.GetPlant(this.Map); if (plant != null && plant.def.defName != "AB_TarPuddle") { plant.Destroy(DestroyMode.Vanish); Thing plantToSpawn = GenSpawn.Spawn(ThingDef.Named("AB_TarPuddle"), intVec, this.Map, WipeMode.Vanish); } else if (plant == null) { Thing plantToSpawn = GenSpawn.Spawn(ThingDef.Named("AB_TarPuddle"), intVec, this.Map, WipeMode.Vanish); } } } }
public int CalculatedCostAt(IntVec3 c, bool perceivedStatic, IntVec3 prevCell) { bool flag = false; TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(c); if (terrainDef == null || terrainDef.passability == Traversability.Impassable) { return(10000); } int num = terrainDef.pathCost; List <Thing> list = this.map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.passability == Traversability.Impassable) { return(10000); } if (!PathGrid.IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !this.ContainsPathCostIgnoreRepeater(prevCell)) { int pathCost = thing.def.pathCost; if (pathCost > num) { num = pathCost; } } if (thing is Building_Door && prevCell.IsValid) { Building edifice = prevCell.GetEdifice(this.map); if (edifice != null && edifice is Building_Door) { flag = true; } } } int num2 = SnowUtility.MovementTicksAddOn(this.map.snowGrid.GetCategory(c)); if (num2 > num) { num = num2; } if (flag) { num += 45; } if (perceivedStatic) { for (int j = 0; j < 9; j++) { IntVec3 b = GenAdj.AdjacentCellsAndInside[j]; IntVec3 c2 = c + b; if (c2.InBounds(this.map)) { Fire fire = null; list = this.map.thingGrid.ThingsListAtFast(c2); for (int k = 0; k < list.Count; k++) { fire = (list[k] as Fire); if (fire != null) { break; } } if (fire != null && fire.parent == null) { if (b.x == 0 && b.z == 0) { num += 1000; } else { num += 150; } } } } } return(num); }
private void StartSpray() { SnowUtility.AddSnowRadial(this.OccupiedRect().RandomCell, base.Map, 4f, -0.06f); this.spraySustainer = SoundDefOf.GeyserSpray.TrySpawnSustainer(new TargetInfo(base.Position, base.Map, false)); this.spraySustainerStartTick = Find.TickManager.TicksGame; }
// Modified PathGrid.CalculatedCostAt() public static int PathGrid_CalculatedCostAt(Pawn Pawn, IntVec3 c) { IntVec3 prevCell = Pawn.Position; // Modified beahaviour: // - Apply CountersIcePenalty and CountersSnowPenalty stats // - When snow it's medium or thicker, terrain does not apply anymore. TerrainDef terrainDef = Pawn.Map.terrainGrid.TerrainAt(c); if (terrainDef == null || terrainDef.passability == Traversability.Impassable) { return(10000); } // Get terrain path cost int pcTerrain = terrainDef.pathCost; if (terrainDef == TerrainDefOf.Ice) { // Apply counter ice penalty pcTerrain = (int)Math.Ceiling((double)((float)pcTerrain * (1f - Pawn.GetStatValue(StatDef.Named("CountersIcePenalty"), true)))); } // Get snow path cost int pcSnow = SnowUtility.MovementTicksAddOn(Pawn.Map.snowGrid.GetCategory(c)); // Apply counter snow penalty pcSnow = (int)Math.Ceiling((double)((float)pcSnow * (1f - Pawn.GetStatValue(StatDef.Named("CountersSnowPenalty"), true)))); int pc = 0; if (Pawn.Map.snowGrid.GetCategory(c) >= SnowCategory.Medium) { // Snow is thick, we don't consider terrain path cost pc = pcSnow; } else { // Snow is thin, we apply the highest path cost pc = pcTerrain > pcSnow ? pcTerrain : pcSnow; } bool flagDoor = false; List <Thing> list = Pawn.Map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.passability == Traversability.Impassable) { return(10000); } if (!PathGrid_IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !PathGrid_ContainsPathCostIgnoreRepeater(Pawn.Map, prevCell)) { int pcThing = thing.def.pathCost; if (pcThing > pc) { pc = pcThing; } } if (thing is Building_Door && prevCell.IsValid) { Building edifice = prevCell.GetEdifice(Pawn.Map); if (edifice != null && edifice is Building_Door) { flagDoor = true; } } } if (flagDoor) { pc += 45; } return(pc); }
public static bool DoComplexCalcs(Fire __instance) { bool flag = false; //flammableList.Clear(); List <Thing> flammableList = new List <Thing>(); flammabilityMax(__instance) = 0.0f; if (null != __instance.Map) { if (!__instance.Position.GetTerrain(__instance.Map).extinguishesFire) { if (__instance.parent == null) { if (__instance.Position.TerrainFlammableNow(__instance.Map)) { flammabilityMax(__instance) = __instance.Position.GetTerrain(__instance.Map).GetStatValueAbstract(StatDefOf.Flammability, (ThingDef)null); } List <Thing> thingList = __instance.Map.thingGrid.ThingsListAt(__instance.Position); for (int index = 0; index < thingList.Count; ++index) { Thing thing = thingList[index]; if (thing is Building_Door) { flag = true; } float statValue = thing.GetStatValue(StatDefOf.Flammability, true); if ((double)statValue >= 0.00999999977648258) { flammableList.Add(thingList[index]); if ((double)statValue > (double)flammabilityMax(__instance)) { flammabilityMax(__instance) = statValue; } if (__instance.parent == null && (double)__instance.fireSize > 0.400000005960464 && (thingList[index].def.category == ThingCategory.Pawn && Rand.Chance(FireUtility.ChanceToAttachFireCumulative(thingList[index], 150f)))) { thingList[index].TryAttachFire(__instance.fireSize * 0.2f); } } } } else { flammableList.Add(__instance.parent); flammabilityMax(__instance) = __instance.parent.GetStatValue(StatDefOf.Flammability, true); } } if ((double)flammabilityMax(__instance) < 0.00999999977648258) { __instance.Destroy(DestroyMode.Vanish); } else { Thing targ = __instance.parent == null ? (flammableList.Count <= 0 ? (Thing)null : flammableList[Rand.Range(0, flammableList.Count)]) : __instance.parent; if (targ != null && ((double)__instance.fireSize >= 0.400000005960464 || targ == __instance.parent || targ.def.category != ThingCategory.Pawn)) { DoFireDamage(__instance, targ); } if (!__instance.Spawned) { return(false); } float energy = __instance.fireSize * 160f; if (flag) { energy *= 0.15f; } GenTemperature.PushHeat(__instance.Position, __instance.Map, energy); if ((double)Rand.Value < 0.400000005960464) { SnowUtility.AddSnowRadial(__instance.Position, __instance.Map, __instance.fireSize * 3f, (float)-((double)__instance.fireSize * 0.100000001490116)); } __instance.fireSize += (float)(0.000549999997019768 * (double)flammabilityMax(__instance) * 150.0); if ((double)__instance.fireSize > 1.75) { __instance.fireSize = 1.75f; } if ((double)__instance.Map.weatherManager.RainRate <= 0.00999999977648258 || !VulnerableToRain(__instance) || (double)Rand.Value >= 6.0) { return(false); } //__instance.TakeDamage(new DamageInfo(DamageDefOf.Extinguish, 10f, 0.0f, -1f, (Thing)null, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null)); DamageInfo daminfo = new DamageInfo(DamageDefOf.Extinguish, 10f, 0.0f, -1f, (Thing)null, (BodyPartRecord)null, (ThingDef)null, DamageInfo.SourceCategory.ThingOrUnknown, (Thing)null); DamageWorker.DamageResult dresult = new DamageWorker.DamageResult(); Thing_Patch.TakeDamage(__instance, ref dresult, daminfo); } } return(false); }
public static bool CalculatedCostAt(PathGrid __instance, ref int __result, IntVec3 c, bool perceivedStatic, IntVec3 prevCell) { int num = 0; bool flag = false; TerrainDef terrainDef = map(__instance).terrainGrid.TerrainAt(c); if (terrainDef == null || terrainDef.passability == Traversability.Impassable) { __result = 10000; return(false); } num = terrainDef.pathCost; List <Thing> list = map(__instance).thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing; try { thing = list[i]; } catch (ArgumentOutOfRangeException) { break; } if (thing != null) { if (thing.def.passability == Traversability.Impassable) { __result = 10000; return(false); } if (!IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !ContainsPathCostIgnoreRepeater2(__instance, prevCell)) { int pathCost = thing.def.pathCost; if (pathCost > num) { num = pathCost; } } if (thing is Building_Door && prevCell.IsValid) { Building edifice = prevCell.GetEdifice(map(__instance)); if (edifice != null && edifice is Building_Door) { flag = true; } } } } int num2 = SnowUtility.MovementTicksAddOn(map(__instance).snowGrid.GetCategory(c)); if (num2 > num) { num = num2; } if (flag) { num += 45; } if (perceivedStatic) { for (int j = 0; j < 9; j++) { IntVec3 b = GenAdj.AdjacentCellsAndInside[j]; IntVec3 c2 = c + b; if (!c2.InBounds(map(__instance))) { continue; } Fire fire = null; list = map(__instance).thingGrid.ThingsListAtFast(c2); for (int k = 0; k < list.Count; k++) { try { fire = (list[k] as Fire); } catch (ArgumentOutOfRangeException) { break; } if (fire != null) { break; } } if (fire != null && fire.parent == null) { num = ((b.x != 0 || b.z != 0) ? (num + 150) : (num + 1000)); } } } __result = num; return(false); }
private void DoComplexCalcs() { bool flag = false; flammableList.Clear(); flammabilityMax = 0f; if (!base.Position.GetTerrain(base.Map).extinguishesFire) { if (parent == null) { if (base.Position.TerrainFlammableNow(base.Map)) { flammabilityMax = base.Position.GetTerrain(base.Map).GetStatValueAbstract(StatDefOf.Flammability); } List <Thing> list = base.Map.thingGrid.ThingsListAt(base.Position); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing is Building_Door) { flag = true; } float statValue = thing.GetStatValue(StatDefOf.Flammability); if (!(statValue < 0.01f)) { flammableList.Add(list[i]); if (statValue > flammabilityMax) { flammabilityMax = statValue; } if (parent == null && fireSize > 0.4f && list[i].def.category == ThingCategory.Pawn) { list[i].TryAttachFire(fireSize * 0.2f); } } } } else { flammableList.Add(parent); flammabilityMax = parent.GetStatValue(StatDefOf.Flammability); } } if (flammabilityMax < 0.01f) { Destroy(); } else { Thing thing2 = (parent != null) ? parent : ((flammableList.Count <= 0) ? null : flammableList.RandomElement()); if (thing2 != null && (!(fireSize < 0.4f) || thing2 == parent || thing2.def.category != ThingCategory.Pawn)) { DoFireDamage(thing2); } if (base.Spawned) { float num = fireSize * 160f; if (flag) { num *= 0.15f; } GenTemperature.PushHeat(base.Position, base.Map, num); if (Rand.Value < 0.4f) { float radius = fireSize * 3f; SnowUtility.AddSnowRadial(base.Position, base.Map, radius, 0f - fireSize * 0.1f); } fireSize += 0.00055f * flammabilityMax * 150f; if (fireSize > 1.75f) { fireSize = 1.75f; } if (base.Map.weatherManager.RainRate > 0.01f && VulnerableToRain() && Rand.Value < 6f) { TakeDamage(new DamageInfo(DamageDefOf.Extinguish, 10f)); } } } }
private void DoComplexCalcs() { bool flag = false; Fire.flammableList.Clear(); this.flammabilityMax = 0f; if (!base.Position.GetTerrain(base.Map).extinguishesFire) { if (base.parent == null) { if (base.Position.TerrainFlammableNow(base.Map)) { this.flammabilityMax = base.Position.GetTerrain(base.Map).GetStatValueAbstract(StatDefOf.Flammability, null); } List <Thing> list = base.Map.thingGrid.ThingsListAt(base.Position); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing is Building_Door) { flag = true; } float statValue = thing.GetStatValue(StatDefOf.Flammability, true); if (!(statValue < 0.0099999997764825821)) { Fire.flammableList.Add(list[i]); if (statValue > this.flammabilityMax) { this.flammabilityMax = statValue; } if (base.parent == null && this.fireSize > 0.40000000596046448 && list[i].def.category == ThingCategory.Pawn) { list[i].TryAttachFire((float)(this.fireSize * 0.20000000298023224)); } } } } else { Fire.flammableList.Add(base.parent); this.flammabilityMax = base.parent.GetStatValue(StatDefOf.Flammability, true); } } if (this.flammabilityMax < 0.0099999997764825821) { this.Destroy(DestroyMode.Vanish); } else { Thing thing2 = (base.parent == null) ? ((Fire.flammableList.Count <= 0) ? null : Fire.flammableList.RandomElement()) : base.parent; if (thing2 != null && (!(this.fireSize < 0.40000000596046448) || thing2 == base.parent || thing2.def.category != ThingCategory.Pawn)) { this.DoFireDamage(thing2); } if (base.Spawned) { float num = (float)(this.fireSize * 160.0); if (flag) { num = (float)(num * 0.15000000596046448); } GenTemperature.PushHeat(base.Position, base.Map, num); if (Rand.Value < 0.40000000596046448) { float radius = (float)(this.fireSize * 3.0); SnowUtility.AddSnowRadial(base.Position, base.Map, radius, (float)(0.0 - this.fireSize * 0.10000000149011612)); } this.fireSize += (float)(0.00054999999701976776 * this.flammabilityMax * 150.0); if (this.fireSize > 1.75) { this.fireSize = 1.75f; } if (base.Map.weatherManager.RainRate > 0.0099999997764825821 && this.VulnerableToRain() && Rand.Value < 6.0) { base.TakeDamage(new DamageInfo(DamageDefOf.Extinguish, 10, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown)); } } } }
private void DoComplexCalcs() { bool cellContainsDoor = false; Profiler.BeginSample("Determine flammability"); //Determine list of flammables in my cell flammableList.Clear(); flammabilityMax = 0; if (Position.GetTerrain(Map).extinguishesFire) { // immediately extinguish; we just leave flammabilityMax at 0 } else if (parent == null) { if (Position.TerrainFlammableNow(Map)) { flammabilityMax = Position.GetTerrain(Map).GetStatValueAbstract(StatDefOf.Flammability); } var cellThings = Map.thingGrid.ThingsListAt(Position); for (int i = 0; i < cellThings.Count; i++) { var ct = cellThings[i]; if (ct is Building_Door) { cellContainsDoor = true; } var thingFlam = ct.GetStatValue(StatDefOf.Flammability); if (thingFlam < 0.01f) { continue; } //Record its flammability flammableList.Add(cellThings[i]); if (thingFlam > flammabilityMax) { flammabilityMax = thingFlam; } //If I'm a static fire and it's a pawn and I'm big, ignite it if (parent == null && fireSize > MinSizeForIgniteMovables && cellThings[i].def.category == ThingCategory.Pawn) { cellThings[i].TryAttachFire(fireSize * 0.2f); } } } else { //Consider only my parent flammableList.Add(parent); flammabilityMax = parent.GetStatValue(StatDefOf.Flammability); } Profiler.EndSample(); //Determine flammability //Destroy me if I have nothing to burn if (flammabilityMax < 0.01f) { Destroy(); return; } Profiler.BeginSample("Do damage"); { //Choose what I'm going to damage Thing damagee; if (parent != null) { damagee = parent; //Damage parent } else if (flammableList.Count > 0) { damagee = flammableList.RandomElement(); //Damage random flammable thing in cell } else { damagee = null; } //Damage whatever we're supposed to damage if (damagee != null) { //We don't damage the target if it's not our parent, it would attach a fire, and we're too small //This is to avoid tiny fires igniting passing pawns if (!(fireSize < MinSizeForIgniteMovables && damagee != parent && damagee.def.category == ThingCategory.Pawn)) { DoFireDamage(damagee); } } } Profiler.EndSample(); //Do damage //If still spawned (after doing damage)... if (Spawned) { Profiler.BeginSample("Room heat"); //Push some heat float fireEnergy = fireSize * HeatPerFireSizePerInterval; //Hack to reduce impact on doors, otherwise they hit insane temperatures fast if (cellContainsDoor) { fireEnergy *= HeatFactorWhenDoorPresent; } GenTemperature.PushHeat(Position, Map, fireEnergy); Profiler.EndSample(); //Room heat Profiler.BeginSample("Snow clear"); if (Rand.Value < 0.4f) { //Clear some snow around the fire float snowClearRadius = fireSize * SnowClearRadiusPerFireSize; SnowUtility.AddSnowRadial(Position, Map, snowClearRadius, -(fireSize * SnowClearDepthFactor)); } Profiler.EndSample(); //Snow clear Profiler.BeginSample("Grow/extinguish"); //Try to grow the fire fireSize += FireBaseGrowthPerTick * flammabilityMax * ComplexCalcsInterval; if (fireSize > MaxFireSize) { fireSize = MaxFireSize; } //Extinguish from sky (rain etc) if (Map.weatherManager.RainRate > 0.01f) { if (VulnerableToRain()) { if (Rand.Value < BaseSkyExtinguishChance * ComplexCalcsInterval) { TakeDamage(new DamageInfo(DamageDefOf.Extinguish, BaseSkyExtinguishDamage)); } } } Profiler.EndSample(); //Grow/extinguish } }
public static bool MouseoverReadoutOnGUI(MouseoverReadout __instance) { IntVec3 c = UI.MouseCell(); if (!c.InBounds(Find.CurrentMap) || Event.current.type != EventType.Repaint || Find.MainTabsRoot.OpenTab != null) { return(false); } if (Find.CurrentMap.GetComponent <MapComponent_FertilityMods>().Get is MapComponent_FertilityMods fert && fert.ActiveCells.Contains(c)) { //Original Variables Vector2 BotLeft = new Vector2(15f, 65f); GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f)); Text.Font = GameFont.Small; GUI.color = new Color(1f, 1f, 1f, 0.8f); float num = 0f; Rect rect; if (c.Fogged(Find.CurrentMap)) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); Widgets.Label(rect, "Undiscovered".Translate()); GUI.color = Color.white; return(false); } rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); int num2 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f); string[] glowStrings = Traverse.Create(__instance).Field("glowStrings").GetValue <string[]>(); Widgets.Label(rect, glowStrings[num2]); num += 19f; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); TerrainDef terrain = c.GetTerrain(Find.CurrentMap); //string SpeedPercentString = Traverse.Create(__instance).Method("SpeedPercentString", (float)terrain.pathCost).GetValue<string>(); //TerrainDef cachedTerrain = Traverse.Create(__instance).Field("cachedTerrain").GetValue<TerrainDef>(); string cachedTerrainString = Traverse.Create(__instance).Field("cachedTerrainString").GetValue <string>(); //if (terrain != cachedTerrain) //{ float fertNum = Find.CurrentMap.fertilityGrid.FertilityAt(c); string str = ((double)fertNum <= 0.0001) ? string.Empty : (" " + "FertShort".Translate() + " " + fertNum.ToStringPercent()); cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(new object[] { SpeedPercentString((float)terrain.pathCost) }) + str + ")")); //cachedTerrain = terrain; //} Widgets.Label(rect, cachedTerrainString); num += 19f; Zone zone = c.GetZone(Find.CurrentMap); if (zone != null) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label = zone.label; Widgets.Label(rect, label); num += 19f; } float depth = Find.CurrentMap.snowGrid.GetDepth(c); if (depth > 0.03f) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth); string label2 = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[] { SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory)) }) + ")"; Widgets.Label(rect, label2); num += 19f; } List <Thing> thingList = c.GetThingList(Find.CurrentMap); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string labelMouseover = thing.LabelMouseover; Widgets.Label(rect, labelMouseover); num += 19f; } } RoofDef roof = c.GetRoof(Find.CurrentMap); if (roof != null) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); Widgets.Label(rect, roof.LabelCap); num += 19f; } GUI.color = Color.white; return(false); } return(true); }
public static int TerrainCalculatedCostAt(this PathGrid grid, Map map, Pawn pawn, IntVec3 c, bool perceivedStatic, IntVec3 prevCell) { int num; bool flag = false; TerrainDef terrainDef = map.terrainGrid.TerrainAt(c); if (terrainDef == null || terrainDef.passability == Traversability.Impassable) { return(10000); } // Replace the pathCost with a terrain aware value based on the best movement option for a pawn //num = terrainDef.pathCost; num = pawn.TerrainMoveCost(terrainDef); List <Thing> list = map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.passability == Traversability.Impassable) { return(10000); } if (!(bool)IsPathCostIgnoreRepeaterInfo.Invoke(null, new object[] { thing.def }) || !prevCell.IsValid || !(bool)ContainsPathCostIgnoreRepeaterInfo.Invoke(grid, new object[] { prevCell })) { int pathCost = thing.def.pathCost; if (pathCost > num) { num = pathCost; } } if (thing is Building_Door && prevCell.IsValid) { Building edifice = prevCell.GetEdifice(map); if (edifice != null && edifice is Building_Door) { flag = true; } } } int num2 = SnowUtility.MovementTicksAddOn(map.snowGrid.GetCategory(c)); if (num2 > num) { num = num2; } if (flag) { num += 45; } if (perceivedStatic) { for (int j = 0; j < 9; j++) { IntVec3 b = GenAdj.AdjacentCellsAndInside[j]; IntVec3 c2 = c + b; if (!c2.InBounds(map)) { continue; } Fire fire = null; list = map.thingGrid.ThingsListAtFast(c2); for (int k = 0; k < list.Count; k++) { fire = (list[k] as Fire); if (fire != null) { break; } } if (fire != null && fire.parent == null) { num = ((b.x != 0 || b.z != 0) ? (num + 150) : (num + 1000)); } } } return(num); }
private void DoComplexCalcs() { bool flag = false; Profiler.BeginSample("Determine flammability"); Fire.flammableList.Clear(); this.flammabilityMax = 0f; if (!base.Position.GetTerrain(base.Map).extinguishesFire) { if (this.parent == null) { if (base.Position.TerrainFlammableNow(base.Map)) { this.flammabilityMax = base.Position.GetTerrain(base.Map).GetStatValueAbstract(StatDefOf.Flammability, null); } List <Thing> list = base.Map.thingGrid.ThingsListAt(base.Position); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing is Building_Door) { flag = true; } float statValue = thing.GetStatValue(StatDefOf.Flammability, true); if (statValue >= 0.01f) { Fire.flammableList.Add(list[i]); if (statValue > this.flammabilityMax) { this.flammabilityMax = statValue; } if (this.parent == null && this.fireSize > 0.4f && list[i].def.category == ThingCategory.Pawn) { list[i].TryAttachFire(this.fireSize * 0.2f); } } } } else { Fire.flammableList.Add(this.parent); this.flammabilityMax = this.parent.GetStatValue(StatDefOf.Flammability, true); } } Profiler.EndSample(); if (this.flammabilityMax < 0.01f) { this.Destroy(DestroyMode.Vanish); } else { Profiler.BeginSample("Do damage"); Thing thing2; if (this.parent != null) { thing2 = this.parent; } else if (Fire.flammableList.Count > 0) { thing2 = Fire.flammableList.RandomElement <Thing>(); } else { thing2 = null; } if (thing2 != null) { if (this.fireSize >= 0.4f || thing2 == this.parent || thing2.def.category != ThingCategory.Pawn) { this.DoFireDamage(thing2); } } Profiler.EndSample(); if (base.Spawned) { Profiler.BeginSample("Room heat"); float num = this.fireSize * 160f; if (flag) { num *= 0.15f; } GenTemperature.PushHeat(base.Position, base.Map, num); Profiler.EndSample(); Profiler.BeginSample("Snow clear"); if (Rand.Value < 0.4f) { float radius = this.fireSize * 3f; SnowUtility.AddSnowRadial(base.Position, base.Map, radius, -(this.fireSize * 0.1f)); } Profiler.EndSample(); Profiler.BeginSample("Grow/extinguish"); this.fireSize += 0.00055f * this.flammabilityMax * 150f; if (this.fireSize > 1.75f) { this.fireSize = 1.75f; } if (base.Map.weatherManager.RainRate > 0.01f) { if (this.VulnerableToRain()) { if (Rand.Value < 6f) { base.TakeDamage(new DamageInfo(DamageDefOf.Extinguish, 10f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); } } } Profiler.EndSample(); } } }
public void MouseoverReadoutOnGUI() { if (Find.MainTabsRoot.OpenTab != null) { return; } GenUI.DrawTextWinterShadow(new Rect(256f, (float)(Screen.height - 256), -256f, 256f)); Text.Font = GameFont.Small; GUI.color = new Color(1f, 1f, 1f, 0.8f); IntVec3 c = Gen.MouseCell(); if (!c.InBounds()) { return; } float num = 0f; Rect rect; if (c.Fogged()) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, "Undiscovered".Translate()); GUI.color = Color.white; return; } rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, Find.GlowGrid.PsychGlowAt(c).GetLabel() + " (" + Find.GlowGrid.GameGlowAt(c).ToStringPercent() + ")"); num += 19f; rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); TerrainDef terrain = c.GetTerrain(); if (terrain != this.cachedTerrain) { this.cachedTerrainString = terrain.LabelCap + ((terrain.passability != Traversability.Impassable) ? (" (" + "WalkSpeed".Translate(new object[] { this.SpeedPercentString((float)terrain.pathCost) }) + ")") : null); this.cachedTerrain = terrain; } Widgets.Label(rect, this.cachedTerrainString); num += 19f; Zone zone = c.GetZone(); if (zone != null) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); string label = zone.label; Widgets.Label(rect, label); num += 19f; } float depth = Find.SnowGrid.GetDepth(c); if ((double)depth > 0.03) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth); string label2 = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[] { this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory)) }) + ")"; Widgets.Label(rect, label2); num += 19f; } List <Thing> list = Find.ThingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.category != ThingCategory.Mote) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); string labelMouseover = thing.LabelMouseover; Widgets.Label(rect, labelMouseover); num += 19f; } } RoofDef roof = c.GetRoof(); if (roof != null) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, roof.LabelCap); num += 19f; } GUI.color = Color.white; }
public override void TargetEffects(LocalTargetInfo targetInfo) { base.TargetEffects(targetInfo); SnowUtility.AddSnowRadial(targetInfo.Cell, this.pawn.Map, 3f, 1f); }
protected override bool TryCastShot() { Pawn p = this.CasterPawn; Map map = this.CasterPawn.Map; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); pawns.Clear(); plants.Clear(); GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability); Effecter snapeFreezeED = TorannMagicDefOf.TM_SnapFreezeED.Spawn(); snapeFreezeED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false)); snapeFreezeED.Cleanup(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None); info.pitchFactor = .4f; info.volumeFactor = 1.2f; TorannMagicDefOf.TM_WindLowSD.PlayOneShot(info); TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 3f, 0f, .1f, .4f, 1.2f, -3f); float classBonus = 1f; if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost)) { classBonus = 1.5f; } if (this.currentTarget != null && p != null && comp != null) { this.arcaneDmg = comp.arcaneDmg; this.TargetsAoE.Clear(); this.FindTargets(); float energy = -125000 * this.arcaneDmg * classBonus; GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy); for (int i = 0; i < pawns.Count; i++) { if (!pawns[i].RaceProps.IsMechanoid && pawns[i].RaceProps.body.AllPartsVulnerableToFrostbite.Count > 0) { float distanceModifier = 1f / (pawns[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } int bites = Mathf.RoundToInt(Rand.Range(1f, 5f) * classBonus); for (int j = 0; j < bites; j++) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { TM_Action.DamageEntities(pawns[i], pawns[i].def.race.body.AllPartsVulnerableToFrostbite.RandomElement(), Rand.Range(10, 20) * distanceModifier, 1f, DamageDefOf.Frostbite, p); } if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { HealthUtility.AdjustSeverity(pawns[i], HediffDefOf.Hypothermia, distanceModifier / 5f); } } } } for (int i = 0; i < plants.Count; i++) { float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } if (plants[i].def.plant.IsTree) { if (Rand.Chance(distanceModifier / 2f)) { plants[i].MakeLeafless(Plant.LeaflessCause.Cold); } } else { if (Rand.Chance(distanceModifier)) { plants[i].MakeLeafless(Plant.LeaflessCause.Cold); } } plants[i].Notify_ColorChanged(); } List <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true).ToList(); bool raining = map.weatherManager.RainRate > 0f || map.weatherManager.SnowRate > 0f; for (int i = 0; i < cellList.Count; i++) { cellList[i] = cellList[i].ClampInsideMap(map); SnowUtility.AddSnowRadial(cellList[i], map, 2.4f, Rand.Range(.08f, .13f)); TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, cellList[i].ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360)); } List <IntVec3> windList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range + 1, true).Except(cellList).ToList(); for (int i = 0; i < windList.Count; i++) { windList[i] = windList[i].ClampInsideMap(map); Vector3 angle = TM_Calc.GetVector(windList[i], this.currentTarget.Cell); TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, windList[i].ToVector3Shifted(), map, Rand.Range(1.2f, 2f), .45f, Rand.Range(0f, .25f), .5f, -200, Rand.Range(3, 5), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), Rand.Range(0, 360)); } } this.burstShotsLeft = 0; return(true); }
public int CalculatedCostAt(IntVec3 c, bool perceivedStatic, IntVec3 prevCell) { int num = 0; TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(c); num = ((terrainDef != null && terrainDef.passability != Traversability.Impassable) ? (num + terrainDef.pathCost) : 10000); int num2 = SnowUtility.MovementTicksAddOn(this.map.snowGrid.GetCategory(c)); num += num2; List <Thing> list = this.map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.passability == Traversability.Impassable) { return(10000); } if (!PathGrid.IsPathCostIgnoreRepeater(thing.def) || !prevCell.IsValid || !this.ContainsPathCostIgnoreRepeater(prevCell)) { num += thing.def.pathCost; } if (prevCell.IsValid && thing is Building_Door) { Building edifice = prevCell.GetEdifice(this.map); if (edifice != null && edifice is Building_Door) { num += 45; } } } if (perceivedStatic) { for (int j = 0; j < 9; j++) { IntVec3 b = GenAdj.AdjacentCellsAndInside[j]; IntVec3 c2 = c + b; if (c2.InBounds(this.map)) { Fire fire = null; list = this.map.thingGrid.ThingsListAtFast(c2); int num3 = 0; while (num3 < list.Count) { fire = (list[num3] as Fire); if (fire == null) { num3++; continue; } break; } if (fire != null && fire.parent == null) { num = ((b.x != 0 || b.z != 0) ? (num + 150) : (num + 1000)); } } } } return(num); }