// Token: 0x06000013 RID: 19 RVA: 0x0000219C File Offset: 0x0000039C
        public override void Destroy(DestroyMode mode)
        {
            bool spawned = base.Spawned;
            Map  map     = base.Map;

            SmoothableWallUtility.Notify_BuildingDestroying(this, mode);
            base.Destroy(mode);
            InstallBlueprintUtility.CancelBlueprintsFor(this);
            if (mode == DestroyMode.Deconstruct && spawned)
            {
                SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            if (mode == DestroyMode.KillFinalize && spawned)
            {
                ThingDef_MechanoidFigure thingDef_MechanoidFigure = (ThingDef_MechanoidFigure)this.def;
                if (thingDef_MechanoidFigure != null)
                {
                    if (thingDef_MechanoidFigure.soundDestroy != null)
                    {
                        thingDef_MechanoidFigure.soundDestroy.PlayOneShot(new TargetInfo(base.Position, map, false));
                    }
                }
            }
            if (Find.PlaySettings.autoRebuild && mode == DestroyMode.KillFinalize && base.Faction == Faction.OfPlayer && spawned && this.def.blueprintDef != null && this.def.IsResearchFinished && map.areaManager.Home[base.Position] && GenConstruct.CanPlaceBlueprintAt(this.def, base.Position, base.Rotation, map, false, null).Accepted)
            {
                GenConstruct.PlaceBlueprintForBuild(this.def, base.Position, map, base.Rotation, Faction.OfPlayer, base.Stuff);
            }
        }
 private void CheckAutoRebuild(Map map)
 {
     if (this.autoRearm && this.CanSetAutoRearm && map != null && GenConstruct.CanPlaceBlueprintAt(this.def, base.Position, base.Rotation, map, false, null, null, base.Stuff).Accepted)
     {
         GenConstruct.PlaceBlueprintForBuild(this.def, base.Position, map, base.Rotation, Faction.OfPlayer, base.Stuff);
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            bool           result    = false;
            List <IntVec3> targets   = new List <IntVec3>();
            int            numOffset = Mathf.Min((int)(((Map)parms.target).wealthWatcher.WealthTotal / 100000), 7);
            int            num       = Rand.Range(1, 1 + numOffset);

            for (int i = 0; i < num; i++)
            {
                if (this.TryFindRandomPowerConduitInMap((Map)parms.target, out Building tempConduit))
                {
                    IntVec3 intVec = new IntVec3(tempConduit.Position.x, tempConduit.Position.y, tempConduit.Position.z);
                    Rot4    rot    = new Rot4(tempConduit.Rotation.AsByte);
                    targets.Add(intVec);
                    tempConduit.Destroy(DestroyMode.Deconstruct);
                    if (Find.PlaySettings.autoRebuild && tempConduit.def.blueprintDef != null && tempConduit.def.IsResearchFinished && ((Map)parms.target).areaManager.Home[tempConduit.Position])
                    {
                        if (GenConstruct.CanPlaceBlueprintAt(tempConduit.def, intVec, rot, (Map)parms.target, false, null).Accepted)
                        {
                            GenConstruct.PlaceBlueprintForBuild(tempConduit.def, intVec, (Map)parms.target, rot, Faction.OfPlayer, tempConduit.Stuff);
                        }
                    }
                }
            }
            if (!targets.NullOrEmpty())
            {
                result = true;
                LookTargets letterTargets = new LookTargets(this.GetLetterTargets(targets, (Map)parms.target));
                Find.LetterStack.ReceiveLetter(this.def.letterLabel, this.def.letterText, this.def.letterDef, letterTargets);
            }
            return(result);
        }
        public void ScheduleReplacement(CompAutoReplaceable replaceableComp)
        {
            var building = replaceableComp.parent;

            if (building?.def == null)
            {
                return;
            }
            if ((building.Stuff == null && building.def.MadeFromStuff) || (building.Stuff != null && !building.def.MadeFromStuff))
            {
                RemoteTechController.Instance.Logger.Warning("Could not schedule {0} auto-replacement due to Stuff discrepancy.", building);
                return;
            }
            var report = GenConstruct.CanPlaceBlueprintAt(building.def, replaceableComp.ParentPosition, replaceableComp.ParentRotation, map);

            if (!report.Accepted)
            {
                RemoteTechController.Instance.Logger.Message($"Could not auto-replace {building.LabelCap}: {report.Reason}");
                return;
            }
            var blueprint = GenConstruct.PlaceBlueprintForBuild(building.def, replaceableComp.ParentPosition, map, replaceableComp.ParentRotation, Faction.OfPlayer, building.Stuff);
            var entry     = new ReplacementEntry {
                position     = replaceableComp.ParentPosition,
                unforbidTick = Find.TickManager.TicksGame + RemoteTechController.Instance.BlueprintForbidDuration * GenTicks.TicksPerRealSecond,
                savedVars    = new Dictionary <string, string>()
            };

            InvokeExposableCallbacks(building, entry.savedVars, LoadSaveMode.Saving);
            pendingSettings.Add(entry);
            if (RemoteTechController.Instance.BlueprintForbidDuration > 0)
            {
                blueprint.SetForbidden(true, false);
                pendingForbiddenBlueprints.Add(entry);
            }
        }
 private void CheckAutoRebuild(Map map)
 {
     if (map != null)
     {
         GenConstruct.PlaceBlueprintForBuild(def, base.Position, map, base.Rotation, Faction.OfPlayer, base.Stuff);
     }
 }
Ejemplo n.º 6
0
        // Not in use
        public void Expand()
        {
            nextCheckTick--;
            if (nextCheckTick > 0)
            {
                return;
            }
            nextCheckTick += 1;
            Log.Warning(Label + ": " + Position);

            // Get connected cells
            var cell = Position.RandomAdjacentCellCardinal();

            if (cell.InBounds())
            {
                var conduit = cell.GetFirstThing(PowerConduitDef);
                if (conduit != null)
                {
                    if (Find.DesignationManager.DesignationOn(conduit, DesignationDefOf.Deconstruct) == null)
                    {
                        Find.DesignationManager.AddDesignation(new Designation(conduit, DesignationDefOf.Deconstruct));
                    }
                    var blueprint = cell.GetFirstThing(PowerConduitDef.blueprintDef);
                    if (blueprint == null)
                    {
                        GenConstruct.PlaceBlueprintForBuild(def, cell, new Rot4(), Faction.OfColony, GenStuff.DefaultStuffFor(def));
                    }
                }
            }
        }
        public static IEnumerable <Blueprint_Build> Postfix(IEnumerable <Blueprint_Build> __result, float points, Map map, Faction ___faction)
        {
            int numArtillery = Mathf.RoundToInt(points / 60f);

            numArtillery = Mathf.Clamp(numArtillery, 1, 2);
            List <ThingDef> possibleArtillery = DefDatabase <ThingDef> .AllDefs.Where(def => def.building != null && def.building.buildingTags.Contains("Artillery_BaseDestroyer")).ToList();

            List <ThingDef> highestTechArtillery = possibleArtillery.OrderByDescending(a => a.techLevel).GroupBy(d => d.techLevel).Select(g => g.ToList()).FirstOrDefault();

            for (int i = 0; i < numArtillery; i++)
            {
                Rot4     random   = Rot4.Random;
                ThingDef thingDef = highestTechArtillery.RandomElement();
                IntVec3  intVec   = (IntVec3)AccessTools.Method(typeof(SiegeBlueprintPlacer), "FindArtySpot").Invoke(null, new object[] { thingDef, random, map });
                if (!intVec.IsValid)
                {
                    yield break;
                }
                StuffCategoryDef stuffDef = thingDef.stuffCategories.RandomElement();
                var potentialStuff        = DefDatabase <ThingDef> .AllDefs.Where(d => d.stuffProps?.categories.Contains(stuffDef) ?? false);

                ThingDef stuff = potentialStuff.RandomElementByWeight(d => 1 / (d.BaseMarketValue * (d.smallVolume ? 20 : 1)));
                yield return(GenConstruct.PlaceBlueprintForBuild(thingDef, intVec, map, random, ___faction, stuff));

                points -= 60f;
            }
        }
Ejemplo n.º 8
0
 public static void CheckAutoRebuildOnDestroyed(Thing thing, DestroyMode mode, Map map, BuildableDef buildingDef)
 {
     if (Find.PlaySettings.autoRebuild && mode == DestroyMode.KillFinalize && thing.Faction == Faction.OfPlayer && buildingDef.blueprintDef != null && buildingDef.IsResearchFinished && map.areaManager.Home[thing.Position] && GenConstruct.CanPlaceBlueprintAt(buildingDef, thing.Position, thing.Rotation, map).Accepted)
     {
         GenConstruct.PlaceBlueprintForBuild(buildingDef, thing.Position, map, thing.Rotation, Faction.OfPlayer, thing.Stuff);
     }
 }
Ejemplo n.º 9
0
 public static void CheckAutoRebuildTerrainOnDestroyed(TerrainDef terrainDef, IntVec3 pos, Map map)
 {
     if (Find.PlaySettings.autoRebuild && terrainDef.autoRebuildable && terrainDef.blueprintDef != null && terrainDef.IsResearchFinished && map.areaManager.Home[pos] && GenConstruct.CanPlaceBlueprintAt(terrainDef, pos, Rot4.South, map).Accepted)
     {
         GenConstruct.PlaceBlueprintForBuild(terrainDef, pos, map, Rot4.South, Faction.OfPlayer, null);
     }
 }
Ejemplo n.º 10
0
        public override void ReceiveCompSignal(string signal)
        {
            if (signal == AutoRebuildSignal && autoRebuild)
            {
                GenConstruct.PlaceBlueprintForBuild(parent.def, parent.Position, previousMap, parent.Rotation, Faction.OfPlayer, parent.Stuff);
            }

            base.ReceiveCompSignal(signal);
        }
 public static void PlaceBridgeIfNeeded(BuildableDef sourceDef, IntVec3 pos, Map map, Rot4 rotation, Faction faction, ThingDef stuff)
 {
     if (pos.GetThingList(map).Any(t => t.def.entityDefToBuild == TerrainDefOf.Bridge))
     {
         return;                //Already building!
     }
     if (PlaceBridges.NeedsBridge(sourceDef, pos, map, stuff))
     {
         GenConstruct.PlaceBlueprintForBuild(TerrainDefOf.Bridge, pos, map, rotation, faction, null);
     }
 }
Ejemplo n.º 12
0
        //A lot like CheckAutoRebuildOnDestroyed
        public static void CheckAutoRebuildOnLaunch(Thing thing, Map map, BuildableDef buildingDef)
        {
            if (!Settings.Get().autoRebuildTransportPod)
            {
                return;
            }

            if (Find.PlaySettings.autoRebuild && thing.Faction == Faction.OfPlayer && buildingDef.blueprintDef != null && buildingDef.IsResearchFinished && map.areaManager.Home[thing.Position] && GenConstruct.CanPlaceBlueprintAt(buildingDef, thing.Position, thing.Rotation, map, false, null).Accepted)
            {
                GenConstruct.PlaceBlueprintForBuild(buildingDef, thing.Position, map, thing.Rotation, Faction.OfPlayer, thing.Stuff);
            }
        }
Ejemplo n.º 13
0
        public static bool Prefix(Designator_Build __instance, ref IntVec3 c)
        {
            ThingDef stuffDef = (ThingDef)(typeof(Designator_Build).GetField("stuffDef", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                                                                             | BindingFlags.Static).GetValue(__instance));

            if (stuffDef != null)
            {
                if (stuffDef.comps != null)
                {
                    CompProperties_ReplaceThing compProperties_RepleceThing = stuffDef.comps.Where(x => x is CompProperties_ReplaceThing comp && comp.CompareThing == __instance.PlacingDef).FirstOrDefault() as CompProperties_ReplaceThing;
                    if (compProperties_RepleceThing != null)
                    {
                        Rot4 placingRot = (Rot4)(typeof(Designator_Build).GetField("placingRot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                                                                                   | BindingFlags.Static).GetValue(__instance));

                        if (DebugSettings.godMode || __instance.PlacingDef.GetStatValueAbstract(StatDefOf.WorkToBuild, stuffDef) == 0f)
                        {
                            if (__instance.PlacingDef is TerrainDef)
                            {
                                __instance.Map.terrainGrid.SetTerrain(c, (TerrainDef)__instance.PlacingDef);
                            }
                            else
                            {
                                Thing thing = ThingMaker.MakeThing(compProperties_RepleceThing.ReplaceThing, stuffDef);
                                thing.SetFactionDirect(Faction.OfPlayer);
                                GenSpawn.Spawn(thing, c, __instance.Map, placingRot);
                            }
                        }
                        else
                        {
                            BuildableDef buildableDef = compProperties_RepleceThing.ReplaceThing;
                            if (buildableDef.blueprintDef == null)
                            {
                                buildableDef.blueprintDef = ThingDefGenerator_BuildingsCustom.NewBlueprintDef_Thing(compProperties_RepleceThing.ReplaceThing, isInstallBlueprint: false);
                            }
                            if (buildableDef.frameDef == null)
                            {
                                buildableDef.frameDef = ThingDefGenerator_BuildingsCustom.NewFrameDef_Thing(compProperties_RepleceThing.ReplaceThing);
                            }

                            GenSpawn.WipeExistingThings(c, placingRot, buildableDef, __instance.Map, DestroyMode.Deconstruct);
                            GenConstruct.PlaceBlueprintForBuild(buildableDef, c, __instance.Map, placingRot, Faction.OfPlayer, stuffDef);
                        }

                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 14
0
 static void Postfix(JobDriver_PlantHarvest __instance, Toil __result)
 {
     __result.initAction = delegate
     {
         Thing thing = __result.actor.jobs.curJob.GetTarget(TargetIndex.A).Thing;
         Map   map   = __result.actor.Map;
         map.designationManager.RemoveAllDesignationsOn(thing, false);
         if (!tw_YAAM.ConvertSoilAfterHarvest)
         {
             return;
         }
         IntVec3    pos        = thing.Position;
         TerrainDef terrainDef = map.terrainGrid.TerrainAt(pos);
         if (!terrainDef.defName.StartsWith("twSoil"))
         {
             return;
         }
         map.terrainGrid.SetTerrain(__result.actor.jobs.curJob.targetA.Cell, RimWorld.TerrainDefOf.Soil);
         if (map.terrainGrid.TerrainAt(pos).defName != RimWorld.TerrainDefOf.Soil.defName)
         {
             Verse.Log.Warning("tw_YAMM.ConvertSoilAfterHarvest failed at " + pos.ToString());
         }
         List <Zone> zonesList = map.zoneManager.AllZones;
         for (int j = 0; j < zonesList.Count; j++)
         {
             Zone_Growing growingZone = zonesList[j] as Zone_Growing;
             if (growingZone == null)
             {
                 continue;
             }
             if (growingZone.cells.Count == 0)
             {
                 continue;
             }
             if (!growingZone.Cells.Contains(pos))
             {
                 continue;
             }
             if (tw_YAAM.WorldObject.GrowingZonesPlaceBlueprint.Contains(growingZone.label))
             {
                 Blueprint_Build blueprint_Build = GenConstruct.PlaceBlueprintForBuild(terrainDef, pos, map, Rot4.North, Faction.OfPlayer, null);
                 if (blueprint_Build == null)
                 {
                     Verse.Log.Warning("tw_YAMM.PlaceBlueprint failed for " + terrainDef.defName + " in " + growingZone.label);
                 }
                 return;
             }
         }
     };
 }
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Job job = null;

            ConstructionStatus status = jobTarget.TargetConstructionStatus(meeseeks.MapHeld);

            Logger.MessageFormat(this, "Checking for blocker, construction status: {0}", status);

            if (status == ConstructionStatus.None)
            {
                BuildableDef buildableDef = jobTarget.BuildableDef;

                if (buildableDef != null && GenConstruct.PlaceBlueprintForBuild(buildableDef, jobTarget.Cell, meeseeks.MapHeld, jobTarget.blueprintRotation, meeseeks.Faction, jobTarget.blueprintStuff) != null)
                {
                    status = ConstructionStatus.InProgress;
                }
            }

            if (status == ConstructionStatus.Blocked)
            {
                job = GetDeconstructingJob(meeseeks, jobTarget, meeseeks.MapHeld);
                if (job == null)
                {
                    jobAvailabilty = JobAvailability.Delayed;
                }
                else
                {
                    jobAvailabilty = JobAvailability.Available;
                }
            }
            else if (status == ConstructionStatus.InProgress)
            {
                job = ScanForJob(meeseeks, memory, savedJob, jobTarget, ref jobAvailabilty, true);
                if (job == null)
                {
                    jobAvailabilty = JobAvailability.Delayed;
                }
                else
                {
                    jobAvailabilty = JobAvailability.Available;
                }
            }
            else if (status == ConstructionStatus.Complete)
            {
                jobAvailabilty = JobAvailability.Complete;
            }

            return(job);
        }
Ejemplo n.º 16
0
        private void MakeFO(int XX1, int ZZ1, int bx, int bz, ThingDef stuff)
        {
            Map map = this.Map;

            //Verse.Log.Message(XX1 + " " + ZZ1);
            //int Radius = (int)Math.Round(Math.Sqrt(XX1 * XX1 + ZZ1 * ZZ1));


            //Verse.Log.Message("Radius : " + Radius);
            //int FHD = Radius * 2 + 1;//Radius * 2 + 1;


            //int x = 0; int y = (int)Math.Ceiling(Radius);
            IntVec3 printVec;
            //bool[,] grid = new bool[XX1 * 2 + 1, ZZ1 * 2 + 1];
            int y = 0;
            int x = 0;

            for (y = 0; y < ZZ1 * 2 + 1; y++)
            {
                for (x = 0; x < XX1 * 2 + 1; x++)
                {
                    if ((bx - XX1 + x) < 0 || (bx - XX1 + x) >= map.Size.x)
                    {
                        // Messages.Message("xxx", MessageTypeDefOf.NeutralEvent);
                        continue;
                    }
                    else if ((bz - ZZ1 + y) < 0 || bz - ZZ1 + y >= map.Size.z)
                    {
                        //Messages.Message("zzz", MessageTypeDefOf.NeutralEvent);
                        continue;
                    }

                    if (is_ellipse(XX1, ZZ1, x - XX1, y - ZZ1)) // 체크!
                    {
                        // 블루프린트 설치
                        //grid[y, x] = true;
                        printVec   = this.Position;
                        printVec.x = bx - XX1 + x;
                        printVec.z = bz - ZZ1 + y;

                        //Messages.Message(bx + "  " + x  + "  " + bz + "  "+y+ "bphere"+ "  "+ "pv" + printVec.x + " " + printVec.z + " " + XX1 + " " + ZZ1, MessageTypeDefOf.NeutralEvent);

                        GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Wall, printVec, this.Map, base.Rotation, Faction.OfPlayer, stuff);
                    }
                }
            }
            //GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Wall, base.Position, this.Map, base.Rotation, Faction.OfPlayer, ThingDefOf.WoodLog);
        }
        private static IEnumerable <Blueprint_Build> PlaceArtilleryBlueprints(LordToilData_SiegeCustom data, Map map)
        {
            IEnumerable <ThingDef> artyDefs = customParams.artilleryDefs;

            // No tag matches
            if (!artyDefs.Any())
            {
                Log.Error($"Could not find any artillery ThingDefs matching the following tags: {customParams.artilleryBuildingTags.ToStringSafeEnumerable()}");
                yield break;
            }

            float points = data.blueprintPoints;

            // Generate blueprints
            int numArtillery = Mathf.RoundToInt(points / customParams.lowestArtilleryBlueprintPoints);

            numArtillery = Mathf.Clamp(numArtillery, customParams.artilleryCountRange.min, customParams.artilleryCountRange.max);
            int i = 0;

            while (points > 0 && i < numArtillery)
            {
                artyDefs = artyDefs.Where(t => ThingDefExtension.Get(t).siegeBlueprintPoints <= points);
                if (!artyDefs.Any())
                {
                    yield break;
                }
                var rot      = Rot4.Random;
                var artyDef  = artyDefs.RandomElementByWeight(t => ThingDefExtension.Get(t).siegeBlueprintPoints);
                var artySpot = NonPublicMethods.SiegeBlueprintPlacer_FindArtySpot(artyDef, rot, map);
                if (!artySpot.IsValid)
                {
                    yield break;
                }
                yield return(GenConstruct.PlaceBlueprintForBuild(artyDef, artySpot, map, rot, (Faction)NonPublicFields.SiegeBlueprintPlacer_faction.GetValue(null), GenStuff.DefaultStuffFor(artyDef)));

                if (data.artilleryCounts.ContainsKey(artyDef))
                {
                    data.artilleryCounts[artyDef]++;
                }
                else
                {
                    data.artilleryCounts.Add(artyDef, 1);
                }
                points -= ThingDefExtension.Get(artyDef).siegeBlueprintPoints;
                i++;
            }
            yield break;
        }
Ejemplo n.º 18
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            Map map = base.Map;

            SmoothableWallUtility.Notify_BuildingDestroying(this, mode);
            base.Destroy(mode);
            InstallBlueprintUtility.CancelBlueprintsFor(this);
            if (mode == DestroyMode.Deconstruct)
            {
                SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            if (Find.PlaySettings.autoRebuild && mode == DestroyMode.KillFinalize && base.Faction == Faction.OfPlayer && this.def != null && this.def.blueprintDef != null && this.def.IsResearchFinished)
            {
                GenConstruct.PlaceBlueprintForBuild(this.def, base.Position, map, base.Rotation, Faction.OfPlayer, base.Stuff);
            }
        }
Ejemplo n.º 19
0
        //public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff)
        public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction)
        {
            if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge)
            {
                return;
            }

            TerrainAffordanceDef affNeeded = sourceDef.terrainAffordanceNeeded;

            foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size))
            {
                if (PlaceBridges.NeedsBridge(sourceDef, pos, map))
                {
                    GenConstruct.PlaceBlueprintForBuild(TerrainDefOf.Bridge, pos, map, rotation, faction, null);
                }
            }
        }
        private static IEnumerable <Blueprint_Build> MakeCoverLine(IntVec3 root, Map map, Rot4 growDir, int maxLength, ThingDef coverThing, ThingDef coverStuff)
        {
            var     placedSandbagLocs = (List <IntVec3>)NonPublicFields.SiegeBlueprintPlacer_placedCoverLocs.GetValue(null);
            IntVec3 cur = root;

            for (int i = 0; i < maxLength; i++)
            {
                if (!NonPublicMethods.SiegeBlueprintPlacer_CanPlaceBlueprintAt(cur, Rot4.North, coverThing, map, coverStuff))
                {
                    break;
                }
                yield return(GenConstruct.PlaceBlueprintForBuild(coverThing, cur, map, Rot4.North, (Faction)NonPublicFields.SiegeBlueprintPlacer_faction.GetValue(null), coverStuff));

                placedSandbagLocs.Add(cur);
                cur += growDir.FacingCell;
            }
            yield break;
        }
        public override void DesignateSingleCell(IntVec3 cell)
        {
            List <Thing> things = cell.GetThingList(Map).FindAll(t => CanReplaceStuffFor(stuffDef, t));

            for (int i = 0; i < things.Count; i++)
            {
                Thing thing = things[i];
                thing.SetFaction(Faction.OfPlayer);
                if (DebugSettings.godMode)
                {
                    ReplaceFrame.FinalizeReplace(thing, stuffDef);
                }
                else
                {
                    Log.Message($"PlaceReplaceFrame on {thing} with {stuffDef}");
                    if (thing is Blueprint_Build blueprint)
                    {
                        blueprint.stuffToUse = stuffDef;
                    }
                    else if (thing is ReplaceFrame replaceFrame)
                    {
                        if (replaceFrame.oldStuff == stuffDef)
                        {
                            replaceFrame.Destroy(DestroyMode.Cancel);
                        }
                        else
                        {
                            replaceFrame.ChangeStuff(stuffDef);
                        }
                    }
                    else if (thing is Frame frame)
                    {
                        GenConstruct.PlaceBlueprintForBuild(frame.def.entityDefToBuild, frame.Position, frame.Map, frame.Rotation, frame.Faction, stuffDef);
                    }
                    else
                    {
                        GenReplace.PlaceReplaceFrame(thing, stuffDef);
                    }
                }
            }
        }
Ejemplo n.º 22
0
        // Token: 0x0600002D RID: 45 RVA: 0x000035EC File Offset: 0x000017EC
        public void PlaceProduct()
        {
            var position = Position;
            var map      = Map;
            var thing    = ThingMaker.MakeThing(ThingDef.Named(compostBinComp.Props.productOne));

            thing.stackCount = compostBinComp.Props.numProductOne;
            GenPlace.TryPlaceThing(thing, position, map, ThingPlaceMode.Near);
            var thing2 = ThingMaker.MakeThing(ThingDef.Named(compostBinComp.Props.productTwo));

            thing2.stackCount = compostBinComp.Props.numProductTwo;
            GenPlace.TryPlaceThing(thing2, position, map, ThingPlaceMode.Near);
            if (def.defName != AYCharcoalKiln)
            {
                var random = new Random();
                var Chance = random.Next(3);
                var num    = random.Next(3);
                if (Chance < 2)
                {
                    GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDef.Named("WoodLog")), position, map,
                                           ThingPlaceMode.Near);
                }

                if (num < 1)
                {
                    GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDef.Named("WoodLog")), position, map,
                                           ThingPlaceMode.Near);
                }
            }

            ThingDef prevStuff = null;

            if (Stuff != null)
            {
                prevStuff = Stuff;
            }

            Destroy();
            GenConstruct.PlaceBlueprintForBuild(ThingDef.Named(def.defName), position, map, Rot4.North,
                                                Faction.OfPlayer, prevStuff);
        }
