Ejemplo n.º 1
0
        public static bool FreeHumanlikesSpawnedOfFaction(MapPawns __instance, ref List <Pawn> __result, Faction faction)
        {
            if (faction == null)
            {
                Log.Error("Called FreeHumanlikesSpawnedOfFaction with null faction.");
                __result = new List <Pawn>();
                return(false);
            }

            List <Pawn> value = new List <Pawn>();
            List <Pawn> list  = __instance.SpawnedPawnsInFaction(faction);

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].HostFaction == null && list[i].RaceProps.Humanlike)
                {
                    value.Add(list[i]);
                }
            }

            lock (__instance)
            {
                Dictionary <Faction, List <Pawn> > newFreeHumanlikesSpawnedOfFactionResult =
                    new Dictionary <Faction, List <Pawn> >(freeHumanlikesSpawnedOfFactionResult(__instance))
                {
                    [faction] = value
                };
                freeHumanlikesSpawnedOfFactionResult(__instance) = newFreeHumanlikesSpawnedOfFactionResult;
            }
            __result = value;
            return(false);
        }
Ejemplo n.º 2
0
        public static bool FreeHumanlikesSpawnedOfFaction(MapPawns __instance, ref List <Pawn> __result, Faction faction)
        {
            List <Pawn> pawnList1;

            lock (freeHumanlikesSpawnedOfFactionResult(__instance))
            {
                if (!freeHumanlikesSpawnedOfFactionResult(__instance).TryGetValue(faction, out pawnList1))
                {
                    pawnList1 = new List <Pawn>();
                    freeHumanlikesSpawnedOfFactionResult(__instance)[faction] = pawnList1;
                }
            }
            lock (pawnList1)
            {
                pawnList1.Clear();
                List <Pawn> list = __instance.SpawnedPawnsInFaction(faction);
                for (int i = 0; i < list.Count; i++)
                {
                    Pawn pawn;
                    try
                    {
                        pawn = list[i];
                    }
                    catch (ArgumentOutOfRangeException) { break; }
                    if (pawn.HostFaction == null && pawn.RaceProps.Humanlike)
                    {
                        pawnList1.Add(pawn);
                    }
                }
            }
            __result = pawnList1;
            return(false);
        }
Ejemplo n.º 3
0
        public static bool FreeHumanlikesSpawnedOfFaction(MapPawns __instance, ref List <Pawn> __result, Faction faction)
        {
            if (faction == null)
            {
                Log.Error("Called FreeHumanlikesSpawnedOfFaction with null faction.");
                __result = new List <Pawn>();
                return(false);
            }

            List <Pawn> value    = new List <Pawn>();
            List <Pawn> pawnList = __instance.SpawnedPawnsInFaction(faction);

            for (int i = 0; i < pawnList.Count; i++)
            {
                Pawn pawn = pawnList[i];
                if (pawn.HostFaction == null && pawn.RaceProps.Humanlike)
                {
                    value.Add(pawn);
                }
            }

            lock (__instance)
            {
                __instance.freeHumanlikesSpawnedOfFactionResult[faction] = value;
            }
            __result = value;
            return(false);
        }
Ejemplo n.º 4
0
        public static void FreeHumanlikesSpawnedInVehicles(Faction faction, ref List <Pawn> __result, MapPawns __instance)
        {
            List <Pawn> innerPawns = __instance.SpawnedPawnsInFaction(faction).Where(p => p is VehiclePawn).SelectMany(v => (v as VehiclePawn).AllPawnsAboard).ToList();

            __result.AddRange(innerPawns);
        }