private bool IsBetter(ThingDef facilityDef, IntVec3 facilityPos, Rot4 facilityRot, Thing thanThisFacility) { if (facilityDef != thanThisFacility.def) { Log.Error("Comparing two different facility defs."); return(false); } Vector3 b = GenThing.TrueCenter(facilityPos, facilityRot, facilityDef.size, facilityDef.Altitude); Vector3 a = parent.TrueCenter(); float num = Vector3.Distance(a, b); float num2 = Vector3.Distance(a, thanThisFacility.TrueCenter()); if (num != num2) { return(num < num2); } int x = facilityPos.x; IntVec3 position = thanThisFacility.Position; if (x != position.x) { int x2 = facilityPos.x; IntVec3 position2 = thanThisFacility.Position; return(x2 < position2.x); } int z = facilityPos.z; IntVec3 position3 = thanThisFacility.Position; return(z < position3.z); }
private bool IsBetter(ThingDef facilityDef, IntVec3 facilityPos, Rot4 facilityRot, Thing thanThisFacility) { bool result; if (facilityDef != thanThisFacility.def) { Log.Error("Comparing two different facility defs.", false); result = false; } else { Vector3 b = GenThing.TrueCenter(facilityPos, facilityRot, facilityDef.size, facilityDef.Altitude); Vector3 a = this.parent.TrueCenter(); float num = Vector3.Distance(a, b); float num2 = Vector3.Distance(a, thanThisFacility.TrueCenter()); if (num != num2) { result = (num < num2); } else if (facilityPos.x != thanThisFacility.Position.x) { result = (facilityPos.x < thanThisFacility.Position.x); } else { result = (facilityPos.z < thanThisFacility.Position.z); } } return(result); }
public override void DrawGhost(IntVec3 center, Rot4 rot, ThingDef thingDef, Color ghostCol, AltitudeLayer drawAltitude) { base.DrawGhost(center, rot, thingDef, ghostCol, drawAltitude); GraphicDatabase.Get <Graphic_Single>(graphicPath, ShaderTypeDefOf.EdgeDetect.Shader, new Vector2(1, 3), ghostCol) .DrawFromDef(GenThing.TrueCenter(center, rot, thingDef.Size, drawAltitude.AltitudeFor()) + (IntVec3.South * 2).RotatedBy(rot).ToVector3(), rot, thingDef); }
private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, Site site, SitePart sitePart) { string text = def.letterText.Formatted(alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items), days.ToString(), SitePartUtility.GetDescriptionDialogue(site, sitePart), GenThing.GetMarketValue(items).ToStringMoney()).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref text, items); return(text); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map; if (!this.TryGetRandomAvailableTargetMap(out map)) { return(false); } SettlementBase settlementBase = IncidentWorker_QuestTradeRequest.RandomNearbyTradeableSettlement(map.Tile); if (settlementBase == null) { return(false); } TradeRequestComp component = settlementBase.GetComponent <TradeRequestComp>(); if (!this.TryGenerateTradeRequest(component, map)) { return(false); } string text = "LetterCaravanRequest".Translate(new object[] { settlementBase.Label, TradeRequestUtility.RequestedThingLabel(component.requestThingDef, component.requestCount).CapitalizeFirst(), (component.requestThingDef.GetStatValueAbstract(StatDefOf.MarketValue, null) * (float)component.requestCount).ToStringMoney("F0"), GenThing.ThingsToCommaList(component.rewards, true, true, -1).CapitalizeFirst(), GenThing.GetMarketValue(component.rewards).ToStringMoney("F0"), (component.expiration - Find.TickManager.TicksGame).ToStringTicksToDays("F0"), CaravanArrivalTimeEstimator.EstimatedTicksToArrive(map.Tile, settlementBase.Tile, null).ToStringTicksToDays("0.#") }); GenThing.TryAppendSingleRewardInfo(ref text, component.rewards); Find.LetterStack.ReceiveLetter("LetterLabelCaravanRequest".Translate(), text, LetterDefOf.PositiveEvent, settlementBase, settlementBase.Faction, null); return(true); }
public static void DrawLinesToNearbyBeacons(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map, Thing thing = null) { Vector3 a = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); foreach (Thing item in map.listerThings.ThingsOfDef(ThingDefOf.ShipLandingBeacon)) { if ((thing == null || thing != item) && item.Faction == Faction.OfPlayer) { CompShipLandingBeacon compShipLandingBeacon = item.TryGetComp <CompShipLandingBeacon>(); if (compShipLandingBeacon != null && CanLinkTo(myPos, compShipLandingBeacon) && !GenThing.CloserThingBetween(myDef, myPos, item.Position, map)) { GenDraw.DrawLineBetween(a, item.TrueCenter(), SimpleColor.White); } } } float minEdgeDistance = myDef.GetCompProperties <CompProperties_ShipLandingBeacon>().edgeLengthRange.min - 1f; float maxEdgeDistance = myDef.GetCompProperties <CompProperties_ShipLandingBeacon>().edgeLengthRange.max - 1f; foreach (Thing item2 in map.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint)) { if ((thing == null || thing != item2) && item2.def.entityDefToBuild == myDef && (myPos.x == item2.Position.x || myPos.z == item2.Position.z) && !AlignedDistanceTooShort(myPos, item2.Position, minEdgeDistance) && !AlignedDistanceTooLong(myPos, item2.Position, maxEdgeDistance) && !GenThing.CloserThingBetween(myDef, myPos, item2.Position, map)) { GenDraw.DrawLineBetween(a, item2.TrueCenter(), SimpleColor.White); } } }
public override void DrawGhost(ThingDef def, IntVec3 loc, Rot4 rot, Color ghostCol) { Graphic baseGraphic = GraphicDatabase.Get <Graphic_Single>(def.building.turretTopGraphicPath, ShaderDatabase.Cutout, new Vector2(def.building.turretTopDrawSize, def.building.turretTopDrawSize), Color.white); Graphic graphic = GhostUtility.GhostGraphicFor(baseGraphic, def, ghostCol); graphic.DrawFromDef(GenThing.TrueCenter(loc, rot, def.Size, AltitudeLayer.MetaOverlays.AltitudeFor()), rot, def); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (!TryFindFactions(out Faction alliedFaction, out Faction enemyFaction)) { return(false); } if (!TryFindTile(out int tile)) { return(false); } Site site = SiteMaker.MakeSite(SiteCoreDefOf.Nothing, SitePartDefOf.Outpost, tile, enemyFaction); site.sitePartsKnown = true; List <Thing> list = GenerateRewards(alliedFaction, site.desiredThreatPoints); site.GetComponent <DefeatAllEnemiesQuestComp>().StartQuest(alliedFaction, 18, list); int randomInRange = SiteTuning.QuestSiteTimeoutDaysRange.RandomInRange; site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000); Find.WorldObjects.Add(site); string text = def.letterText.Formatted(alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(list, string.Empty), randomInRange.ToString(), SitePartUtility.GetDescriptionDialogue(site, site.parts.FirstOrDefault()), GenThing.GetMarketValue(list).ToStringMoney()).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref text, list); Find.LetterStack.ReceiveLetter(def.letterLabel, text, def.letterDef, site, alliedFaction); return(true); }
protected override bool CanDrawNumbersBetween(Thing thing, ThingDef def, IntVec3 a, IntVec3 b, Map map) { if (ThingToInstall != thing) { return(!GenThing.CloserThingBetween(def, a, b, map, ThingToInstall)); } return(false); }
public static void DrawLinesToPotentialThingsToLinkTo(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map) { Vector3 a = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); foreach (Thing current in CompAffectedByFacilities.PotentialThingsToLinkTo(myDef, myPos, myRot, map)) { GenDraw.DrawLineBetween(a, current.TrueCenter()); } }
public static void DrawLinesToPotentialThingsToLinkTo(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map) { Vector3 a = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); foreach (Thing item in PotentialThingsToLinkTo(myDef, myPos, myRot, map)) { GenDraw.DrawLineBetween(a, item.TrueCenter()); } }
public static Vector3 TrueCenter(this Thing t) { Pawn pawn = t as Pawn; if (pawn != null) { return(pawn.Drawer.DrawPos); } return(GenThing.TrueCenter(t.Position, t.Rotation, t.def.size, t.def.Altitude)); }
public static IEnumerable <Thing> PotentialThingsToLinkTo(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map) { _003CPotentialThingsToLinkTo_003Ec__Iterator1 _003CPotentialThingsToLinkTo_003Ec__Iterator = (_003CPotentialThingsToLinkTo_003Ec__Iterator1) /*Error near IL_0034: stateMachine*/; alreadyReturnedCount.Clear(); CompProperties_AffectedByFacilities myProps = myDef.GetCompProperties <CompProperties_AffectedByFacilities>(); if (myProps.linkableFacilities != null) { IEnumerable <Thing> candidates = Enumerable.Empty <Thing>(); for (int i = 0; i < myProps.linkableFacilities.Count; i++) { candidates = candidates.Concat(map.listerThings.ThingsOfDef(myProps.linkableFacilities[i])); } Vector3 myTrueCenter = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); IOrderedEnumerable <Thing> sortedCandidates = (from x in candidates orderby Vector3.Distance(myTrueCenter, x.TrueCenter()) select x).ThenBy(delegate(Thing x) { IntVec3 position2 = x.Position; return(position2.x); }).ThenBy(delegate(Thing x) { IntVec3 position = x.Position; return(position.z); }); foreach (Thing item in sortedCandidates) { if (CanPotentiallyLinkTo_Static(item, myDef, myPos, myRot)) { CompProperties_Facility facilityProps = item.def.GetCompProperties <CompProperties_Facility>(); if (alreadyReturnedCount.ContainsKey(item.def)) { if (alreadyReturnedCount[item.def] >= facilityProps.maxSimultaneous) { continue; } } else { alreadyReturnedCount.Add(item.def, 0); } Dictionary <ThingDef, int> dictionary; ThingDef def; (dictionary = alreadyReturnedCount)[def = item.def] = dictionary[def] + 1; yield return(item); /*Error: Unable to find new state assignment for yield return*/; } } } yield break; IL_02b1: /*Error near IL_02b2: Unexpected return in MoveNext()*/; }
public static void DrawArtificialBuildingOverlay(IntVec3 pos, ThingDef def, Map map, float radius) { GenDraw.DrawRadiusRing(pos, radius, ArtificialBuildingRingColor); int num = 0; foreach (Thing item in map.listerArtificialBuildingsForMeditation.GetForCell(pos, radius)) { if (num++ > 10) { break; } GenDraw.DrawLineBetween(GenThing.TrueCenter(pos, Rot4.North, def.size, def.Altitude), item.TrueCenter(), SimpleColor.Red); } }
public static Vector3 TrueCenter(this Thing t) { Pawn pawn = t as Pawn; Vector3 result; if (pawn != null) { result = pawn.Drawer.DrawPos; } else { result = GenThing.TrueCenter(t.Position, t.Rotation, t.def.size, t.def.Altitude); } return(result); }
private string GetLetterText(Faction alliedFaction, List <Thing> items, int days, Site site, SitePart sitePart) { string result = string.Format(this.def.letterText, new object[] { alliedFaction.leader.LabelShort, alliedFaction.def.leaderTitle, alliedFaction.Name, GenLabel.ThingsLabel(items, " - "), days.ToString(), SitePartUtility.GetDescriptionDialogue(site, sitePart), GenThing.GetMarketValue(items).ToStringMoney(null) }).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref result, items); return(result); }
public static void RenderAnticipatedWirePieceConnecting(IntVec3 userPos, Rot4 rotation, IntVec2 thingSize, Thing transmitter) { Vector3 vector = GenThing.TrueCenter(userPos, rotation, thingSize, AltitudeLayer.MapDataOverlay.AltitudeFor()); if (userPos != transmitter.Position) { Vector3 vector2 = transmitter.TrueCenter(); vector2.y = AltitudeLayer.MapDataOverlay.AltitudeFor(); Vector3 pos = (vector + vector2) / 2f; Vector3 v = vector2 - vector; Vector3 s = new Vector3(1f, 1f, v.MagnitudeHorizontal()); Quaternion q = Quaternion.LookRotation(vector2 - vector); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(pos, q, s); Graphics.DrawMesh(MeshPool.plane10, matrix, PowerOverlayMats.MatConnectorAnticipated, 0); } }
public static bool CanPotentiallyLinkTo_Static(ThingDef facilityDef, IntVec3 facilityPos, Rot4 facilityRot, ThingDef myDef, IntVec3 myPos, Rot4 myRot) { CompProperties_Facility compProperties = facilityDef.GetCompProperties <CompProperties_Facility>(); if (compProperties.mustBePlacedAdjacent) { CellRect rect = GenAdj.OccupiedRect(myPos, myRot, myDef.size); CellRect rect2 = GenAdj.OccupiedRect(facilityPos, facilityRot, facilityDef.size); if (!GenAdj.AdjacentTo8WayOrInside(rect, rect2)) { return(false); } } if (compProperties.mustBePlacedAdjacentCardinalToBedHead) { if (!myDef.IsBed) { return(false); } CellRect other = GenAdj.OccupiedRect(facilityPos, facilityRot, facilityDef.size); bool flag = false; int sleepingSlotsCount = BedUtility.GetSleepingSlotsCount(myDef.size); for (int i = 0; i < sleepingSlotsCount; i++) { IntVec3 sleepingSlotPos = BedUtility.GetSleepingSlotPos(i, myPos, myRot, myDef.size); if (sleepingSlotPos.IsAdjacentToCardinalOrInside(other)) { flag = true; } } if (!flag) { return(false); } } if (!compProperties.mustBePlacedAdjacent && !compProperties.mustBePlacedAdjacentCardinalToBedHead) { Vector3 a = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); Vector3 b = GenThing.TrueCenter(facilityPos, facilityRot, facilityDef.size, facilityDef.Altitude); if (Vector3.Distance(a, b) > compProperties.maxDistance) { return(false); } } return(true); }
public static void DrawLinesToPotentialThingsToLinkTo(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map) { CompProperties_Facility compProperties = myDef.GetCompProperties <CompProperties_Facility>(); Vector3 a = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); for (int i = 0; i < compProperties.linkableBuildings.Count; i++) { foreach (Thing item in map.listerThings.ThingsOfDef(compProperties.linkableBuildings[i])) { CompAffectedByFacilities compAffectedByFacilities = item.TryGetComp <CompAffectedByFacilities>(); if (compAffectedByFacilities != null && compAffectedByFacilities.CanPotentiallyLinkTo(myDef, myPos, myRot)) { GenDraw.DrawLineBetween(a, item.TrueCenter()); compAffectedByFacilities.DrawRedLineToPotentiallySupplantedFacility(myDef, myPos, myRot); } } } }
public static void DrawMeditationFociAffectedByBuildingOverlay(Map map, ThingDef def, Faction faction, IntVec3 pos, Rot4 rotation) { int num = 0; foreach (Thing item in GetMeditationFociAffectedByBuilding(map, def, faction, pos, rotation)) { if (num++ > 10) { break; } CompToggleDrawAffectedMeditationFoci compToggleDrawAffectedMeditationFoci = item.TryGetComp <CompToggleDrawAffectedMeditationFoci>(); if (compToggleDrawAffectedMeditationFoci == null || compToggleDrawAffectedMeditationFoci.Enabled) { GenAdj.OccupiedRect(pos, rotation, def.size); GenDraw.DrawLineBetween(GenThing.TrueCenter(pos, rotation, def.size, def.Altitude), item.TrueCenter(), SimpleColor.Red); } } }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null) { if (!ModsConfig.RoyaltyActive) { return; } FocusStrengthOffset_BuildingDefs focusStrengthOffset_BuildingDefs = ((CompProperties_MeditationFocus)((def.IsFrame || def.IsBlueprint) ? ((ThingDef)def.entityDefToBuild).CompDefFor <CompMeditationFocus>() : def.CompDefFor <CompMeditationFocus>())).offsets.OfType <FocusStrengthOffset_BuildingDefs>().FirstOrDefault(); if (focusStrengthOffset_BuildingDefs != null) { GenDraw.DrawRadiusRing(center, focusStrengthOffset_BuildingDefs.radius, RingColor); List <Thing> forCell = Find.CurrentMap.listerBuldingOfDefInProximity.GetForCell(center, focusStrengthOffset_BuildingDefs.radius, focusStrengthOffset_BuildingDefs.defs); for (int i = 0; i < forCell.Count && i < focusStrengthOffset_BuildingDefs.maxBuildings; i++) { GenDraw.DrawLineBetween(GenThing.TrueCenter(center, Rot4.North, def.size, def.Altitude), forCell[i].TrueCenter(), SimpleColor.Green); } } }
public static IEnumerable <Thing> PotentialThingsToLinkTo(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map) { CompAffectedByFacilities.alreadyReturnedCount.Clear(); CompProperties_AffectedByFacilities myProps = myDef.GetCompProperties <CompProperties_AffectedByFacilities>(); if (myProps.linkableFacilities == null) { yield break; } IEnumerable <Thing> candidates = Enumerable.Empty <Thing>(); for (int i = 0; i < myProps.linkableFacilities.Count; i++) { candidates = candidates.Concat(map.listerThings.ThingsOfDef(myProps.linkableFacilities[i])); } Vector3 myTrueCenter = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); IOrderedEnumerable <Thing> sortedCandidates = from x in candidates orderby Vector3.Distance(myTrueCenter, x.TrueCenter()), x.Position.x, x.Position.z select x; foreach (Thing th in sortedCandidates) { if (CompAffectedByFacilities.CanPotentiallyLinkTo_Static(th, myDef, myPos, myRot)) { CompProperties_Facility facilityProps = th.def.GetCompProperties <CompProperties_Facility>(); if (CompAffectedByFacilities.alreadyReturnedCount.ContainsKey(th.def)) { if (CompAffectedByFacilities.alreadyReturnedCount[th.def] >= facilityProps.maxSimultaneous) { continue; } } else { CompAffectedByFacilities.alreadyReturnedCount.Add(th.def, 0); } Dictionary <ThingDef, int> dictionary; ThingDef def; (dictionary = CompAffectedByFacilities.alreadyReturnedCount)[def = th.def] = dictionary[def] + 1; yield return(th); } } yield break; }
public static IEnumerable <Thing> PotentialThingsToLinkTo(ThingDef myDef, IntVec3 myPos, Rot4 myRot, Map map) { alreadyReturnedCount.Clear(); CompProperties_AffectedByFacilities compProperties = myDef.GetCompProperties <CompProperties_AffectedByFacilities>(); if (compProperties.linkableFacilities == null) { yield break; } IEnumerable <Thing> enumerable = Enumerable.Empty <Thing>(); for (int i = 0; i < compProperties.linkableFacilities.Count; i++) { enumerable = enumerable.Concat(map.listerThings.ThingsOfDef(compProperties.linkableFacilities[i])); } Vector3 myTrueCenter = GenThing.TrueCenter(myPos, myRot, myDef.size, myDef.Altitude); IOrderedEnumerable <Thing> orderedEnumerable = from x in enumerable orderby Vector3.Distance(myTrueCenter, x.TrueCenter()), x.Position.x, x.Position.z select x; foreach (Thing item in orderedEnumerable) { if (!CanPotentiallyLinkTo_Static(item, myDef, myPos, myRot)) { continue; } CompProperties_Facility compProperties2 = item.def.GetCompProperties <CompProperties_Facility>(); if (alreadyReturnedCount.ContainsKey(item.def)) { if (alreadyReturnedCount[item.def] >= compProperties2.maxSimultaneous) { continue; } } else { alreadyReturnedCount.Add(item.def, 0); } alreadyReturnedCount[item.def]++; yield return(item); } }
public override void DrawGhost(ThingDef def, IntVec3 loc, Rot4 rot, Color ghostCol, Thing thing = null) { GhostUtility.GhostGraphicFor(GraphicDatabase.Get <Graphic_Single>(def.building.turretGunDef.graphicData.texPath, ShaderDatabase.Cutout, new Vector2(def.building.turretTopDrawSize, def.building.turretTopDrawSize), Color.white), def, ghostCol).DrawFromDef(GenThing.TrueCenter(loc, rot, def.Size, AltitudeLayer.MetaOverlays.AltitudeFor()), rot, def, TurretTop.ArtworkRotation); }
protected virtual bool CanDrawNumbersBetween(Thing thing, ThingDef def, IntVec3 a, IntVec3 b, Map map) { return(!GenThing.CloserThingBetween(def, a, b, map)); }