Ejemplo n.º 23
0
        public void ScheduleReplacement(CompAutoReplaceable replaceableComp)
        {
            var building  = replaceableComp.parent;
            var blueprint = GenConstruct.PlaceBlueprintForBuild(building.def, replaceableComp.ParentPosition, map, replaceableComp.ParentRotation, Faction.OfPlayer, null);
            var entry     = new ReplacementEntry {
                position     = replaceableComp.ParentPosition,
                unforbidTick = Find.TickManager.TicksGame + RemoteExplosivesController.Instance.BlueprintForbidDuration * GenTicks.TicksPerRealSecond
            };
            var explosive = building as Building_RemoteExplosive;

            if (explosive != null)
            {
                entry.armed   = explosive.IsArmed;
                entry.channel = explosive.CurrentChannel;
            }
            pendingSettings.Add(entry);
            if (RemoteExplosivesController.Instance.BlueprintForbidDuration > 0)
            {
                blueprint.SetForbidden(true, false);
                pendingForbiddenBlueprints.Add(entry);
            }
        }
Ejemplo n.º 24
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            if (DebugSettings.godMode || entDef.GetStatValueAbstract(StatDefOf.WorkToBuild, stuffDef) == 0f)
            {
                if (entDef is TerrainDef)
                {
                    base.Map.terrainGrid.SetTerrain(c, (TerrainDef)entDef);
                }
                else
                {
                    Thing thing = ThingMaker.MakeThing((ThingDef)entDef, stuffDef);
                    thing.SetFactionDirect(Faction.OfPlayer);
                    GenSpawn.Spawn(thing, c, base.Map, placingRot);
                }
            }
            else
            {
                GenSpawn.WipeExistingThings(c, placingRot, entDef.blueprintDef, base.Map, DestroyMode.Deconstruct);
                GenConstruct.PlaceBlueprintForBuild(entDef, c, base.Map, placingRot, Faction.OfPlayer, stuffDef);
            }
            MoteMaker.ThrowMetaPuffs(GenAdj.OccupiedRect(c, placingRot, entDef.Size), base.Map);
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.IsOrbitalTradeBeacon)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BuildOrbitalTradeBeacon, KnowledgeAmount.Total);
            }
            if (TutorSystem.TutorialMode)
            {
                TutorSystem.Notify_Event(new EventPack(base.TutorTagDesignate, c));
            }
            if (entDef.PlaceWorkers != null)
            {
                for (int i = 0; i < entDef.PlaceWorkers.Count; i++)
                {
                    entDef.PlaceWorkers[i].PostPlace(base.Map, entDef, c, placingRot);
                }
            }
        }
