public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!(signal.tag == inSignal))
            {
                return;
            }
            copy = null;
            MonumentMarker arg = signal.args.GetArg <MonumentMarker>("SUBJECT");

            if (arg != null && mapParent != null && mapParent.HasMap)
            {
                Map     map        = mapParent.Map;
                IntVec3 dropCenter = DropCellFinder.RandomDropSpot(map);
                copy        = (MonumentMarker)ThingMaker.MakeThing(ThingDefOf.MonumentMarker);
                copy.sketch = arg.sketch.DeepCopy();
                if (!arg.questTags.NullOrEmpty())
                {
                    copy.questTags = new List <string>();
                    copy.questTags.AddRange(arg.questTags);
                }
                DropPodUtility.DropThingsNear(dropCenter, map, Gen.YieldSingle((Thing)copy.MakeMinified()), 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: true, forbid: false);
            }
            if (!outSignalResult.NullOrEmpty())
            {
                if (copy != null)
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult, copy.Named("SUBJECT")));
                }
                else
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult));
                }
            }
        }
Esempio n. 2
0
        public static Gizmo GetSelectMonumentMarkerGizmo(Thing thing)
        {
            if (!thing.Spawned || !ModsConfig.RoyaltyActive)
            {
                return(null);
            }
            List <Thing> list = thing.Map.listerThings.ThingsOfDef(ThingDefOf.MonumentMarker);

            for (int j = 0; j < list.Count; j++)
            {
                MonumentMarker i = (MonumentMarker)list[j];
                if (i.IsPart(thing))
                {
                    return(new Command_Action
                    {
                        defaultLabel = "CommandSelectMonumentMarker".Translate(),
                        defaultDesc = "CommandSelectMonumentMarkerDesc".Translate(),
                        icon = ThingDefOf.MonumentMarker.uiIcon,
                        iconAngle = ThingDefOf.MonumentMarker.uiIconAngle,
                        iconOffset = ThingDefOf.MonumentMarker.uiIconOffset,
                        action = delegate
                        {
                            CameraJumper.TrySelect(i);
                        }
                    });
                }
            }
            return(null);
        }
