Exemplo n.º 1
0
 static bool Prefix(RimWorld.Planet.WorldPawns __instance, ref Pawn pawn, ref RimWorld.Planet.PawnDiscardDecideMode discardMode)
 {
     if (Current.Game.Info.RealPlayTimeInteracting > 0 &&                          // prevent this from firing when the game hasn't even started proper
         !pawn.Destroyed &&                                                        // ignore pawns destroyed for whatever reason
         !KidnapUtility.IsKidnapped(pawn) &&                                       // don't make kidnapped pawns available; vanilla handles that naturally
         !PawnsFinder.AllCaravansAndTravelingTransportPods_Alive.Contains(pawn) && // ignore caravan/pods
         (pawn.ParentHolder == null || !(pawn.ParentHolder is CompTransporter)) && // ignore pawns in shuttle
         GameComponent.ListAllySpawned.Contains(pawn.GetUniqueLoadID()))
     {
         if (PawnComponentsUtility.HasSpawnedComponents(pawn))
         {
             PawnComponentsUtility.RemoveComponentsOnDespawned(pawn);
         }
         GameComponent.ReturnToAvailable(pawn, GameComponent.ListAllySpawned, GameComponent.ListAllyAvailable);
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
 public void PassToWorld(Pawn pawn, PawnDiscardDecideMode discardMode = PawnDiscardDecideMode.Decide)
 {
     if (pawn.Spawned)
     {
         Log.Error("Tried to call PassToWorld with spawned pawn: " + pawn + ". Despawn him first.", false);
     }
     else if (this.Contains(pawn))
     {
         Log.Error("Tried to pass pawn " + pawn + " to world, but it's already here.", false);
     }
     else
     {
         if (discardMode == PawnDiscardDecideMode.KeepForever && pawn.Discarded)
         {
             Log.Error("Tried to pass a discarded pawn " + pawn + " to world with discardMode=Keep. Discarded pawns should never be stored in WorldPawns.", false);
             discardMode = PawnDiscardDecideMode.Decide;
         }
         if (PawnComponentsUtility.HasSpawnedComponents(pawn))
         {
             PawnComponentsUtility.RemoveComponentsOnDespawned(pawn);
         }
         if (discardMode != PawnDiscardDecideMode.Decide)
         {
             if (discardMode != PawnDiscardDecideMode.KeepForever)
             {
                 if (discardMode == PawnDiscardDecideMode.Discard)
                 {
                     this.DiscardPawn(pawn, false);
                 }
             }
             else
             {
                 this.pawnsForcefullyKeptAsWorldPawns.Add(pawn);
                 this.AddPawn(pawn);
             }
         }
         else
         {
             this.AddPawn(pawn);
         }
     }
 }
Exemplo n.º 3
0
        public void PassToWorld(Pawn pawn, PawnDiscardDecideMode discardMode = PawnDiscardDecideMode.Decide)
        {
            if (pawn.Spawned)
            {
                Log.Error(string.Concat("Tried to call PassToWorld with spawned pawn: ", pawn, ". Despawn him first."));
                return;
            }
            if (Contains(pawn))
            {
                Log.Error(string.Concat("Tried to pass pawn ", pawn, " to world, but it's already here."));
                return;
            }
            if (discardMode == PawnDiscardDecideMode.KeepForever && pawn.Discarded)
            {
                Log.Error(string.Concat("Tried to pass a discarded pawn ", pawn, " to world with discardMode=Keep. Discarded pawns should never be stored in WorldPawns."));
                discardMode = PawnDiscardDecideMode.Decide;
            }
            if (PawnComponentsUtility.HasSpawnedComponents(pawn))
            {
                PawnComponentsUtility.RemoveComponentsOnDespawned(pawn);
            }
            switch (discardMode)
            {
            case PawnDiscardDecideMode.Decide:
                AddPawn(pawn);
                break;

            case PawnDiscardDecideMode.KeepForever:
                pawnsForcefullyKeptAsWorldPawns.Add(pawn);
                AddPawn(pawn);
                break;

            case PawnDiscardDecideMode.Discard:
                DiscardPawn(pawn);
                break;
            }
        }