Ejemplo n.º 25
0
        private void MakeD(int XX1, int ZZ1, int bx, int bz, ThingDef stuff)
        {
            Map map = this.Map;
            int xp, yp;

            if (XX1 > 0)
            {
                xp = 1;
            }
            else
            {
                xp = -1;
            }
            if (ZZ1 > 0)
            {
                yp = 1;
            }
            else
            {
                yp = -1;
            }

            IntVec3 printVec = startpoint;

            while (true)
            {
                printVec.x += xp;
                printVec.z += yp;

                GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Wall, printVec, this.Map, base.Rotation, Faction.OfPlayer, stuff);

                if (printVec.x == bx || printVec.z == bz)
                {
                    return;
                }
            }
            //GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Wall, base.Position, this.Map, base.Rotation, Faction.OfPlayer, ThingDefOf.WoodLog);
        }
Ejemplo n.º 26
0
        public Terrain_Action(Zone_Growing growingZone, TerrainDef terrainDef)
        {
            defaultLabel = terrainDef.label;
            defaultDesc  = string.Format("twYAAM_Gizmo_Description".Translate(), defaultLabel);
            icon         = ContentFinder <Texture2D> .Get(terrainDef.texturePath + "UI");

            action = delegate
            {
                Map map = growingZone.Map;
                foreach (IntVec3 cell in growingZone.Cells)
                {
                    if (map.terrainGrid.TerrainAt(cell).fertility >= terrainDef.fertility)
                    {
                        continue;
                    }
                    Blueprint_Build blueprint_Build = GenConstruct.PlaceBlueprintForBuild(terrainDef, cell, map, Rot4.North, Faction.OfPlayer, null);
                    if (blueprint_Build == null)
                    {
                        Verse.Log.Warning("tw_YAMM.Terrain_Action failed for " + terrainDef.defName + " in " + growingZone.label);
                    }
                }
            };
        }
        //public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff)
        public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction)
        {
            if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge)
            {
                return;
            }

            TerrainAffordanceDef affNeeded = sourceDef.terrainAffordanceNeeded;

            foreach (IntVec3 cell in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size))
            {
                if (cell.SupportsStructureType(map, affNeeded))
                {
                    continue;
                }


                if (cell.SupportsStructureType(map, TerrainDefOf.Bridge.terrainAffordanceNeeded) &&
                    TerrainDefOf.Bridge.affordances.Contains(affNeeded))
                {
                    GenConstruct.PlaceBlueprintForBuild(TerrainDefOf.Bridge, cell, map, rotation, faction, null);
                }
            }
        }