Esempio n. 3
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            if (!AllDone)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandCancelMonumentMarker".Translate();
                command_Action.defaultDesc  = "CommandCancelMonumentMarkerDesc".Translate();
                command_Action.icon         = CancelCommandTex;
                command_Action.action       = delegate
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmCancelMonumentMarker".Translate(), delegate
                    {
                        QuestUtility.SendQuestTargetSignals(questTags, "MonumentCancelled", this.Named("SUBJECT"));
                        RemovePossiblyRelatedBlueprints();
                        this.Uninstall();
                    }, destructive: true));
                };
                yield return(command_Action);
            }
            bool flag = false;

            foreach (SketchEntity entity in sketch.Entities)
            {
                SketchBuildable sketchBuildable = entity as SketchBuildable;
                if (sketchBuildable != null && !entity.IsSameSpawnedOrBlueprintOrFrame(entity.pos + base.Position, base.Map) && !entity.IsSpawningBlocked(entity.pos + base.Position, base.Map) && BuildCopyCommandUtility.FindAllowedDesignator(sketchBuildable.Buildable) != null)
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                Command_Action command_Action2 = new Command_Action();
                command_Action2.defaultLabel = "CommandPlaceBlueprints".Translate();
                command_Action2.defaultDesc  = "CommandPlaceBlueprintsDesc".Translate();
                command_Action2.icon         = PlaceBlueprintsCommandTex;
                MonumentMarker monumentMarker = default(MonumentMarker);
                ThingDef       stuffLocal     = default(ThingDef);
                command_Action2.action = delegate
                {
                    IEnumerable <ThingDef> enumerable = AllowedStuffs();
                    if (!enumerable.Any())
                    {
                        PlaceAllBlueprints(null);
                        SoundDefOf.Click.PlayOneShotOnCamera();
                    }
                    else if (enumerable.Count() == 1)
                    {
                        PlaceAllBlueprints(enumerable.First());
                        SoundDefOf.Click.PlayOneShotOnCamera();
                    }
                    else
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();
                        bool flag4 = false;
                        foreach (ThingDef item in enumerable)
                        {
                            if (base.Map.listerThings.ThingsOfDef(item).Count > 0)
                            {
                                flag4 = true;
                                break;
                            }
                        }
                        foreach (ThingDef item2 in enumerable)
                        {
                            monumentMarker = this;
                            if (!flag4 || base.Map.listerThings.ThingsOfDef(item2).Count != 0)
                            {
                                stuffLocal = item2;
                                list.Add(new FloatMenuOption(stuffLocal.LabelCap, delegate
                                {
                                    monumentMarker.PlaceAllBlueprints(stuffLocal);
                                }, item2));
                            }
                        }
                        Find.WindowStack.Add(new FloatMenu(list));
                    }
                };
                yield return(command_Action2);
            }
            foreach (Gizmo questRelatedGizmo in QuestUtility.GetQuestRelatedGizmos(this))
            {
                yield return(questRelatedGizmo);
            }
            if (Prefs.DevMode)
            {
                bool flag2 = false;
                foreach (SketchEntity entity2 in sketch.Entities)
                {
                    if (!entity2.IsSameSpawned(entity2.pos + base.Position, base.Map) && !entity2.IsSpawningBlocked(entity2.pos + base.Position, base.Map))
                    {
                        flag2 = true;
                        break;
                    }
                }
                if (flag2)
                {
                    Command_Action command_Action3 = new Command_Action();
                    command_Action3.defaultLabel = "Dev: Build all";
                    command_Action3.action       = delegate
                    {
                        DebugBuildAll();
                        SoundDefOf.Click.PlayOneShotOnCamera();
                    };
                    yield return(command_Action3);
                }
            }
            tmpUniqueBuildableDefs.Clear();
            foreach (SketchEntity entity3 in sketch.Entities)
            {
                SketchBuildable sketchBuildable2 = entity3 as SketchBuildable;
                if (sketchBuildable2 != null && !entity3.IsSameSpawnedOrBlueprintOrFrame(entity3.pos + base.Position, base.Map) && tmpUniqueBuildableDefs.Add(new Pair <BuildableDef, ThingDef>(sketchBuildable2.Buildable, sketchBuildable2.Stuff)))
                {
                    SketchTerrain sketchTerrain;
                    if ((sketchTerrain = (sketchBuildable2 as SketchTerrain)) != null && sketchTerrain.treatSimilarAsSame)
                    {
                        TerrainDef terrain = sketchBuildable2.Buildable as TerrainDef;
                        if (terrain.designatorDropdown != null)
                        {
                            Designator designator = BuildCopyCommandUtility.FindAllowedDesignatorRoot(sketchBuildable2.Buildable);
                            if (designator != null)
                            {
                                yield return(designator);
                            }
                        }
                        else
                        {
                            IEnumerable <TerrainDef> allDefs = DefDatabase <TerrainDef> .AllDefs;
                            foreach (TerrainDef item3 in allDefs)
                            {
                                if (item3.BuildableByPlayer && item3.designatorDropdown == null)
                                {
                                    bool flag3 = true;
                                    for (int i = 0; i < terrain.affordances.Count; i++)
                                    {
                                        if (!item3.affordances.Contains(terrain.affordances[i]))
                                        {
                                            flag3 = false;
                                            break;
                                        }
                                    }
                                    if (flag3)
                                    {
                                        Command command = BuildCopyCommandUtility.BuildCommand(item3, null, item3.label, item3.description, allowHotKey: false);
                                        if (command != null)
                                        {
                                            yield return(command);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Command command2 = BuildCopyCommandUtility.BuildCommand(sketchBuildable2.Buildable, sketchBuildable2.Stuff, entity3.Label, sketchBuildable2.Buildable.description, allowHotKey: false);
                        if (command2 != null)
                        {
                            yield return(command2);
                        }
                    }
                }
            }
            tmpUniqueBuildableDefs.Clear();
        }
Esempio n. 4
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            MonumentMarker monumentMarker = thing as MonumentMarker;

            if (monumentMarker != null)
            {
                CellRect          rect           = monumentMarker.sketch.OccupiedRect.MovedBy(loc);
                Blueprint_Install thingToIgnore2 = monumentMarker.FindMyBlueprint(rect, map);
                foreach (SketchEntity entity in monumentMarker.sketch.Entities)
                {
                    CellRect cellRect = entity.OccupiedRect.MovedBy(loc);
                    if (!cellRect.InBounds(map))
                    {
                        return(false);
                    }
                    if (cellRect.InNoBuildEdgeArea(map))
                    {
                        return("TooCloseToMapEdge".Translate());
                    }
                    foreach (IntVec3 item in cellRect)
                    {
                        if (!entity.CanBuildOnTerrain(item, map))
                        {
                            TerrainDef terrain = item.GetTerrain(map);
                            return("CannotPlaceMonumentOnTerrain".Translate(terrain.LabelCap));
                        }
                    }
                }
                tmpMonumentThings.Clear();
                foreach (SketchBuildable buildable in monumentMarker.sketch.Buildables)
                {
                    Thing       spawnedBlueprintOrFrame = buildable.GetSpawnedBlueprintOrFrame(loc + buildable.pos, map);
                    SketchThing sketchThing;
                    if (spawnedBlueprintOrFrame != null)
                    {
                        tmpMonumentThings.Add(spawnedBlueprintOrFrame);
                    }
                    else if ((sketchThing = buildable as SketchThing) != null)
                    {
                        Thing sameSpawned = sketchThing.GetSameSpawned(loc + sketchThing.pos, map);
                        if (sameSpawned != null)
                        {
                            tmpMonumentThings.Add(sameSpawned);
                        }
                    }
                }
                foreach (SketchEntity entity2 in monumentMarker.sketch.Entities)
                {
                    if (entity2.IsSameSpawnedOrBlueprintOrFrame(loc + entity2.pos, map))
                    {
                        continue;
                    }
                    foreach (IntVec3 item2 in entity2.OccupiedRect.MovedBy(loc))
                    {
                        if (item2.InBounds(map))
                        {
                            Building firstBuilding = item2.GetFirstBuilding(map);
                            if (firstBuilding != null && !tmpMonumentThings.Contains(firstBuilding))
                            {
                                tmpMonumentThings.Clear();
                                return("CannotPlaceMonumentOver".Translate(firstBuilding.LabelCap));
                            }
                        }
                    }
                    SketchBuildable sketchBuildable;
                    if ((sketchBuildable = entity2 as SketchBuildable) != null)
                    {
                        Thing thing2 = sketchBuildable.FirstPermanentBlockerAt(loc + entity2.pos, map);
                        if (thing2 != null && !tmpMonumentThings.Contains(thing2))
                        {
                            tmpMonumentThings.Clear();
                            return("CannotPlaceMonumentOver".Translate(thing2.LabelCap));
                        }
                    }
                }
                foreach (SketchEntity entity3 in monumentMarker.sketch.Entities)
                {
                    Building firstAdjacentBuilding = MonumentMarkerUtility.GetFirstAdjacentBuilding(entity3, loc, tmpMonumentThings, map);
                    if (firstAdjacentBuilding != null)
                    {
                        return("MonumentAdjacentToBuilding".Translate(firstAdjacentBuilding.LabelCap));
                    }
                    if (entity3.IsSpawningBlockedPermanently(loc + entity3.pos, map, thingToIgnore2))
                    {
                        tmpMonumentThings.Clear();
                        return("MonumentBlockedPermanently".Translate());
                    }
                }
                tmpMonumentThings.Clear();
            }
            return(true);
        }
Esempio n. 5
0
        public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null)
        {
            CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size);

            if (stuffDef == null && thing != null)
            {
                stuffDef = thing.Stuff;
            }
            foreach (IntVec3 item in cellRect)
            {
                if (!item.InBounds(map))
                {
                    return(new AcceptanceReport("OutOfBounds".Translate()));
                }
                if (item.InNoBuildEdgeArea(map) && !godMode)
                {
                    return("TooCloseToMapEdge".Translate());
                }
            }
            if (center.Fogged(map))
            {
                return("CannotPlaceInUndiscovered".Translate());
            }
            List <Thing> thingList = center.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing2 = thingList[i];
                if (thing2 == thingToIgnore || !(thing2.Position == center) || !(thing2.Rotation == rot))
                {
                    continue;
                }
                if (thing2.def == entDef)
                {
                    return(new AcceptanceReport("IdenticalThingExists".Translate()));
                }
                if (thing2.def.entityDefToBuild == entDef)
                {
                    if (thing2 is Blueprint)
                    {
                        return(new AcceptanceReport("IdenticalBlueprintExists".Translate()));
                    }
                    return(new AcceptanceReport("IdenticalThingExists".Translate()));
                }
            }
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.hasInteractionCell)
            {
                IntVec3 c = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map);
                if (!c.InBounds(map))
                {
                    return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate()));
                }
                List <Thing> list = map.thingGrid.ThingsListAtFast(c);
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j] != thingToIgnore)
                    {
                        if (list[j].def.passability == Traversability.Impassable || list[j].def == thingDef)
                        {
                            return(new AcceptanceReport("InteractionSpotBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                        }
                        BuildableDef entityDefToBuild = list[j].def.entityDefToBuild;
                        if (entityDefToBuild != null && (entityDefToBuild.passability == Traversability.Impassable || entityDefToBuild == thingDef))
                        {
                            return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                        }
                    }
                }
            }
            foreach (IntVec3 item2 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size))
            {
                if (item2.InBounds(map))
                {
                    thingList = item2.GetThingList(map);
                    for (int k = 0; k < thingList.Count; k++)
                    {
                        Thing thing3 = thingList[k];
                        if (thing3 != thingToIgnore)
                        {
                            ThingDef  thingDef2 = null;
                            Blueprint blueprint = thing3 as Blueprint;
                            if (blueprint != null)
                            {
                                ThingDef thingDef3 = blueprint.def.entityDefToBuild as ThingDef;
                                if (thingDef3 == null)
                                {
                                    continue;
                                }
                                thingDef2 = thingDef3;
                            }
                            else
                            {
                                thingDef2 = thing3.def;
                            }
                            if (thingDef2.hasInteractionCell && (entDef.passability == Traversability.Impassable || entDef == thingDef2) && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef2, thing3.Position, thing3.Rotation, thing3.Map)))
                            {
                                return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(entDef.label, thingDef2.label).CapitalizeFirst()));
                            }
                        }
                    }
                }
            }
            TerrainDef terrainDef = entDef as TerrainDef;

            if (terrainDef != null)
            {
                if (map.terrainGrid.TerrainAt(center) == terrainDef)
                {
                    return(new AcceptanceReport("TerrainIsAlready".Translate(terrainDef.label)));
                }
                if (map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null)
                {
                    return(new AcceptanceReport("SpaceBeingSmoothed".Translate()));
                }
            }
            if (!CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore, stuffDef))
            {
                if (entDef.GetTerrainAffordanceNeed(stuffDef) != null)
                {
                    if (entDef.useStuffTerrainAffordance && stuffDef != null)
                    {
                        return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordanceFromStuff".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef), stuffDef).CapitalizeFirst()));
                    }
                    return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef)).CapitalizeFirst()));
                }
                return(new AcceptanceReport("TerrainCannotSupport".Translate(entDef).CapitalizeFirst()));
            }
            if (ModsConfig.RoyaltyActive)
            {
                List <Thing> list2 = map.listerThings.ThingsOfDef(ThingDefOf.MonumentMarker);
                for (int l = 0; l < list2.Count; l++)
                {
                    MonumentMarker monumentMarker = (MonumentMarker)list2[l];
                    if (!monumentMarker.complete && !monumentMarker.AllowsPlacingBlueprint(entDef, center, rot, stuffDef))
                    {
                        return(new AcceptanceReport("BlueprintWouldCollideWithMonument".Translate()));
                    }
                }
            }
            if (!godMode)
            {
                foreach (IntVec3 item3 in cellRect)
                {
                    thingList = item3.GetThingList(map);
                    for (int m = 0; m < thingList.Count; m++)
                    {
                        Thing thing4 = thingList[m];
                        if (thing4 != thingToIgnore && !CanPlaceBlueprintOver(entDef, thing4.def))
                        {
                            return(new AcceptanceReport("SpaceAlreadyOccupied".Translate()));
                        }
                    }
                }
            }
            if (entDef.PlaceWorkers != null)
            {
                for (int n = 0; n < entDef.PlaceWorkers.Count; n++)
                {
                    AcceptanceReport result = entDef.PlaceWorkers[n].AllowsPlacing(entDef, center, rot, map, thingToIgnore, thing);
                    if (!result.Accepted)
                    {
                        return(result);
                    }
                }
            }
            return(AcceptanceReport.WasAccepted);
        }
