Пример #1
0
        static bool Prefix(X2_AIRobot __instance, ref List <WorkGiver> ___workGiversEmergencyCache, ref List <WorkGiver> ___workGiversNonEmergencyCache)
        {
            if (Traverse.Create(__instance.workSettings).Field("workGiversDirty").GetValue <bool>())
            {
                ___workGiversEmergencyCache    = null;
                ___workGiversNonEmergencyCache = null;
            }

            return(true);
        }
Пример #2
0
        static bool Prefix(string pawnDefName, IntVec3 position, Map map, Faction faction, ref X2_AIRobot __result)
        {
            PawnKindDef named = DefDatabase <PawnKindDef> .GetNamed(pawnDefName);

            PawnGenerationRequest request = new PawnGenerationRequest(named
                                                                      , faction: faction
                                                                      , context: PawnGenerationContext.NonPlayer
                                                                      , forceGenerateNewPawn: true
                                                                      , newborn: true
                                                                      , canGeneratePawnRelations: false
                                                                      , colonistRelationChanceFactor: 0f
                                                                      , allowGay: false
                                                                      , allowAddictions: false
                                                                      , relationWithExtraPawnChanceFactor: 0f
                                                                      , fixedBiologicalAge: 0f
                                                                      , fixedChronologicalAge: 0f
                                                                      , fixedGender: Gender.Male
                                                                      );

            X2_AIRobot x2_AIRobot = (X2_AIRobot)PawnGenerator.GeneratePawn(request);

            if (x2_AIRobot.inventory == null)
            {
                x2_AIRobot.inventory = new Pawn_InventoryTracker(x2_AIRobot);
            }

            if (x2_AIRobot.equipment == null)
            {
                x2_AIRobot.equipment = new Pawn_EquipmentTracker(x2_AIRobot);
            }

            if (x2_AIRobot.apparel == null)
            {
                x2_AIRobot.apparel = new Pawn_ApparelTracker(x2_AIRobot);
            }

            x2_AIRobot.workSettings = new Pawn_WorkSettings(x2_AIRobot);

            if (x2_AIRobot.story == null)
            {
                x2_AIRobot.story = new Pawn_StoryTracker(x2_AIRobot);
            }

            __result = (X2_AIRobot)X2_Building_AIRobotCreator.Spawn(x2_AIRobot, position, map);

            x2_AIRobot.story.traits.GainTrait(new Trait(DefOfs.AIRobot_BaseTrait, 1, true));

            if (x2_AIRobot.workSettings == null || x2_AIRobot.workSettings is X2_AIRobot_Pawn_WorkSettings)
            {
                x2_AIRobot.workSettings = new Pawn_WorkSettings(x2_AIRobot);
            }
            x2_AIRobot.workSettings.EnableAndInitializeIfNotAlreadyInitialized();

            return(false);
        }