Beispiel #1
0
        public void EquipPawn(Mercenary merc, MilUnitFC loadout)
        {
            foreach (Apparel clothes in loadout.defaultPawn.apparel.WornApparel)
            {
                if (clothes.def.MadeFromStuff)
                {
                    Thing thing = ThingMaker.MakeThing(clothes.def, clothes.Stuff);
                    thing.SetColor(Color.white);
                    merc.pawn.apparel.Wear(thing as Apparel);
                }
                else
                {
                    Thing thing = ThingMaker.MakeThing(clothes.def, clothes.Stuff);
                    thing.SetColor(Color.white);
                    merc.pawn.apparel.Wear(thing as Apparel);
                }
            }

            foreach (ThingWithComps weapon in loadout.defaultPawn.equipment.AllEquipmentListForReading)
            {
                if (weapon.def.MadeFromStuff)
                {
                    merc.pawn.equipment.AddEquipment(ThingMaker.MakeThing(weapon.def, weapon.Stuff) as ThingWithComps);
                }
                else
                {
                    merc.pawn.equipment.AddEquipment(ThingMaker.MakeThing(weapon.def) as ThingWithComps);
                }

                if (FactionColonies.checkForMod("CETeam.CombatExtended"))
                {
                    //Log.Message("mod detected");
                    //CE is loaded
                    foreach (ThingComp comp in merc.pawn.AllComps)
                    {
                        if (comp.GetType().ToString() == "CombatExtended.CompInventory")
                        {
                            Type typ = FactionColonies.returnUnknownTypeFromName(
                                "CombatExtended.LoadoutPropertiesExtension");

                            //Method not static, so create instance of object and define the parameters to the method.
                            var      obj       = Activator.CreateInstance(typ);
                            object[] paramArgu = { merc.pawn.equipment.Primary, comp, 1 };

                            Traverse.Create(obj).Method("TryGenerateAmmoFor", paramArgu).GetValue();
                            Traverse.Create(obj).Method("LoadWeaponWithRandAmmo", merc.pawn.equipment.Primary)
                            .GetValue();
                        }
                    }
                }
            }
        }