public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
        {
            base.Notify_PawnLost(p, condition);

            switch (condition)
            {
            case PawnLostCondition.ExitedMap:
            case PawnLostCondition.ChangedFaction:
                //foreach (var action in e.actions.OfType<EventAction_Pawns>()) action.RemovePawn(p);
                break;

            case PawnLostCondition.Undefined:
            case PawnLostCondition.Vanished:
            case PawnLostCondition.IncappedOrKilled:
            case PawnLostCondition.MadePrisoner:
            case PawnLostCondition.LeftVoluntarily:
            case PawnLostCondition.Drafted:
                Hospitality_MapComponent.Instance(lord.Map).QueueEvent(new Event
                {
                    delayTicks = (int)(GenDate.TicksPerHour * Rand.Range(1f, 3f)),
                    actions    =
                        new List <EventAction>
                    {
                        new EventAction_AngerForPawn(p, faction),
                        new EventAction_BreakPawns(new List <Pawn> {
                            p
                        })
                    }
                });
                break;

            default:
                throw new ArgumentOutOfRangeException("condition");
            }
        }
 public void Notify_PawnLost(Pawn pawn, PawnLostCondition cond, DamageInfo?dinfo = null)
 {
     if (ownedPawns.Contains(pawn))
     {
         RemovePawn(pawn);
         if (cond == PawnLostCondition.IncappedOrKilled || cond == PawnLostCondition.MadePrisoner)
         {
             numPawnsLostViolently++;
         }
         curJob.Notify_PawnLost(pawn, cond);
         if (!lordManager.lords.Contains(this))
         {
             return;
         }
         if (!ShouldExist)
         {
             Destroy();
             return;
         }
         curLordToil.Notify_PawnLost(pawn, cond);
         TriggerSignal signal = default(TriggerSignal);
         signal.type      = TriggerSignalType.PawnLost;
         signal.thing     = pawn;
         signal.condition = cond;
         if (dinfo.HasValue)
         {
             signal.dinfo = dinfo.Value;
         }
         CheckTransitionOnSignal(signal);
     }
     else
     {
         Log.Error(string.Concat("Lord lost pawn ", pawn, " it didn't have. Condition=", cond));
     }
 }
        public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
        {
            base.Notify_PawnLost(p, condition);

            switch (condition)
            {
            case PawnLostCondition.Vanished:
                break;

            /* Theoretically the only valid loss condition is that the mod itself despawns them, since they're
             * intended to be invincible. Hence any condition other than Vanished should never happen.
             *
             * Theoretically. We're not there yet.
             */
            case PawnLostCondition.ExitedMap:
            case PawnLostCondition.ChangedFaction:
            case PawnLostCondition.Undefined:
            case PawnLostCondition.IncappedOrKilled:
            case PawnLostCondition.MadePrisoner:
            case PawnLostCondition.LeftVoluntarily:
            case PawnLostCondition.Drafted:
                throw new ArgumentException("Ancestor pawns should not be lost due to " + condition);

            default:
                throw new ArgumentOutOfRangeException("condition");
            }
        }
Exemple #4
0
 public void Notify_PawnLost(Pawn pawn, PawnLostCondition cond)
 {
     if (this.ownedPawns.Contains(pawn))
     {
         this.RemovePawn(pawn);
         if (cond == PawnLostCondition.IncappedOrKilled || cond == PawnLostCondition.MadePrisoner)
         {
             this.numPawnsLostViolently++;
         }
         if (this.ownedPawns.Count == 0 && !this.CanExistWithoutPawns)
         {
             this.lordManager.RemoveLord(this);
         }
         else
         {
             this.curLordToil.Notify_PawnLost(pawn, cond);
             this.curJob.Notify_PawnLost(pawn, cond);
             this.CheckTransitionOnSignal(new TriggerSignal
             {
                 type      = TriggerSignalType.PawnLost,
                 thing     = pawn,
                 condition = cond
             });
         }
         return;
     }
     Log.Error(string.Concat(new object[]
     {
         "Lord lost pawn ",
         pawn,
         " it didn't have. Condition=",
         cond
     }));
 }
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     if (p == bestower)
     {
         MakeCeremonyFail();
     }
 }
