public static bool SetRoof(RoofGrid __instance, IntVec3 c, RoofDef def) { Map map = __instance.map; int mcc = map.cellIndices.CellToIndex(c); if (__instance.roofGrid[mcc] != def) { __instance.roofGrid[mcc] = def; map.glowGrid.MarkGlowGridDirty(c); //Comment the 3 following lines and uncomment the 4th to fix the roof notification -Sernior Room room = map.regionGrid.GetValidRegionAt_NoRebuild(c)?.Room; if (room != null) { room.Notify_RoofChanged(); } //map.regionGrid.GetValidRegionAt_NoRebuild(c)?.District.Notify_RoofChanged(); This fixes the roofs notification instead of the 3 previous lines -Sernior if (__instance.drawerInt != null) { __instance.drawerInt.SetDirty(); } map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Roofs); } return(false); }
private void ShipImpact() { // Log.Message("ShipImpact at " + this.Position.ToString() + " with truecenter" + Gen.TrueCenter(this).ToString() + " and ticks: " + this.containingShip.drawTickOffset.ToString()); this.containingShip.shipState = ShipState.Stationary; for (int i = 0; i < 6; i++) { Vector3 loc = base.Position.ToVector3Shifted() + Gen.RandomHorizontalVector(1f); MoteMaker.ThrowDustPuff(loc, base.Map, 1.2f); } MoteMaker.ThrowLightningGlow(base.Position.ToVector3Shifted(), base.Map, 2f); RoofDef roof = this.Position.GetRoof(this.Map); if (roof != null) { if (!roof.soundPunchThrough.NullOrUndefined()) { roof.soundPunchThrough.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); } if (roof.filthLeaving != null) { for (int j = 0; j < 3; j++) { FilthMaker.MakeFilth(base.Position, base.Map, roof.filthLeaving, 1); } } } GenSpawn.Spawn(this.containingShip, base.Position, this.Map, this.containingShip.Rotation); this.containingShip.ShipUnload(false, this.dropPawnsOnTochdown, this.dropItemsOnTouchdown); this.DeSpawn(); }
private static bool CanPhysicallyDropInto(IntVec3 c, Map map, bool canRoofPunch) { bool result; if (!c.Walkable(map)) { result = false; } else { RoofDef roof = c.GetRoof(map); if (roof != null) { if (!canRoofPunch) { return(false); } if (roof.isThickRoof) { return(false); } } result = true; } return(result); }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { AcceptanceReport result; if (!c.InBounds(base.Map)) { result = false; } else if (c.Fogged(base.Map)) { result = false; } else { RoofDef roofDef = base.Map.roofGrid.RoofAt(c); if (roofDef != null && roofDef.isThickRoof) { result = "MessageNothingCanRemoveThickRoofs".Translate(); } else { bool flag = base.Map.areaManager.NoRoof[c]; result = !flag; } } return(result); }
protected bool CanSpawnTornadoAt(IntVec3 c, Map map) { if (c.Fogged(map)) { return(false); } int num = GenRadial.NumCellsInRadius(7f); for (int i = 0; i < num; i++) { IntVec3 c2 = c + GenRadial.RadialPattern[i]; if (c2.InBounds(map)) { if (this.AnyPawnOfPlayerFactionAt(c2, map)) { return(false); } // Added to eliminate spawning inside areas that will immediate despawn RoofDef roofDef = map.roofGrid.RoofAt(c2); if (roofDef != null && roofDef.isThickRoof) { return(false); } } } return(true); }
private static bool IsValidTarget(Building_TurretGun __instance, Thing t) { Building_Turret building_Turret = __instance; Pawn pawn = t as Pawn; if (pawn != null) { if (__instance.AttackVerb.ProjectileFliesOverhead()) { RoofDef roofDef = building_Turret.Map.roofGrid.RoofAt(t.Position); if (roofDef != null && roofDef.isThickRoof) { return(false); } } if (mannableComp == null) { return(!GenAI.MachinesLike(building_Turret.Faction, pawn)); } if (pawn.RaceProps.Animal && pawn.Faction == Faction.OfPlayer) { return(false); } } return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <TargetInfo> list = new List <TargetInfo>(); ThingDef shipPartDef = def.mechClusterBuilding; IntVec3 intVec = FindDropPodLocation(map, (IntVec3 spot) => CanPlaceAt(spot)); if (intVec == IntVec3.Invalid) { return(false); } float points = Mathf.Max(parms.points * 0.9f, 300f); List <Pawn> list2 = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms { groupKind = PawnGroupKindDefOf.Combat, tile = map.Tile, faction = Faction.OfMechanoids, points = points }).ToList(); Thing thing = ThingMaker.MakeThing(shipPartDef); thing.SetFaction(Faction.OfMechanoids); LordMaker.MakeNewLord(Faction.OfMechanoids, new LordJob_SleepThenMechanoidsDefend(new List <Thing> { thing }, Faction.OfMechanoids, 28f, intVec, canAssaultColony: false, isMechCluster: false), map, list2); DropPodUtility.DropThingsNear(intVec, map, list2.Cast <Thing>()); foreach (Pawn item in list2) { item.TryGetComp <CompCanBeDormant>()?.ToSleep(); } list.AddRange(list2.Select((Pawn p) => new TargetInfo(p))); GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map); list.Add(new TargetInfo(intVec, map)); SendStandardLetter(parms, list); return(true); bool CanPlaceAt(IntVec3 loc) { CellRect cellRect = GenAdj.OccupiedRect(loc, Rot4.North, shipPartDef.Size); if (loc.Fogged(map) || !cellRect.InBounds(map)) { return(false); } if (!DropCellFinder.SkyfallerCanLandAt(loc, map, shipPartDef.Size)) { return(false); } foreach (IntVec3 item2 in cellRect) { RoofDef roof = item2.GetRoof(map); if (roof != null && roof.isNatural) { return(false); } } return(GenConstruct.CanBuildOnTerrain(shipPartDef, loc, map, Rot4.North)); } }
public static Bounds GetBoundsFor(IntVec3 cell, RoofDef roof) { if (roof == null) { return(new Bounds()); } float height = CollisionVertical.WallCollisionHeight; if (roof.isNatural) { height *= CollisionVertical.NaturalRoofThicknessMultiplier; } if (roof.isThickRoof) { height *= CollisionVertical.ThickRoofThicknessMultiplier; } height = Mathf.Max(0.1f, height - CollisionVertical.WallCollisionHeight); Vector3 center = cell.ToVector3Shifted(); center.y = CollisionVertical.WallCollisionHeight + height / 2f; return(new Bounds(center, new Vector3(1f, height, 1f))); }
private void Impact() { for (int i = 0; i < 6; i++) { Vector3 loc = base.Position.ToVector3Shifted() + Gen.RandomHorizontalVector(1f); MoteMaker.ThrowDustPuff(loc, 1.2f); } MoteMaker.ThrowLightningGlow(base.Position.ToVector3Shifted(), 2f); Deepstriker deepStriker = (Deepstriker)ThingMaker.MakeThing(tdef.RemainingDef, null); deepStriker.info = this.contents; GenSpawn.Spawn(deepStriker, base.Position, base.Rotation); RoofDef roof = base.Position.GetRoof(); if (roof != null) { if (!roof.soundPunchThrough.NullOrUndefined()) { roof.soundPunchThrough.PlayOneShot(base.Position); } if (roof.filthLeaving != null) { for (int j = 0; j < 3; j++) { FilthMaker.MakeFilth(base.Position, roof.filthLeaving, 1); } } } this.Destroy(DestroyMode.Vanish); }
public static void Postfix(IntVec3 c, RoofDef def) { if (def == null) { DesignatorMoveBase.SetNoRoofFalse(c); } }
public static bool ImpactSomething(Projectile __instance) { if (__instance.def.projectile.flyOverhead) { RoofDef roofDef = __instance.Map.roofGrid.RoofAt(__instance.Position); if (roofDef != null) { if (roofDef.isThickRoof) { ThrowDebugText(__instance, "hit-thick-roof", __instance.Position); __instance.def.projectile.soundHitThickRoof.PlayOneShot((SoundInfo) new TargetInfo(__instance.Position, __instance.Map, false)); __instance.Destroy(DestroyMode.Vanish); return(false); } if (__instance.Position.GetEdifice(__instance.Map) == null || __instance.Position.GetEdifice(__instance.Map).def.Fillage != FillCategory.Full) { RoofCollapserImmediate.DropRoofInCells(__instance.Position, __instance.Map, (List <Thing>)null); } } } if (__instance.usedTarget.HasThing && CanHit(__instance, __instance.usedTarget.Thing)) { if (__instance.usedTarget.Thing is Pawn thing && thing.GetPosture() != PawnPosture.Standing && ((double)(origin(__instance) - destination(__instance)).MagnitudeHorizontalSquared() >= 20.25 && !Rand.Chance(0.2f))) { ThrowDebugText(__instance, "miss-laying", __instance.Position); //Impact.Invoke(__instance, new object[] { (Thing)null }); Impact(__instance, null); } else { Impact(__instance, __instance.usedTarget.Thing); } }
protected virtual void HitRoof() { if (!this.def.skyfaller.hitRoof) { return; } CellRect cr = this.OccupiedRect(); if (cr.Cells.Any((IntVec3 x) => x.Roofed(this.Map))) { RoofDef roof = cr.Cells.First((IntVec3 x) => x.Roofed(this.Map)).GetRoof(base.Map); if (!roof.soundPunchThrough.NullOrUndefined()) { roof.soundPunchThrough.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); } RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(base.Map).Cells.Where(delegate(IntVec3 c) { if (!c.InBounds(this.Map)) { return(false); } if (cr.Contains(c)) { return(true); } if (c.GetFirstPawn(this.Map) != null) { return(false); } Building edifice = c.GetEdifice(this.Map); return(edifice == null || !edifice.def.holdsRoof); }), base.Map, null); } }
public static bool CanPhysicallyDropInto(IntVec3 c, Map map, bool canRoofPunch, bool allowedIndoors = true) { if (!c.Walkable(map)) { return(false); } RoofDef roof = c.GetRoof(map); if (roof != null) { if (!canRoofPunch) { return(false); } if (roof.isThickRoof) { return(false); } } if (!allowedIndoors) { Room room = c.GetRoom(map); if (room != null && !room.PsychologicallyOutdoors) { return(false); } } return(true); }
private bool IsValidTarget(Thing t) { Pawn p = t as Pawn; if (p != null) { if (this.GunCompEq.PrimaryVerb.verbProps.projectileDef.projectile.flyOverhead) { RoofDef roofDef = Find.VisibleMap.roofGrid.RoofAt(t.Position); if (roofDef != null && roofDef.isThickRoof) { return(false); } } if (this.mannableComp == null) { return(!GenAI.MachinesLike(this.Faction, p)); } if (p.RaceProps.Animal && p.Faction == Faction.OfPlayer) { return(false); } } return(true); }
private bool IsValidTarget(Thing t) // Projectile flyoverhead check instead of verb { Pawn pawn = t as Pawn; if (pawn != null) { //if (this.GunCompEq.PrimaryVerb.verbProps.projectileDef.projectile.flyOverhead) if (Projectile.projectile.flyOverhead) { RoofDef roofDef = base.Map.roofGrid.RoofAt(t.Position); if (roofDef != null && roofDef.isThickRoof) { return(false); } } if (this.mannableComp == null) { return(!GenAI.MachinesLike(base.Faction, pawn)); } if (pawn.RaceProps.Animal && pawn.Faction == Faction.OfPlayer) { return(false); } } return(true); }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { List <Thing> commandConsoleList = Find.ListerThings.ThingsOfDef(OG_Util.OutpostCommandConsoleDef); if (commandConsoleList.Count == 1) { // Command console exists. Check which faction it belongs to. Thing commandConsole = commandConsoleList[0]; if ((commandConsole.Faction != null) && (commandConsole.Faction == OG_Util.FactionOfMAndCo)) { if (!c.InBounds()) { return(false); } if (c.Fogged()) { return(false); } RoofDef roofDef = Find.RoofGrid.RoofAt(c); if (roofDef == OG_Util.IronedRoofDef) { return("You cannot remove M&Co. Outpost roof. This area does not belong to your colony."); } } } return(base.CanDesignateCell(c)); }
// Token: 0x0600650C RID: 25868 RVA: 0x00233C80 File Offset: 0x00231E80 public override void Resolve(ResolveParams rp) { Faction = rp.faction; HiveFactionExtension hiveFaction = Faction.def.GetModExtension <HiveFactionExtension>(); cells.Clear(); Map map = BaseGen.globalSettings.map; IntVec3 CenterCell = rp.rect.CenterCell; float dist = rp.rect.TopRight.DistanceTo(rp.rect.BottomLeft); // Log.Message(Faction+" hive radius "+ dist); cells = map.AllCells.Where(x => x.DistanceTo(CenterCell) <= dist).ToList(); RoofGrid roofGrid = BaseGen.globalSettings.map.roofGrid; RoofDef def = rp.roofDef ?? RoofDefOf.RoofRockThick; List <IntVec3> cellst = cells.Where(x => x.DistanceTo(CenterCell) < dist - 10).ToList(); List <IntVec3> celle = cells.Where(x => x.DistanceTo(CenterCell) > dist - 5 && x.DistanceTo(CenterCell) < dist).ToList(); for (int i = 0; i < dist / 5; i++) { IntVec3 ce = celle.RandomElement(); Rand.PushState(); float size = Rand.Range(5, 10); Rand.PopState(); cells.RemoveAll(x => ce.DistanceTo(x) < size); } foreach (IntVec3 c in cells) { roofGrid.SetRoof(c, def); map.terrainGrid.SetTerrain(c, TerrainDefOf.Gravel); this.TrySpawnWall(c, rp); } }
// Token: 0x06000015 RID: 21 RVA: 0x00002D50 File Offset: 0x00000F50 private bool IsValidTarget(Thing t) { Pawn pawn = t as Pawn; bool flag = pawn != null; if (flag) { bool flag2 = base.GunCompEq.PrimaryVerb.ProjectileFliesOverhead(); if (flag2) { RoofDef roofDef = base.Map.roofGrid.RoofAt(t.Position); bool flag3 = roofDef != null && roofDef.isThickRoof; if (flag3) { return(false); } } bool flag4 = this.mannableComp == null; if (flag4) { return(false); } bool flag5 = pawn.RaceProps.Animal && pawn.Faction == Faction.OfPlayer; if (flag5) { return(false); } } return(true); }
private bool IsValidTarget(Thing t) { Pawn pawn = t as Pawn; if (pawn != null) { if (this.AttackVerb.ProjectileFliesOverhead()) { RoofDef roofDef = Operator.Map.roofGrid.RoofAt(t.Position); if (roofDef != null && roofDef.isThickRoof) { // Log.Message(t + " ProjectileFliesOverhead isThickRoof IsValidTarget: false"); return(false); } } if (this.Operator != null) { // Log.Message(t + " !MachinesLike IsValidTarget: " + !GenAI.MachinesLike(Operator.Faction, pawn)); return(!GenAI.MachinesLike(Operator.Faction, pawn)); } if (pawn.RaceProps.Animal && pawn.Faction == Faction.OfPlayer) { // Log.Message(t + " OfPlayer Animal IsValidTarget: false"); return(false); } } if (!Operator.CanSee(t)) { // Log.Messageage(t + "CanSee IsValidTarget: false"); } // Log.Message(t + " IsValidTarget: true"); return(true); }
private bool IsValidTarget(Thing t) { if (gun == null) { return(false); } Pawn pawn = t as Pawn; if (pawn != null) { if (this.GunCompEq.PrimaryVerb.ProjectileFliesOverhead()) { RoofDef roofDef = base.Map.roofGrid.RoofAt(t.Position); if (roofDef != null && roofDef.isThickRoof) { return(false); } } if (this.mannableComp == null) { return(!GenAI.MachinesLike(base.Faction, pawn)); } if (pawn.RaceProps.Animal && pawn.Faction == Faction.OfPlayer) { return(false); } } return(true); }
public static void Postfix(IntVec3 c, RoofDef def) { if (def == null && Current.ProgramState == ProgramState.Playing) { DesignatorMoveBase.SetNoRoofFalse(c); } }
public static bool Prefix(ref bool __result, IntVec3 c, Map map, bool canRoofPunch) { ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>(); if (extFtControl == null || extFtControl.overwriteRoof != RoofOverwriteType.FullStable) { return(true); } if (!c.Walkable(map)) { __result = false; return(false); } if (c.CloseToEdge(map, MaxDistanceToEdge)) { __result = true; return(false); } RoofDef roof = c.GetRoof(map); if (roof != null && !canRoofPunch) { __result = false; } else { __result = true; } return(false); }
private bool VulnerableToRain() { bool result; if (!base.Spawned) { result = false; } else { RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position); if (roofDef == null) { result = true; } else if (roofDef.isThickRoof) { result = false; } else { Thing edifice = base.Position.GetEdifice(base.Map); result = (edifice != null && edifice.def.holdsRoof); } } return(result); }
public override void NeedInterval() { if (this.Disabled) { this.CurLevel = 1f; return; } if (base.IsFrozen) { return; } float b = 0.2f; bool flag = !this.pawn.Spawned || this.pawn.Position.UsesOutdoorTemperature(this.pawn.Map); RoofDef roofDef = (!this.pawn.Spawned) ? null : this.pawn.Position.GetRoof(this.pawn.Map); float num; if (!flag) { if (roofDef == null) { num = 5f; } else if (!roofDef.isThickRoof) { num = -0.32f; } else { num = -0.45f; b = 0f; } } else if (roofDef == null) { num = 8f; } else if (roofDef.isThickRoof) { num = -0.4f; } else { num = 1f; } if (this.pawn.InBed() && num < 0f) { num *= 0.2f; } num *= 0.0025f; float curLevel = this.CurLevel; if (num < 0f) { this.CurLevel = Mathf.Min(this.CurLevel, Mathf.Max(this.CurLevel + num, b)); } else { this.CurLevel = Mathf.Min(this.CurLevel + num, 1f); } this.lastEffectiveDelta = this.CurLevel - curLevel; }
public static void AdjustNum(RoofDef roofDef, Pawn pawn, ref float num) { if (roofDef != null && pawn.Map.GetComponent <MapComponent_Windows>().WindowCells.ContainsKey(pawn.Position)) { num = (num < 0f) ? num * 0.9f : num / 0.9f; return; } }
public static void SetRoofComplete(Map map, RoofDef type) { foreach (IntVec3 cell in map.AllCells) { map.roofGrid.SetRoof(cell, type); } map.roofGrid.RoofGridUpdate(); }
public static void MakeTriangularRoom(Map map, ResolveParams rp) { if (rp.wallStuff == null) { Faction faction = Find.FactionManager.RandomNonHostileFaction(false, false, true, TechLevel.Spacer); rp.wallStuff = BaseGenUtility.RandomCheapWallStuff(faction, false); } if (rp.floorDef == null) { rp.floorDef = BaseGenUtility.CorrespondingTerrainDef(rp.wallStuff, true); } if (rp.floorDef == null) { rp.floorDef = BaseGenUtility.RandomBasicFloorDef(Faction.OfMechanoids, false); } ResolveParams resolveParams = rp; resolveParams.rect = new CellRect(rp.rect.minX, rp.rect.minZ, 1, rp.rect.Height); BaseGen.symbolStack.Push("edgeWalls", resolveParams, null); for (int i = 0; i <= rp.rect.Width; i++) { int num = rp.rect.minX + i; int num2 = (int)Math.Floor((double)(0.5f * (float)i)); int num3 = (int)Math.Ceiling((double)(0.5f * (float)i)); for (int j = rp.rect.minZ + num2; j < rp.rect.minZ + rp.rect.Width - num2; j++) { foreach (Thing thing in map.thingGrid.ThingsAt(new IntVec3(num, 1, j))) { thing.TakeDamage(new DamageInfo(DamageDefOf.Blunt, 10000, -1f, -1f, null, null, null, 0)); } MapGenUtility.TryToSetFloorTile(new IntVec3(num, 1, j), map, rp.floorDef); if (j == rp.rect.minZ + num2 || j == rp.rect.minZ + num3 || j == rp.rect.minZ + rp.rect.Width - (num2 + 1) || j == rp.rect.minZ + rp.rect.Width - (num3 + 1)) { ResolveParams resolveParams2 = rp; resolveParams2.rect = new CellRect(num, j, 1, 1); BaseGen.symbolStack.Push("edgeWalls", resolveParams2, null); } } } map.MapUpdate(); RoofGrid roofGrid = BaseGen.globalSettings.map.roofGrid; RoofDef def = rp.roofDef ?? RoofDefOf.RoofConstructed; for (int k = 0; k <= rp.rect.Width; k++) { int newX = rp.rect.minX + k; int num4 = (int)Math.Floor((double)(0.5f * (float)k)); for (int l = rp.rect.minZ + num4; l < rp.rect.minZ + rp.rect.Width - num4; l++) { IntVec3 c = new IntVec3(newX, 1, l); if (!roofGrid.Roofed(c)) { roofGrid.SetRoof(c, def); } } } }
public static bool CellFullFillsSpaceRequirement(this IntVec3 targetCell, IntVec2 intVec2, Map map) { foreach (IntVec3 cell in GenAdj.OccupiedRect(targetCell, Rot4.North, intVec2)) { RoofDef roof = cell.GetRoof(map); return(!(!cell.InBounds(map) || !cell.Walkable(map) || (roof != null && (roof.isNatural || roof.isThickRoof)) || CellBlockedByThing(targetCell, map))); } return(true); }
static void Postfix(Designator_AreaNoRoof __instance, IntVec3 c, ref AcceptanceReport __result) { RoofDef roofDef = __instance.Map.roofGrid.RoofAt(c); if (roofDef.defName == "RoofClean") { __result = "You can't remove clean roof".Translate(); } }
// when a new roof is placed, notify windows that enclose that cell to update public static void Prefix(IntVec3 c, RoofDef def) { MapComponent_Windows mapComp = WindowCache.WindowComponent; if (mapComp?.WindowCells?.ContainsKey(c) ?? false) { mapComp?.DirtyCells?.Add(c); } }