Ejemplo n.º 28
0
 public static Blueprint PlaceBlueprint(ThingDef def, IntVec3 spot, Rot4 rotation = default(Rot4), ThingDef stuff = null)
 {
     return(GenConstruct.PlaceBlueprintForBuild(def, spot, info.map, rotation, info.currentLord.faction, stuff));
 }
Ejemplo n.º 29
0
        private void MakeFC(int XX1, int ZZ1, int bx, int bz, ThingDef stuff)
        {
            Map map = this.Map;

            //Verse.Log.Message(XX1 + " " + ZZ1);
            int Radius = (int)Math.Round(Math.Sqrt(XX1 * XX1 + ZZ1 * ZZ1));


            //Verse.Log.Message("Radius : " + Radius);
            int FHD = Radius * 2 + 1;//Radius * 2 + 1;

            /*
             * int LLL = bx - Radius;
             * int RRR = bx + Radius;
             * int BBB = bz - Radius;
             * int UUU = bz + Radius;
             *
             * if (LLL < 0)
             * {
             *  LLL = 0;
             * }
             * if (BBB < 0)
             * {
             *  BBB = 0;
             * }
             * if (RRR > map.Size.x)
             * {
             *  RRR = map.Size.x;
             * }
             * if (UUU > map.Size.z)
             * {
             *  UUU = map.Size.z;
             * }
             */

            //int x = 0; int y = (int)Math.Ceiling(Radius);
            IntVec3 printVec;
            //bool[,] grid = new bool[FHD, FHD];
            int y = 0;
            int x = 0;

            for (y = 0; y < FHD; y++)
            {
                for (x = 0; x < FHD; x++)
                {
                    if ((bx - Radius + x) < 0 || (bx - Radius + x) >= map.Size.x)
                    {
                        continue;
                    }
                    else if ((bz - Radius + y) < 0 || bz - Radius + y >= map.Size.z)
                    {
                        continue;
                    }

                    if (is_ellipse(Radius, x - (Radius), y - (Radius))) // 체크!
                    {
                        // 블루프린트 설치
                        //grid[y, x] = true;
                        printVec   = this.Position;
                        printVec.x = bx - Radius + x;
                        printVec.z = bz - Radius + y;

                        //Messages.Message(bx + "  " + x  + "  " + bz + "  "+y+ "bphere"+ "  "+ "pv" + printVec.x + " " + printVec.z + " " + Radius + " " + FHD, MessageTypeDefOf.NeutralEvent);

                        GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Wall, printVec, this.Map, base.Rotation, Faction.OfPlayer, stuff);
                    }
                }
            }
            //GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Wall, base.Position, this.Map, base.Rotation, Faction.OfPlayer, ThingDefOf.WoodLog);
        }