Exemple #6
0
 public void Notify_PawnLost(Pawn pawn, PawnLostCondition cond)
 {
     if (this.ownedPawns.Contains(pawn))
     {
         this.RemovePawn(pawn);
         if (cond == PawnLostCondition.IncappedOrKilled || cond == PawnLostCondition.MadePrisoner)
         {
             this.numPawnsLostViolently++;
         }
         if (this.ownedPawns.Count == 0 && !this.CanExistWithoutPawns)
         {
             this.lordManager.RemoveLord(this);
         }
         else
         {
             this.curLordToil.Notify_PawnLost(pawn, cond);
             this.curJob.Notify_PawnLost(pawn, cond);
             TriggerSignal signal = default(TriggerSignal);
             signal.type      = TriggerSignalType.PawnLost;
             signal.thing     = pawn;
             signal.condition = cond;
             this.CheckTransitionOnSignal(signal);
         }
     }
     else
     {
         Log.Error("Lord lost pawn " + pawn + " it didn't have. Condition=" + cond);
     }
 }
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     ReachabilityUtility.ClearCache();
     if (!this.caravanSent)
     {
         CaravanFormingUtility.RemovePawnFromCaravan(p, this.lord);
     }
 }
        public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition)
        {
            FactionFC faction = Find.World.GetComponent <FactionFC>();
            //Check if a settlement battle ended
            SettlementFC settlement = faction.getSettlement(pawn.Tile, Find.World.info.name);

            settlement?.worldSettlement.removeAttacker(pawn);
        }
Exemple #9
0
 public TriggerSignal(TriggerSignalType type)
 {
     this.type      = type;
     this.memo      = null;
     this.thing     = null;
     this.dinfo     = default(DamageInfo);
     this.condition = PawnLostCondition.Undefined;
     this.faction   = null;
 }
Exemple #10
0
        public override void Notify_PawnLost(Pawn victim, PawnLostCondition cond)
        {
            base.Notify_PawnLost(victim, cond);

            if (cond == PawnLostCondition.IncappedOrKilled)
            {
                CarnUtils.Info.leavingUrgency = LocomotionUrgency.Sprint;
            }
        }
Exemple #11
0
 public TriggerSignal(TriggerSignalType type)
 {
     this.type            = type;
     memo                 = null;
     thing                = null;
     dinfo                = default(DamageInfo);
     condition            = PawnLostCondition.Undefined;
     faction              = null;
     previousRelationKind = null;
 }
Exemple #12
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     base.Notify_PawnLost(p, condition);
     ReachabilityUtility.ClearCacheFor(p);
     if (!this.caravanSent)
     {
         if (condition == PawnLostCondition.IncappedOrKilled && p.Downed)
         {
             this.downedPawns.Add(p);
         }
         CaravanFormingUtility.RemovePawnFromCaravan(p, this.lord, false);
     }
 }
Exemple #13
0
        public override void Notify_PawnLost(Pawn victim, PawnLostCondition cond)
        {
            //if (cond == PawnLostCondition.IncappedOrKilled
            //    || cond == PawnLostCondition.MadePrisoner)
            //{
            //    // Hostile actions
            //    this.lord.ReceiveMemo("HostileConditions");
            //    return;
            //}

            //// Non-hostile cause of PawnLost
            this.UpdateAllDuties();
        }
Exemple #14
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     base.Notify_PawnLost(p, condition);
     if (condition == PawnLostCondition.IncappedOrKilled)
     {
         Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, pawnLostGoodwillImpact);
         Messages.Message("A MiningCo. employee has been injured or killed in your area. MiningCo. goodwill toward you decreased: " + pawnLostGoodwillImpact + ".", new TargetInfo(p.Position, this.Map), MessageTypeDefOf.NegativeHealthEvent);
     }
     else if (condition == PawnLostCondition.ExitedMap)
     {
         Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, pawnExitedGoodwillImpact);
     }
 }
Exemple #15
0
        public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition)
        {
            if (condition == PawnLostCondition.ExitedMap)
            {
                return;
            }

            Log.Message("lord owns " + lord.ownedPawns.Select(p => p.LabelShort).ToCommaList());
            if (!lord.ownedPawns.Any())
            {
                GuestUtility.OnLostEntireGroup(lord);
            }
        }
