コード例 #1
0
        private static MinifiedThing GetClosestCandidate(BuildableDef sourceDef, IntVec3 center, Map map, Faction faction, ThingDef stuff)
        {
            var settings = UseMinifiedBuildings.Settings;
            var matches  = map.listerThings.ThingsOfDef(ThingDefOf.MinifiedThing).OfType <MinifiedThing>()
                           .Where(m => m.InnerThing.def == sourceDef && m.InnerThing.Stuff == stuff &&
                                  !m.IsForbidden(faction) &&
                                  InstallBlueprintUtility.ExistingBlueprintFor(m) == null &&
                                  (!m.TryGetQuality(out QualityCategory qc) || (settings.EnableForQualityBuildings && qc >= settings.GetMinQuality(sourceDef.frameDef, map))))
                           .ToList();

            var           minDist = int.MaxValue;
            MinifiedThing closest = null;

            foreach (var t in matches)
            {
                var dist = IntVec3Utility.ManhattanDistanceFlat(center, t.Position);
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = t;
                }
            }

            return(settings.IsTooFar(minDist) ? null : closest);
        }
コード例 #2
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            bool spawned = base.Spawned;
            Map  map     = base.Map;

            SmoothableWallUtility.Notify_BuildingDestroying(this, mode);
            this.GetLord()?.Notify_BuildingLost(this);
            base.Destroy(mode);
            InstallBlueprintUtility.CancelBlueprintsFor(this);
            if (spawned)
            {
                switch (mode)
                {
                case DestroyMode.Deconstruct:
                    SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(base.Position, map));
                    break;

                case DestroyMode.KillFinalize:
                    DoDestroyEffects(map);
                    break;
                }
            }
            if (spawned)
            {
                ThingUtility.CheckAutoRebuildOnDestroyed(this, mode, map, def);
            }
        }
コード例 #3
0
        // 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);
            }
        }
コード例 #4
0
 public static void Postfix(Designation __instance)
 {
     if (__instance.def == MoveBaseDefOf.MoveBase && __instance.target.Thing != null)
     {
         DesignatorMoveBase.Notify_Removing_Callback(__instance.target.Thing);
         InstallBlueprintUtility.CancelBlueprintsFor(__instance.target.Thing);
     }
 }
コード例 #5
0
 public static bool UseableBed(Thing miniThing, Pawn pawn)
 {
     return(miniThing.GetInnerIfMinified() is Building_Bed b &&
            !b.def.building.bed_defaultMedical &&
            RestUtility.CanUseBedEver(pawn, b.def) &&
            !CaravanReserved(pawn, miniThing) &&
            InstallBlueprintUtility.ExistingBlueprintFor(miniThing) == null);
 }
コード例 #6
0
ファイル: Building.cs プロジェクト: sachdevs/RW-Decompile
        public override void DrawExtraSelectionOverlays()
        {
            base.DrawExtraSelectionOverlays();
            Blueprint_Install blueprint_Install = InstallBlueprintUtility.ExistingBlueprintFor(this);

            if (blueprint_Install != null)
            {
                GenDraw.DrawLineBetween(this.TrueCenter(), blueprint_Install.TrueCenter());
            }
        }
コード例 #7
0
ファイル: Building.cs プロジェクト: sachdevs/RW-Decompile
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            Map map = base.Map;

            base.Destroy(mode);
            InstallBlueprintUtility.CancelBlueprintsFor(this);
            if (mode == DestroyMode.Deconstruct)
            {
                SoundDef.Named("BuildingDeconstructed").PlayOneShot(new TargetInfo(base.Position, map, false));
            }
        }
コード例 #8
0
 public static void DesignateThingPrefix(Designator __instance, Thing t)
 {
     if (__instance is Designator_Cancel cancel)
     {
         if (t.MapHeld.designationManager.DesignationOn(t, MoveBaseDefOf.MoveBase) != null)
         {
             DesignatorMoveBase.Notify_Removing_Callback(t);
             InstallBlueprintUtility.CancelBlueprintsFor(t);
         }
     }
 }
コード例 #9
0
 public static void DesignateSingleCellPrefix(Designator __instance, IntVec3 c)
 {
     if (__instance is Designator_Cancel cancel)
     {
         foreach (Thing thing in c.GetThingList(__instance.Map))
         {
             if (thing.MapHeld.designationManager.DesignationOn(thing, MoveBaseDefOf.MoveBase) != null)
             {
                 DesignatorMoveBase.Notify_Removing_Callback(thing);
                 InstallBlueprintUtility.CancelBlueprintsFor(thing);
             }
         }
     }
 }
コード例 #10
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);
            }
        }
コード例 #11
0
ファイル: Building.cs プロジェクト: wensincai/RW-Decompile
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            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 (spawned)
            {
                ThingUtility.CheckAutoRebuildOnDestroyed(this, mode, map, this.def);
            }
        }
コード例 #12
0
        //Altered the vanilla Destroy method from Building, so that it allows proper destruction of assets to this turret.
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            base.Destroy(mode);
            InstallBlueprintUtility.CancelBlueprintsFor((Thing)this);

            if (!this.selfLight.DestroyedOrNull())
            {
                this.selfLight = null;
            }
            if (!this.searchLight.DestroyedOrNull())
            {
                this.searchLight = null;
            }

            if (mode != DestroyMode.Deconstruct)
            {
                return;
            }
            SoundStarter.PlayOneShot(SoundDef.Named("BuildingDeconstructed"), new TargetInfo(Position, Map, false));
        }
コード例 #13
0
        public override Job FurnitureJob(Pawn pawn, Building_Bed myBed, Room myRoom)
        {
            if (myRoom == null)
            {
                return(null);
            }

            var movable = new List <Thing>();

            foreach (var thing in myRoom.ContainedAndAdjacentThings)
            {
                if (thing.def.Minifiable &&
                    pawn.CanReserve(thing) &&
                    InstallBlueprintUtility.ExistingBlueprintFor(thing) == null)
                {
                    movable.Add(thing);
                    //consider moving it
                }
            }

            var cells = myRoom.CellsNotNextToDoorCardinal();

            foreach (var thing in movable.InRandomOrder())
            {
                if (thing is Building_Bed)
                {
                    continue;
                }

                if (thing.PlaceThing(pawn, cells,
                                     thing.def.rotatable ? Rot4.Random : Rot4.North,
                                     myRoom, out var furnitureJob1))
                {
                    return(furnitureJob1);
                }
            }

            return(null);
        }
コード例 #14
0
ファイル: Building.cs プロジェクト: woomy144/Rimworld
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            bool wasSpawned = Spawned;
            var  map        = Map; // before Destroy()!

            // before Destroy(); the math is easier to do here
            SmoothableWallUtility.Notify_BuildingDestroying(this, mode);

            base.Destroy(mode);

            // (buildings can be reinstalled)
            InstallBlueprintUtility.CancelBlueprintsFor(this);

            if (mode == DestroyMode.Deconstruct && wasSpawned)
            {
                SoundDefOf.Building_Deconstructed.PlayOneShot(new TargetInfo(Position, map));
            }

            if (wasSpawned)
            {
                ThingUtility.CheckAutoRebuildOnDestroyed(this, mode, map, def);
            }
        }
コード例 #15
0
 private static bool NoPlans(Thing x)
 {
     return(InstallBlueprintUtility.ExistingBlueprintFor(x) == null);
 }