示例#1
0
            private static bool Prefix(TradeShip __instance, Thing toGive, int countToGive, Pawn playerNegotiator, List <Pawn> ___soldPrisoners)
            {
                if (__instance.Map != null)
                {
                    MapParent_PocketDimension mapParent = __instance.Map.info.parent as MapParent_PocketDimension;
                    if (mapParent != null)
                    {
                        Map containingMap = PocketDimensionUtility.GetHighestContainingMap(__instance.Map);

                        // If there was no containing map found (should mean box is in a caravan; could mean the box was nested inside itself, it which case, oh well, give them their goods anyway :P)
                        if (containingMap == __instance.Map)
                        {
                            Building_PocketDimensionExit exit = PocketDimensionUtility.GetExit(mapParent.dimensionSeed);
                            if (exit != null && exit.SpawnedOrAnyParentSpawned)
                            {
                                Thing thing = toGive.SplitOff(countToGive);
                                thing.PreTraded(TradeAction.PlayerBuys, playerNegotiator, __instance);
                                Pawn pawn = thing as Pawn;
                                if (pawn != null)
                                {
                                    ___soldPrisoners.Remove(pawn);
                                }

                                IntVec3 positionHeld = exit.PositionHeld;
                                Map     mapHeld      = exit.MapHeld;
                                GenPlace.TryPlaceThing(thing, positionHeld, mapHeld, ThingPlaceMode.Near);
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
        private void EqualizeTemperatures()
        {
            Building_PocketDimensionExit exit = PocketDimensionUtility.GetExit(this.dimensionSeed);

            if (exit == null)
            {
                return;
            }
            // If the exits vent is not open it means we are loading an old save from before the vents were on both side and synced, so just close the vent to fix
            else if (!exit.VentOpen)
            {
                SetVentOpen(false);
                return;
            }


            RoomGroup thisRoomGroup  = this.GetRoomGroup();
            RoomGroup otherRoomGroup = exit.GetRoomGroup();

            if (thisRoomGroup == null || otherRoomGroup == null || thisRoomGroup == otherRoomGroup)
            {
                return;
            }

            float totalTemperature   = thisRoomGroup.Temperature + otherRoomGroup.Temperature;
            float averageTemperature = totalTemperature / 2.0f;

            float thisRoomChangeAmount    = this.GetTemperatureChangeAmount(thisRoomGroup, averageTemperature);
            float otherRoomChangeAmount   = this.GetTemperatureChangeAmount(otherRoomGroup, averageTemperature);
            float temperatureChangeAmount = Mathf.Min(thisRoomChangeAmount, otherRoomChangeAmount);

            EqualizeTemperatureForRoom(thisRoomGroup, averageTemperature, temperatureChangeAmount);
            EqualizeTemperatureForRoom(otherRoomGroup, averageTemperature, temperatureChangeAmount);
        }
示例#3
0
        protected override void SetName(string name)
        {
            Building_PocketDimensionBox  box  = PocketDimensionUtility.GetBox(buildingSeed);
            Building_PocketDimensionExit exit = PocketDimensionUtility.GetExit(buildingSeed);

            if (box != null)
            {
                box.uniqueName = curName;
            }
            if (exit != null)
            {
                exit.uniqueName = "CM_PocketDimension_ExitName".Translate(curName);
            }

            Messages.Message("CM_RenamePocketDimensionMessage".Translate(curName), MessageTypeDefOf.TaskCompletion);
        }
示例#4
0
        public void Abandon(bool lost)
        {
            if (!this.shouldBeDeleted)
            {
                TaggedString label = "CM_PocketDimensionDestroyedLetterLabel".Translate();
                TaggedString text  = "CM_PocketDimensionDestroyedLetterText".Translate();

                if (lost)
                {
                    label = "CM_PocketDimensionLostLetterLabel".Translate();
                    text  = "CM_PocketDimensionLostLetterText".Translate();
                }

                Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(this.dimensionSeed);
                if (box != null && !box.BeingDestroyed)
                {
                    Thing thingHolder = box.SpawnedParentOrMe;
                    if (thingHolder != null)
                    {
                        LookTargets lookTarget = new LookTargets(thingHolder.Position, thingHolder.Map);
                        Find.LetterStack.ReceiveLetter(label, text, PocketDimensionDefOf.CM_PocketDimensionBreachedLetter, lookTarget);
                    }
                    else
                    {
                        Find.LetterStack.ReceiveLetter(label, text, PocketDimensionDefOf.CM_PocketDimensionBreachedLetter);
                    }
                }
                else
                {
                    Find.LetterStack.ReceiveLetter(label, text, PocketDimensionDefOf.CM_PocketDimensionBreachedLetter);
                }

                if (box != null)
                {
                    box.GetLost = true;
                }

                Building_PocketDimensionExit exit = PocketDimensionUtility.GetExit(this.dimensionSeed);
                if (exit != null)
                {
                    exit.GetLost = true;
                }
            }

            this.shouldBeDeleted = true;
        }