Exemple #16
0
        public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition)
        {
            if (condition == PawnLostCondition.ChangedFaction || condition == PawnLostCondition.ExitedMap)
            {
                lord.AddPawn(pawn);
                return;
            }
            pawn.SetFaction(FactionColonies.getPlayerColonyFaction());
            FactionFC faction = Find.World.GetComponent <FactionFC>();
            //Check if a settlement battle ended
            SettlementFC settlement = faction.getSettlement(pawn.Tile, Find.World.info.name);

            settlement?.worldSettlement.removeDefender(pawn);
        }
Exemple #17
0
        public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition)
        {
            if (condition == PawnLostCondition.ExitedMap)
            {
                return;
            }

            pawn.ownership.UnclaimAll();

            if (!lord.ownedPawns.Any())
            {
                GuestUtility.OnLostEntireGroup(lord);
            }
        }
Exemple #18
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     base.Notify_PawnLost(p, condition);
     if (condition == PawnLostCondition.IncappedOrKilled)
     {
         if (p.kindDef == Util_PawnKindDefOf.Medic)
         {
             Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, -5);
             string letterText = "A MiningCo. medic has been downed or killed while helping your colony.\n\n"
                                 + "Medics are precious people, even more on rimworlds. Losing one will obviously anger MiningCo. and nobody wants to anger this company.\n"
                                 + "Remember that you must ensure their safety in your area!";
             Find.LetterStack.ReceiveLetter("Medic down", letterText, LetterDefOf.NegativeEvent);
         }
     }
 }
        public override void Notify_PawnLost(Pawn victim, PawnLostCondition cond)
        {
            base.Notify_PawnLost(victim, cond);

            if (cond == PawnLostCondition.IncappedOrKilled)
            {
                if (victim == lord.faction.leader)
                {
                    lord.ReceiveMemo("LeaderKilled");
                    return;
                }

                pawnsKilled++;
                numChargers++;
            }

            UpdateAllDuties();
        }
Exemple #20
0
 public void Notify_PawnLost(Pawn pawn, PawnLostCondition cond, DamageInfo?dinfo = null)
 {
     if (this.ownedPawns.Contains(pawn))
     {
         this.RemovePawn(pawn);
         if (cond == PawnLostCondition.IncappedOrKilled || cond == PawnLostCondition.MadePrisoner)
         {
             this.numPawnsLostViolently++;
         }
         this.curJob.Notify_PawnLost(pawn, cond);
         if (this.lordManager.lords.Contains(this))
         {
             if (this.ownedPawns.Count == 0 && !this.CanExistWithoutPawns)
             {
                 this.lordManager.RemoveLord(this);
             }
             else
             {
                 this.curLordToil.Notify_PawnLost(pawn, cond);
                 TriggerSignal signal = default(TriggerSignal);
                 signal.type      = TriggerSignalType.PawnLost;
                 signal.thing     = pawn;
                 signal.condition = cond;
                 if (dinfo.HasValue)
                 {
                     signal.dinfo = dinfo.Value;
                 }
                 this.CheckTransitionOnSignal(signal);
             }
         }
         return;
     }
     Log.Error(string.Concat(new object[]
     {
         "Lord lost pawn ",
         pawn,
         " it didn't have. Condition=",
         cond
     }), false);
 }
Exemple #21
0
 public void Notify_PawnLost(Pawn pawn, PawnLostCondition cond, DamageInfo?dinfo = default(DamageInfo?))
 {
     if (ownedPawns.Contains(pawn))
     {
         RemovePawn(pawn);
         if (cond == PawnLostCondition.IncappedOrKilled || cond == PawnLostCondition.MadePrisoner)
         {
             numPawnsLostViolently++;
         }
         curJob.Notify_PawnLost(pawn, cond);
         if (lordManager.lords.Contains(this))
         {
             if (ownedPawns.Count == 0 && !CanExistWithoutPawns)
             {
                 lordManager.RemoveLord(this);
             }
             else
             {
                 curLordToil.Notify_PawnLost(pawn, cond);
                 TriggerSignal signal = default(TriggerSignal);
                 signal.type      = TriggerSignalType.PawnLost;
                 signal.thing     = pawn;
                 signal.condition = cond;
                 if (dinfo.HasValue)
                 {
                     signal.dinfo = dinfo.Value;
                 }
                 CheckTransitionOnSignal(signal);
             }
         }
     }
     else
     {
         Log.Error("Lord lost pawn " + pawn + " it didn't have. Condition=" + cond);
     }
 }
 public virtual void Notify_PawnLost(Pawn victim, PawnLostCondition cond)
 {
 }
 public virtual void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
 }