Ejemplo n.º 30
0
        public override void DesignateSingleCell(IntVec3 cell)
        {
            List <Thing> things = cell.GetThingList(Map).FindAll(t => CanReplaceStuffFor(stuffDef, t));

            for (int i = 0; i < things.Count; i++)
            {
                Thing thing = things[i];
                thing.SetFaction(Faction.OfPlayer);

                //In case you're replacing with a stuff that needs a higher affordance that bridges can handle.
                PlaceBridges.EnsureBridge.PlaceBridgeIfNeeded(thing.def, thing.Position, Map, thing.Rotation, Faction.OfPlayer, stuffDef);

                if (DebugSettings.godMode)
                {
                    ReplaceFrame.FinalizeReplace(thing, stuffDef);
                }
                else
                {
                    Log.Message($"PlaceReplaceFrame on {thing} with {stuffDef}");
                    if (thing is Blueprint_Build blueprint)
                    {
                        blueprint.stuffToUse = stuffDef;
                    }
                    else if (thing is ReplaceFrame replaceFrame)
                    {
                        if (replaceFrame.oldStuff == stuffDef)
                        {
                            replaceFrame.Destroy(DestroyMode.Cancel);
                        }
                        else
                        {
                            replaceFrame.ChangeStuff(stuffDef);

                            //Interrupt any workers - they don't have the required new stuff
                            if (replaceFrame.Map.mapPawns.FreeColonists.First() is Pawn sampleColonist &&
                                replaceFrame.Map.reservationManager.FirstRespectedReserver(replaceFrame, sampleColonist) is Pawn worker)
                            {
                                if (worker.CurJob.def == JobDefOf.FinishFrame &&
                                    worker.CurJob.targetA == replaceFrame)
                                {
                                    worker.jobs.EndCurrentJob(JobCondition.InterruptForced);
                                }

                                for (int jobI = worker.jobs.jobQueue.Count - 1; jobI >= 0; jobI--)
                                {
                                    Job qJob = worker.jobs.jobQueue[jobI].job;
                                    if (qJob.def == JobDefOf.FinishFrame &&
                                        qJob.targetA == replaceFrame)
                                    {
                                        worker.jobs.EndCurrentOrQueuedJob(qJob, JobCondition.InterruptForced);
                                    }
                                }
                            }
                        }
                    }
                    else if (thing is Frame frame)
                    {
                        GenConstruct.PlaceBlueprintForBuild(frame.def.entityDefToBuild, frame.Position, frame.Map, frame.Rotation, frame.Faction, stuffDef);
                    }
                    else
                    {
                        GenReplace.PlaceReplaceFrame(thing, stuffDef);
                    }
                }
            }
        }