Esempio n. 6
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            MonumentMarker monumentMarker = thing as MonumentMarker;

            if (monumentMarker != null)
            {
                CellRect          rect           = monumentMarker.sketch.OccupiedRect.MovedBy(loc);
                Blueprint_Install thingToIgnore2 = monumentMarker.FindMyBlueprint(rect, map);
                foreach (SketchEntity entity in monumentMarker.sketch.Entities)
                {
                    CellRect cellRect = entity.OccupiedRect.MovedBy(loc);
                    if (!cellRect.InBounds(map))
                    {
                        return(false);
                    }
                    if (cellRect.InNoBuildEdgeArea(map))
                    {
                        return("TooCloseToMapEdge".Translate());
                    }
                    foreach (IntVec3 item in cellRect)
                    {
                        if (!entity.CanBuildOnTerrain(item, map))
                        {
                            return("MonumentBadTerrain".Translate());
                        }
                    }
                    if (entity.IsSpawningBlockedPermanently(loc + entity.pos, map, thingToIgnore2))
                    {
                        return("MonumentBlockedPermanently".Translate());
                    }
                }
                tmpMonumentThings.Clear();
                foreach (SketchBuildable buildable in monumentMarker.sketch.Buildables)
                {
                    Thing       spawnedBlueprintOrFrame = buildable.GetSpawnedBlueprintOrFrame(loc + buildable.pos, map);
                    SketchThing sketchThing;
                    if (spawnedBlueprintOrFrame != null)
                    {
                        tmpMonumentThings.Add(spawnedBlueprintOrFrame);
                    }
                    else if ((sketchThing = (buildable as SketchThing)) != null)
                    {
                        Thing sameSpawned = sketchThing.GetSameSpawned(loc + sketchThing.pos, map);
                        if (sameSpawned != null)
                        {
                            tmpMonumentThings.Add(sameSpawned);
                        }
                    }
                }
                foreach (SketchEntity entity2 in monumentMarker.sketch.Entities)
                {
                    if (!entity2.IsSameSpawnedOrBlueprintOrFrame(loc + entity2.pos, map))
                    {
                        foreach (IntVec3 item2 in entity2.OccupiedRect.MovedBy(loc))
                        {
                            if (item2.InBounds(map))
                            {
                                Building firstBuilding = item2.GetFirstBuilding(map);
                                if (firstBuilding != null && !tmpMonumentThings.Contains(firstBuilding))
                                {
                                    tmpMonumentThings.Clear();
                                    return("MonumentOverlapsBuilding".Translate());
                                }
                            }
                        }
                    }
                }
                foreach (SketchEntity entity3 in monumentMarker.sketch.Entities)
                {
                    if (!entity3.IsSameSpawnedOrBlueprintOrFrame(loc + entity3.pos, map))
                    {
                        foreach (IntVec3 edgeCell in entity3.OccupiedRect.MovedBy(loc).ExpandedBy(1).EdgeCells)
                        {
                            if (edgeCell.InBounds(map))
                            {
                                Building firstBuilding2 = edgeCell.GetFirstBuilding(map);
                                if (firstBuilding2 != null && !tmpMonumentThings.Contains(firstBuilding2) && (firstBuilding2.Faction == null || firstBuilding2.Faction == Faction.OfPlayer))
                                {
                                    tmpMonumentThings.Clear();
                                    return("MonumentAdjacentToBuilding".Translate());
                                }
                            }
                        }
                    }
                }
                tmpMonumentThings.Clear();
            }
            return(true);
        }