Exemple #24
0
 public override void Notify_PawnLost(Pawn pawn, PawnLostCondition condition)
 {
     base.Notify_PawnLost(pawn, condition);
 }
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     base.Notify_PawnLost(p, condition);
     //Log.Message(p.ToString() + " lost");
     signalsCounted.Remove(p);
 }
 public Trigger_PawnLost(PawnLostCondition condition = PawnLostCondition.Undefined, Pawn pawn = null)
 {
     this.condition = condition;
     this.pawn      = pawn;
 }
Exemple #27
0
 public override void Notify_PawnLost(Pawn victim, PawnLostCondition cond)
 {
     UpdateAllDuties();
     base.Notify_PawnLost(victim, cond);
 }
Exemple #28
0
 public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
 {
     ReachabilityUtility.ClearCacheFor(p);
 }
Exemple #29
0
        public static bool Destroy(Pawn __instance, DestroyMode mode = DestroyMode.Vanish)
        {
            if (mode != 0 && mode != DestroyMode.KillFinalize)
            {
                Log.Error(string.Concat("Destroyed pawn ", __instance, " with unsupported mode ", mode, "."));
            }
            //ThingWithComps twc = __instance;
            //twc.Destroy(mode);
            ThingWithCompsDestroy(__instance, mode);
            Find.WorldPawns.Notify_PawnDestroyed(__instance);
            if (__instance.ownership != null)
            {
                Building_Grave assignedGrave = __instance.ownership.AssignedGrave;
                __instance.ownership.UnclaimAll();
                if (mode == DestroyMode.KillFinalize)
                {
                    assignedGrave?.CompAssignableToPawn.TryAssignPawn(__instance);
                }
            }

            __instance.ClearMind(ifLayingKeepLaying: false, clearInspiration: true);
            Lord lord = __instance.GetLord();

            if (lord != null)
            {
                PawnLostCondition cond = (mode != DestroyMode.KillFinalize) ? PawnLostCondition.Vanished : PawnLostCondition.IncappedOrKilled;
                lord.Notify_PawnLost(__instance, cond);
            }

            if (Current.ProgramState == ProgramState.Playing)
            {
                Find.GameEnder.CheckOrUpdateGameOver();
                Find.TaleManager.Notify_PawnDestroyed(__instance);
            }

            //foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_Alive.Where((Pawn p) => p.playerSettings != null && p.playerSettings.Master == __instance))
            //{
            //item.playerSettings.Master = null;
            //}
            //ClearMatchingMasters(__instance)
            if (Pawn_PlayerSettings_Patch.petsInit == false)
            {
                Pawn_PlayerSettings_Patch.RebuildPetsDictionary();
            }
            if (Pawn_PlayerSettings_Patch.pets.TryGetValue(__instance, out List <Pawn> pawnList))
            {
                for (int i = 0; i < pawnList.Count; i++)
                {
                    Pawn p;
                    try
                    {
                        p = pawnList[i];
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        break;
                    }
                    p.playerSettings.Master = null;
                }
            }

            /*
             * for (int i = 0; i < PawnsFinder.AllMapsWorldAndTemporary_Alive.Count; i++)
             * {
             *  Pawn p;
             *  try
             *  {
             *      p = PawnsFinder.AllMapsWorldAndTemporary_Alive[i];
             *  }
             *  catch (ArgumentOutOfRangeException)
             *  {
             *      break;
             *  }
             *  if (p.playerSettings != null && p.playerSettings.Master == __instance)
             *  {
             *      p.playerSettings.Master = null;
             *  }
             * }
             */
            if (__instance.equipment != null)
            {
                __instance.equipment.Notify_PawnDied();
            }

            if (mode != DestroyMode.KillFinalize)
            {
                if (__instance.equipment != null)
                {
                    __instance.equipment.DestroyAllEquipment();
                }

                __instance.inventory.DestroyAll();
                if (__instance.apparel != null)
                {
                    __instance.apparel.DestroyAll();
                }
            }

            WorldPawns worldPawns = Find.WorldPawns;

            if (!worldPawns.IsBeingDiscarded(__instance) && !worldPawns.Contains(__instance))
            {
                worldPawns.PassToWorld(__instance);
            }
            return(false);
        }