Exemplo n.º 1
0
        public AnimalTab(ModContentPack mod)
        {
            var type = AccessTools.TypeByName("AnimalTab.Command_HandlerSettings");

            commandCtor = AccessTools.Constructor(type, new[] { AccessTools.TypeByName("AnimalTab.CompHandlerSettings") });
            compField   = AccessTools.FieldRefAccess <ThingComp>(type, "comp");
            MP.RegisterSyncMethod(type, "MassSetMode").SetContext(SyncContext.MapSelected);
            MP.RegisterSyncMethod(type, "MassSetHandler").SetContext(SyncContext.MapSelected);
            MP.RegisterSyncMethod(type, "MassSetLevel").SetContext(SyncContext.MapSelected);
            MP.RegisterSyncWorker <Command_Action>(SyncHandlerSettingsCommand, type);

            type = AccessTools.TypeByName("AnimalTab.PawnColumnWorker_Handler");
            MpCompat.RegisterLambdaDelegate(type, "DoHandlerFloatMenu", 0, 1, 2);
            MpCompat.RegisterLambdaDelegate(type, "DoMassHandlerFloatMenu", 0, 1, 4);
            MpCompat.harmony.Patch(AccessTools.Method(type, nameof(PawnColumnWorker.DoHeader)),
                                   prefix: new HarmonyMethod(typeof(AnimalTab), nameof(PreDoHeader)),
                                   postfix: new HarmonyMethod(typeof(AnimalTab), nameof(StopWatch)));
            MpCompat.harmony.Patch(AccessTools.Method(type, nameof(PawnColumnWorker.DoCell)),
                                   prefix: new HarmonyMethod(typeof(AnimalTab), nameof(PreDoCell)),
                                   postfix: new HarmonyMethod(typeof(AnimalTab), nameof(StopWatch)));

            type       = compHandlerSettingsType = AccessTools.TypeByName("AnimalTab.CompHandlerSettings");
            modeField  = MP.RegisterSyncField(type, "_mode");
            levelField = MP.RegisterSyncField(type, "_level");
        }
        public CleaningArea(ModContentPack mod)
        {
            Type type = CleaningAreaMapComponentType = AccessTools.TypeByName("CleaningArea.CleaningArea_MapComponent");

            MP.RegisterSyncMethod(AccessTools.PropertySetter(type, "cleaningArea"));
            MP.RegisterSyncWorker <MapComponent>(SyncWorkerForCleaningArea, type);
        }
Exemplo n.º 3
0
        public CorruptionCore(ModContentPack mod)
        {
            // ITab_Pawn_Soul - checkboxes to allow praying and show prayers
            var type = AccessTools.TypeByName("Corruption.Core.Soul.ITab_Pawn_Soul");

            pawnSoulITabSoulToShowGetter = AccessTools.PropertyGetter(type, "SoulToShow");
            MP.RegisterSyncMethod(typeof(CorruptionCore), nameof(SyncFavourValue));
            MpCompat.harmony.Patch(AccessTools.Method(type, "FillTab"),
                                   prefix: new HarmonyMethod(typeof(CorruptionCore), nameof(PreFillTab)),
                                   postfix: new HarmonyMethod(typeof(CorruptionCore), nameof(PostFillTab)));

            type = AccessTools.TypeByName("Corruption.Core.Soul.CompSoul");
            compSoulFavourTrackerField = AccessTools.Field(type, "FavourTracker");
            compSoulAllowPrayingSync   = MP.RegisterSyncField(type, "PrayerTracker/AllowPraying");
            compSoulShowPrayerSync     = MP.RegisterSyncField(type, "PrayerTracker/ShowPrayer");

            setPawnPantheonDialogType      = AccessTools.TypeByName("Corruption.Core.Dialog_SetPawnPantheon");
            setPawnPantheonDialogSoulField = AccessTools.Field(setPawnPantheonDialogType, "soul");
            MP.RegisterSyncMethod(setPawnPantheonDialogType, "SelectionChanged");
            MP.RegisterSyncWorker <object>(SyncDialogSetPawnPantheon, setPawnPantheonDialogType);

            type = AccessTools.TypeByName("Corruption.Core.Soul.Soul_FavourTracker");
            soulFavourTrackerFavoursField = AccessTools.Field(type, "Favours");

            type = AccessTools.TypeByName("Corruption.Core.Soul.FavourProgress");
            favourProgressFavourValueField = AccessTools.Field(type, "favourValue");
        }
        public RimFridgeCompat(ModContentPack mod)
        {
            // Several Gizmos
            {
                Type type = AccessTools.TypeByName("RimFridge.CompRefrigerator");

                string[] methods =
                {
                    "<CompGetGizmosExtra>b__1",
                    "<CompGetGizmosExtra>b__2",
                    "<CompGetGizmosExtra>b__3",
                    "<CompGetGizmosExtra>b__4",
                    "<CompGetGizmosExtra>b__5"
                };

                foreach (string method in methods)
                {
                    MP.RegisterSyncDelegate(type, "<>c__DisplayClass10_0", method);
                }

                dialogType  = AccessTools.TypeByName("RimFridge.Dialog_RenameFridge");
                fridgeField = AccessTools.Field(dialogType, "fridge");

                MP.RegisterSyncWorker <Dialog_Rename>(SyncFridgeName, dialogType);
                MP.RegisterSyncMethod(dialogType, "SetName");
            }
        }
Exemplo n.º 5
0
        static ExtendedOutfitProxy()
        {
            if (!MP.enabled)
            {
                return;
            }

            ProxyFields = new ISyncField[] {
                MP.RegisterSyncField(typeof(ExtendedOutfitProxy), nameof(targetWeight))
                .SetBufferChanges().PostApply(Update)
            };

            ExtendedOutfitFields = new ISyncField[] {
                MP.RegisterSyncField(typeof(ExtendedOutfit), nameof(ExtendedOutfit.targetTemperaturesOverride)),
                MP.RegisterSyncField(typeof(ExtendedOutfit), nameof(ExtendedOutfit.targetTemperatures)),
                MP.RegisterSyncField(typeof(ExtendedOutfit), nameof(ExtendedOutfit.PenaltyWornByCorpse)),
                MP.RegisterSyncField(typeof(ExtendedOutfit), nameof(ExtendedOutfit.AutoWorkPriorities)),
            };

            MP.RegisterSyncMethod(typeof(ExtendedOutfit), nameof(ExtendedOutfit.AddStatPriority));
            MP.RegisterSyncMethod(typeof(ExtendedOutfit), nameof(ExtendedOutfit.RemoveStatPriority));

            MP.RegisterSyncMethod(typeof(ExtendedOutfitProxy), nameof(SetStat));

            MP.RegisterSyncWorker <ExtendedOutfit>(ExtendedOutfitSyncer);
        }
        public static void Initialize()
        {
            try {
                if (!MP.enabled)
                {
                    return;
                }
                const string expectedAPIVersion = "0.1";
                if (!MP.API.Equals(expectedAPIVersion))
                {
                    throw new Exception($"MP API version mismatch. This mod is designed to work with MPAPI version {expectedAPIVersion}");
                }

                // register synchronized methods
                MP.RegisterSyncMethod(typeof(DefensivePositionsManager), nameof(DefensivePositionsManager.ToggleAdvancedMode));
                MP.RegisterSyncMethod(typeof(PawnSavedPositionHandler), nameof(PawnSavedPositionHandler.SetDefensivePosition));
                MP.RegisterSyncMethod(typeof(PawnSavedPositionHandler), nameof(PawnSavedPositionHandler.DiscardSavedPosition));
                MP.RegisterSyncMethod(typeof(PawnSquadHandler), nameof(PawnSquadHandler.SetSquadMembers));
                MP.RegisterSyncMethod(typeof(PawnSquadHandler), nameof(PawnSquadHandler.ClearSquad));

                // register instance resolvers
                MP.RegisterSyncWorker <DefensivePositionsManager>(ManagerSyncer, typeof(DefensivePositionsManager));
                MP.RegisterSyncWorker <PawnSavedPositionHandler>(PawnHandlerSyncer, typeof(PawnSavedPositionHandler));
                MP.RegisterSyncWorker <PawnSquadHandler>(SquadHandlerSyncer, typeof(PawnSquadHandler));

                DefensivePositionsManager.Instance.Logger.Message("Applied Multiplayer API compatibility layer");
            } catch (Exception e) {
                DefensivePositionsManager.Instance.Logger.Error("Failed to apply Multiplayer API compatibility layer: " + e);
            }
        }
        public void LatePatch()
        {
            // Facepaint
            changeFacepaintDialogType = AccessTools.TypeByName("VFEV.Facepaint.Dialog_ChangeFacepaint");
            //setFacepaintMethod = AccessTools.Method(changeFacepaintDialogType, "SetHairstyle");
            orderedFacepaintDefsField = AccessTools.Field(changeFacepaintDialogType, "orderedFacepaintDefs");

            newFacepaintComboSync = MP.RegisterSyncField(AccessTools.Field(changeFacepaintDialogType, "newFacepaintCombo"));
            coloursTiedSync       = MP.RegisterSyncField(AccessTools.Field(changeFacepaintDialogType, "coloursTied"));
            MP.RegisterSyncMethod(changeFacepaintDialogType, "SetHairstyle");
            MP.RegisterSyncWorker <Window>(SyncDialog, changeFacepaintDialogType);

            MP.RegisterSyncMethod(typeof(VanillaFactionsVikings), nameof(SyncedTryRemoveWindow));

            MpCompat.harmony.Patch(AccessTools.Method(changeFacepaintDialogType, "DoWindowContents"),
                                   prefix: new HarmonyMethod(typeof(VanillaFactionsVikings), nameof(PreDoWindowContents)),
                                   postfix: new HarmonyMethod(typeof(VanillaFactionsVikings), nameof(PostDoWindowContents)));

            var type = AccessTools.Inner(changeFacepaintDialogType, "FacepaintCombination");

            MP.RegisterSyncWorker <object>(SyncFacepaintCombination, type);

            facepaintDefOneField    = AccessTools.Field(type, "facepaintDefOne");
            facepaintDefTwoField    = AccessTools.Field(type, "facepaintDefTwo");
            facepaintColourOneField = AccessTools.Field(type, "colourOne");
            facepaintColourTwoField = AccessTools.Field(type, "colourTwo");

            MpCompat.harmony.Patch(AccessTools.Method(typeof(WindowStack), nameof(WindowStack.TryRemove), new[] { typeof(Window), typeof(bool) }),
                                   prefix: new HarmonyMethod(typeof(VanillaFactionsVikings), nameof(PreTryRemoveWindow)));
        }
        static MultiplayerCompatibility()
        {
            if (!MP.enabled)
            {
                return;
            }

            // Sync all gizmo clicks

            MP.RegisterSyncMethod(typeof(Command_Process), nameof(Command_Process.ChangeProcess)).SetContext(SyncContext.MapSelected);
            MP.RegisterSyncMethod(typeof(Command_Quality), nameof(Command_Quality.ChangeQuality)).SetContext(SyncContext.MapSelected);

            var methods = new[] {
                nameof(UF_Utility.FinishProcess),
                nameof(UF_Utility.ProgressOneDay),
                nameof(UF_Utility.ProgressHalfQuadrum),
                nameof(UF_Utility.EmptyObject),
                nameof(UF_Utility.FillObject),
                nameof(UF_Utility.LogSpeedFactors),
            };

            foreach (string methodName in methods)
            {
                MP.RegisterSyncMethod(typeof(UF_Utility), methodName);
            }

            MP.RegisterSyncWorker <UF_Process>(UF_Process_SyncWorker, shouldConstruct: false);
        }
Exemplo n.º 9
0
        public CashRegister(ModContentPack mod)
        {
            var type = AccessTools.TypeByName("CashRegister.Shifts.ITab_Register_Shifts");

            MpCompat.RegisterLambdaMethod(type, "GetGizmos", 1).SetContext(SyncContext.MapSelected);
            MP.RegisterSyncWorker <object>(NoSync, type, shouldConstruct: true);
            MP.RegisterSyncMethod(typeof(CashRegister), nameof(SyncedSetShifts)).ExposeParameter(1).ExposeParameter(2).ExposeParameter(3).ExposeParameter(4).ExposeParameter(5).MinTime(100);
            MpCompat.harmony.Patch(AccessTools.Method(type, "FillTab"),
                                   prefix: new HarmonyMethod(typeof(CashRegister), nameof(PreFillTab)),
                                   postfix: new HarmonyMethod(typeof(CashRegister), nameof(PostFillTab)));

            type = AccessTools.TypeByName("CashRegister.Gizmo_Radius");
            gizmoRadiusConstructor = AccessTools.GetDeclaredConstructors(type).First(x => x.GetParameters().Length == 1);
            gizmoSelectionField    = AccessTools.FieldRefAccess <Building[]>(type, "selection");
            MP.RegisterSyncMethod(AccessTools.DeclaredMethod(type, "ButtonDown"));
            MP.RegisterSyncMethod(AccessTools.DeclaredMethod(type, "ButtonUp"));
            MP.RegisterSyncMethod(AccessTools.DeclaredMethod(type, "ButtonCenter"));
            MP.RegisterSyncWorker <Gizmo>(SyncGizmoRadius, type);

            type             = AccessTools.TypeByName("CashRegister.Building_CashRegister");
            cashRegisterType = type.MakeArrayType();
            shiftsListField  = AccessTools.FieldRefAccess <IList>(type, "shifts");

            type             = AccessTools.TypeByName("CashRegister.Shifts.Shift");
            shiftConstructor = AccessTools.Constructor(type);
            timetableField   = AccessTools.FieldRefAccess <object>(type, "timetable");
            assignedField    = AccessTools.FieldRefAccess <List <Pawn> >(type, "assigned");

            type       = AccessTools.TypeByName("CashRegister.Timetable.TimetableBool");
            timesField = AccessTools.FieldRefAccess <List <bool> >(type, "times");
        }
Exemplo n.º 10
0
 public OneBedToSleepWithAll(ModContentPack mod)
 {
     compType = AccessTools.TypeByName("OneBedToSleepWithAll.CompPolygamyMode");
     MpCompat.RegisterLambdaMethod(compType, "CompGetGizmosExtra", 1);
     // Comp has a null props.compClass, most likely it's dynamically created
     MP.RegisterSyncWorker <ThingComp>(SyncCompPolygamyMode, compType);
 }
Exemplo n.º 11
0
        public static void LatePatch()
        {
            // Ancient PD turret - toggle aiming at drop pods, enemies, explosive projectiles
            MpCompat.RegisterLambdaMethod("VFEAncients.Building_TurretPD", "GetGizmos", 1, 3, 5);

            var type = AccessTools.TypeByName("VFEAncients.CompGeneTailoringPod");

            // Start gene tailoring operation (after danger warning confirmation)
            MP.RegisterSyncMethod(type, "StartOperation");
            // Cancel operation (before starting it)
            MpCompat.RegisterLambdaMethod(type, "CompGetGizmosExtra", 8);

            // (Dev) instant success/failure
            MpCompat.RegisterLambdaMethod(type, "CompGetGizmosExtra", 9, 10).SetDebugOnly();
            // (Dev) instant finish, random result not synced, as it calls CompleteOperation
            // would cause a tiny conflict, not worth bothering with it
            // (I think it would need to be done without SetDebugOnly, or it would cause issues)

            choosePowerDialogType = AccessTools.TypeByName("VFEAncients.Dialog_ChoosePowers");
            var powerDefType = AccessTools.TypeByName("VFEAncients.PowerDef");
            var tupleType    = typeof(Tuple <,>).MakeGenericType(powerDefType, powerDefType);

            onChosen = CompileCallOnChosen(powerDefType, tupleType);
            MP.RegisterSyncMethod(typeof(VanillaFactionsAncients), nameof(SyncedChoosePower));
            MP.RegisterSyncWorker <Window>(SyncDialogChoosePower, choosePowerDialogType);
            MpCompat.harmony.Patch(AccessTools.DeclaredConstructor(choosePowerDialogType, new[] { typeof(List <>).MakeGenericType(tupleType), typeof(Pawn), typeof(Action <>).MakeGenericType(tupleType) }),
                                   postfix: new HarmonyMethod(typeof(VanillaFactionsAncients), nameof(PostDialogConstructor)));
            MpCompat.harmony.Patch(AccessTools.Method(choosePowerDialogType, nameof(Window.DoWindowContents)),
                                   transpiler: new HarmonyMethod(typeof(VanillaFactionsAncients), nameof(ReplaceButtons)));
        }
        internal static void RegisterSyncWorkers()
        {
            MP.RegisterSyncWorker <Color>(SyncColor);

            var type = typeof(TransportPodsArrivalAction_LandInSpecificCell);

            mapParentField     = AccessTools.Field(type, "mapParent");
            cellField          = AccessTools.Field(type, "cell");
            landInShuttleField = AccessTools.Field(type, "landInShuttle");
            MP.RegisterSyncWorker <TransportPodsArrivalAction_LandInSpecificCell>(SyncLandInSpecificCell, type);

            type = typeof(TransportPodsArrivalAction_FormCaravan);
            arrivalMessageKeyField = AccessTools.Field(type, "arrivalMessageKey");
            MP.RegisterSyncWorker <TransportPodsArrivalAction_FormCaravan>(SyncFormCaravan, type);

            type = typeof(TransportPodsArrivalAction_AttackSettlement);
            attackSettlementField            = AccessTools.Field(type, "settlement");
            attackSettlementArrivalModeField = AccessTools.Field(type, "arrivalMode");
            MP.RegisterSyncWorker <TransportPodsArrivalAction_AttackSettlement>(SyncAttackSettlement, type);

            type = typeof(TransportPodsArrivalAction_GiveGift);
            giveGiftSettlementField = AccessTools.Field(type, "settlement");
            MP.RegisterSyncWorker <TransportPodsArrivalAction_GiveGift>(SyncGiveGifts, type);

            type = typeof(TransportPodsArrivalAction_VisitSettlement);
            visitSettlementField = AccessTools.Field(type, "settlement");
            MP.RegisterSyncWorker <TransportPodsArrivalAction_VisitSettlement>(SyncVisitSettlement, type);

            type      = typeof(TransportPodsArrivalAction_VisitSite);
            siteField = AccessTools.Field(type, "site");
            visitSiteArrivalModeField = AccessTools.Field(type, "arrivalMode");
            MP.RegisterSyncWorker <TransportPodsArrivalAction_VisitSite>(SyncVisitSite, type);
        }
Exemplo n.º 13
0
        public RPGStyleInventory(ModContentPack mod)
        {
            Type type = AccessTools.TypeByName("Sandy_Detailed_RPG_Inventory.Sandy_Detailed_RPG_GearTab");

            MP.RegisterSyncWorker <ITab_Pawn_Gear>(SyncITab, type);
            MP.RegisterSyncMethod(type, "InterfaceDrop").SetContext(SyncContext.MapSelected);
            MP.RegisterSyncMethod(type, "InterfaceIngest").SetContext(SyncContext.MapSelected);
        }
Exemplo n.º 14
0
        public PathAvoidCompat(ModContentPack mod)
        {
            PathAvoidDefType         = AccessTools.TypeByName("PathAvoid.PathAvoidDef");
            Designator_PathAvoidType = AccessTools.TypeByName("PathAvoid.Designator_PathAvoid");
            PathAvoidDefField        = AccessTools.Field(Designator_PathAvoidType, "def");

            MP.RegisterSyncWorker <Designator>(PathAvoidDesignatorSyncWorker, Designator_PathAvoidType);
        }
Exemplo n.º 15
0
        public LightsOut(ModContentPack mod)
        {
            commandType      = AccessTools.TypeByName("LightsOut.Gizmos.KeepOnGizmo");
            parentCompGetter = AccessTools.PropertyGetter(commandType, "ParentComp");

            MP.RegisterSyncMethod(commandType, "ToggleAction");
            MP.RegisterSyncWorker <Command_Toggle>(SyncToggleCommand, commandType);
        }
Exemplo n.º 16
0
 static MultiplayerCompatibility()
 {
     if (MP.enabled)
     {
         MP.RegisterAll();
         MP.RegisterSyncWorker <LockGizmo>(SyncWorkerForLockGizmo);
         MP.RegisterSyncMethod(typeof(RimWorld.CompAssignableToPawn), nameof(LockData.CompAssignableToPawn.TryAssignPawn)).CancelIfAnyArgNull();
     }
 }
Exemplo n.º 17
0
        public FertileFieldsCompat(ModContentPack mod)
        {
            Type type = GrowZoneManagerType = AccessTools.TypeByName("RFF_Code.GrowZoneManager");

            MP.RegisterSyncMethod(type, "ToggleReturnToSoil");
            MP.RegisterSyncMethod(type, "ToggleDesignateReplacements");

            MP.RegisterSyncWorker <MapComponent>(SyncWorkerForGrowZoneManager, type);
        }
 static MultiplayerCompatibility()
 {
     if (MP.enabled)
     {
         MP.RegisterAll();
         MP.RegisterSyncMethod(typeof(Plan.PlanColorManager), nameof(Plan.PlanColorManager.ChangeColor));
         MP.RegisterSyncWorker <Designators.AddDesignator>(SyncWorkerForPlanDesignation);
     }
 }
        public ChoiceOfPsycastsCompat(ModContentPack mod)
        {
            var type = learnPsycastsType = AccessTools.TypeByName("RimWorld.ChoiceOfPsycasts.LearnPsycasts");

            MP.RegisterSyncDelegate(type, "<>c__DisplayClass3_0", "<Choice>b__0");

            levelField  = AccessTools.Field(type, "Level");
            parentField = AccessTools.Field(type, "Parent");
            MP.RegisterSyncWorker <Command_Action>(SyncLearnPsycasts, type);
        }
 public AvoidFriendlyFire(ModContentPack mod)
 {
     {
         var type = AccessTools.TypeByName("AvoidFriendlyFire.ExtendedPawnData");
         MP.RegisterSyncWorker <object>(SyncWorkerFor, type);
     }
     {
         MpCompat.RegisterLambdaDelegate("AvoidFriendlyFire.Pawn_DraftController_GetGizmos_Patch", "Postfix", 1);
     }
 }
        public GiddyUpCoreCompat(ModContentPack mod)
        {
            Type type;

            // Gizmos
            {
                // Release Animals
                MP.RegisterSyncDelegate(
                    AccessTools.TypeByName("GiddyUpCore.Harmony.Pawn_PlayerSettings_GetGizmos"),
                    "<>c__DisplayClass1_0",
                    "<helpIterator>b__2"
                    );

                // Mount
                MP.RegisterSyncDelegate(
                    AccessTools.TypeByName("GiddyUpCore.Utilities.GUC_FloatMenuUtility"),
                    "<>c__DisplayClass0_0",
                    "<AddMountingOptions>b__0"
                    );

                // Dismount
                MP.RegisterSyncDelegate(
                    AccessTools.TypeByName("GiddyUpCore.Utilities.GUC_FloatMenuUtility"),
                    "<>c__DisplayClass0_0",
                    "<AddMountingOptions>b__1"
                    );
            }

            // Sync ExtendedPawnData
            {
                type = AccessTools.TypeByName("GiddyUpCore.Storage.ExtendedDataStorage");

                MpCompat.harmony.Patch(AccessTools.Constructor(type),
                                       postfix: new HarmonyMethod(typeof(GiddyUpCoreCompat), nameof(ExtendedDataStoragePostfix)));

                MpCompat.harmony.Patch(AccessTools.Method(type, "GetExtendedDataFor", new Type[] { typeof(Pawn) }),
                                       postfix: new HarmonyMethod(typeof(GiddyUpCoreCompat), nameof(GetExtendedDataForPostfix)));

                MpCompat.harmony.Patch(AccessTools.Method(type, "DeleteExtendedDataFor", new Type[] { typeof(Pawn) }),
                                       postfix: new HarmonyMethod(typeof(GiddyUpCoreCompat), nameof(DeleteExtendedDataForPostfix)));
            }
            {
                type = AccessTools.TypeByName("GiddyUpCore.Storage.ExtendedPawnData");

                MP.RegisterSyncWorker <object>(ExtendedPawnData, type);
            }

            // Remove Random
            {
                MpCompat.harmony.Patch(AccessTools.Method("GiddyUpCore.Utilities.NPCMountUtility:generateMounts"),
                                       prefix: new HarmonyMethod(typeof(GiddyUpCoreCompat), nameof(GenerateMountsPrefix)),
                                       postfix: new HarmonyMethod(typeof(GiddyUpCoreCompat), nameof(GenerateMountsPostfix)),
                                       transpiler: new HarmonyMethod(typeof(GiddyUpCoreCompat), nameof(GenerateMountsTranspiler)));
            }
        }
Exemplo n.º 22
0
        public ChoiceOfPsycastsCompat(ModContentPack mod)
        {
            var type = learnPsycastsType = AccessTools.TypeByName("RimWorld.ChoiceOfPsycasts.LearnPsycasts");

            MpCompat.RegisterLambdaDelegate(type, "Choice", 1);
            MpCompat.RegisterLambdaDelegate(type, "ChoiceCustom", 1);

            levelField = AccessTools.FieldRefAccess<int>(type, "Level");
            parentField = AccessTools.FieldRefAccess<Pawn>(type, "Parent");
            MP.RegisterSyncWorker<Command_Action>(SyncLearnPsycasts, type);
        }
        static MultiplayerCompatibility()
        {
            if (!MP.enabled)
            {
                return;
            }

            Type type;

            GetMapCompMethod = AccessTools.Method(AccessTools.TypeByName("Hospitality.Hospitality_MapComponent"), "Instance");
            GetCompMethod    = AccessTools.Method("Verse.ThingWithComps:GetComp").MakeGenericMethod(AccessTools.TypeByName("Hospitality.CompGuest"));

            MP.RegisterAll();

            ////bed gizmo
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Building_GuestBed:Swap"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Building_GuestBed:AdjustFee"));

            ////Guest MainTab
            //MP.RegisterSyncMethod(AccessTools.Method("Hospitality.MainTab.PawnColumnWorker_AccomodationArea:SetArea"));
            //MP.RegisterSyncMethod(AccessTools.Method("Hospitality.MainTab.PawnColumnWorker_ShoppingArea:SetArea"));
            //MP.RegisterSyncMethod(AccessTools.Method("Hospitality.MainTab.PawnColumnWorker_Entertain:SetValue"));
            //MP.RegisterSyncMethod(AccessTools.Method("Hospitality.MainTab.PawnColumnWorker_Recruit:SetValue"));

            ////Guest Tab
            //MP.RegisterSyncMethod(AccessTools.Method("Hospitality.GuestUtility:ForceRecruit"));
            //MP.RegisterSyncMethod(AccessTools.Method(AccessTools.TypeByName("Hospitality.CompGuest"),"SendHome"));

            //fields in Hospitality.CompGuest; chat, recruit, arrived, sentAway, guestArea_int, shoppingArea_int
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.CompGuest:SetEntertain"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.CompGuest:SetMakeFriends"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.CompGuest:SetArrived"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.CompGuest:SetSentAway"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.CompGuest:SetGuestArea"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.CompGuest:SetShoppingArea"));

            //fields in Hospitality.MapComponent; defaultInteractionMode, defaultAreaRestriction, defaultAreaShopping
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Hospitality_MapComponent:SetDefaultEntertain"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Hospitality_MapComponent:SetDefaultMakeFriends"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Hospitality_MapComponent:SetDefaultAreaRestriction"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Hospitality_MapComponent:SetDefaultAreaShopping"));
            MP.RegisterSyncMethod(AccessTools.Method("Hospitality.Hospitality_MapComponent:SetRefuseGuestsUntilWeHaveBeds"));

            type = AccessTools.TypeByName("Hospitality.Hospitality_MapComponent");
            MP.RegisterSyncWorker <MapComponent>(SyncWorkerForMapComp, type);

            type = AccessTools.TypeByName("Hospitality.CompGuest");
            MP.RegisterSyncWorker <ThingComp>(SyncWorkerForCompGuest, type);

            hospitalityMultiplayerHarmony.Patch(AccessTools.Method("Hospitality.GenericUtility:DoAreaRestriction"),
                                                transpiler: new HarmonyMethod(typeof(MultiplayerCompatibility), nameof(StopRecursiveCall))
                                                );
        }
        static MultiplayerCompatibility()
        {
            if (!MP.enabled)
            {
                return;
            }
            Type colony = typeof(Dialog_RenameColony);

            MP.RegisterSyncMethod(colony, nameof(Dialog_RenameColony.NamedPublic));
            MP.RegisterSyncWorker <Dialog_RenameColony>(SyncRename, typeof(Dialog_RenameColony));
            MP.RegisterAll();
        }
Exemplo n.º 25
0
        public VanillaGeneticsExpanded(ModContentPack mod)
        {
            // Sync worker
            {
                var type = AccessTools.TypeByName("GeneticRim.Command_SetGenomeList");

                setGenomeListMap      = AccessTools.FieldRefAccess <Map>(type, "map");
                setGenomeListBuilding = AccessTools.FieldRefAccess <Building>(type, "building");

                MP.RegisterSyncWorker <Command>(SyncCommand, type, shouldConstruct: true);
            }

            // RNG
            {
                var constructors = new[]
                {
                    "GeneticRim.CompExploder",
                    "GeneticRim.HediffComp_PeriodicWounds",
                };

                PatchingUtilities.PatchSystemRandCtor(constructors, false);
            }

            // Gizmos
            {
                // Archocentipide former - start and (dev) finish gizmos
                MpCompat.RegisterLambdaMethod("GeneticRim.Building_ArchocentipedeFormer", "GetGizmos", 0, 1)[1].SetDebugOnly();

                // Archowomb - awaken confirmation and (dev) finish gizmo
                MpCompat.RegisterLambdaMethod("GeneticRim.Building_ArchoWomb", "GetGizmos", 1, 2)[1].SetDebugOnly();

                // Mechahybridizer - (dev) finish gizmo
                MpCompat.RegisterLambdaMethod("GeneticRim.Building_Mechahybridizer", "GetGizmos", 0).SetDebugOnly();

                // Age related disease dev gizmo
                MpCompat.RegisterLambdaMethod("GeneticRim.CompApplyAgeDiseases", "GetGizmos", 0).SetDebugOnly();

                // DNA storage bank and mechahybridizer gizmos
                var type = AccessTools.TypeByName("GeneticRim.ArchotechExtractableAnimals_MapComponent");
                MP.RegisterSyncMethod(type, "AddAnimalToCarry");
                MP.RegisterSyncMethod(type, "AddParagonToCarry");

                // DNA storage bank gizmo
                MpCompat.RegisterLambdaDelegate("GeneticRim.Command_SetGenomeList", "ProcessInput", 2);
            }

            // Float menu
            {
                MpCompat.RegisterLambdaDelegate("GeneticRim.CompArchotechGrowthCell", "CompFloatMenuOptions", 0);
            }

            LongEventHandler.ExecuteWhenFinished(LatePatch);
        }
Exemplo n.º 26
0
        static KanbanStockpileLoader()
        {
            var harmony = new Harmony("net.ubergarm.rimworld.mods.kanbanstockpile");

            harmony.PatchAll();

            if (ModLister.GetActiveModWithIdentifier("LWM.DeepStorage") != null)
            {
                IsLWMDeepStorageLoaded = true;
                Log.Message("[KanbanStockpile] Detected LWM Deep Storage is loaded!");
            }
            else
            {
                IsLWMDeepStorageLoaded = false;
                KSLog.Message("[KanbanStockpile] Did *NOT* detect LWM Deep Storage...");
            }

            if (ModLister.GetActiveModWithIdentifier("Uuugggg.StockpileRanking") != null)
            {
                IsStockpileRankingLoaded = true;
                Log.Message("[KanbanStockpile] Detected Uuugggg's StockpileRanking is loaded!");
            }
            else
            {
                IsStockpileRankingLoaded = false;
                KSLog.Message("[KanbanStockpile] Did *NOT* detect Uuugggg's StockpileRanking...");
            }

            // Check for both the original and the re-uploaded one (which is basically the same)
            if ((ModLister.GetActiveModWithIdentifier("Mehni.PickUpAndHaul") != null) ||
                (ModLister.GetActiveModWithIdentifier("Mlie.PickUpAndHaul") != null))
            {
                IsPickUpAndHaulLoaded = true;
                Log.Message("[KanbanStockpile] Detected Mehni or Mlie PickUpAndHaul is loaded!");
                if (KanbanStockpile.Settings.PreventPickUpAndHaulOverHauling)
                {
                    PickUpAndHaul_WorkGiver_HaulToInventory_Patch.ApplyPatch(harmony);
                }
            }
            else
            {
                IsPickUpAndHaulLoaded = false;
                KSLog.Message("[KanbanStockpile] Did *NOT* detect Mehni or Mlie PickUpAndHaul...");
            }

            if (MP.enabled)
            {
                MP.RegisterSyncMethod(typeof(State), nameof(State.Set));
                MP.RegisterSyncMethod(typeof(State), nameof(State.Del));
                MP.RegisterSyncWorker <KanbanSettings>(State.SyncKanbanSettings, typeof(KanbanSettings), false, false);
            }
        }
        public CommonSense(ModContentPack mod)
        {
            manualUnloadEnabledField = AccessTools.Field(AccessTools.TypeByName("CommonSense.Settings"), "gui_manual_unload");
            var type = AccessTools.TypeByName("CommonSense.CompUnloadChecker");

            MP.RegisterSyncWorker <ThingComp>(SyncComp, type);
            shouldUnloadSyncField        = MP.RegisterSyncField(AccessTools.Field(type, "ShouldUnload"));
            getCompUnlockerCheckerMethod = AccessTools.Method(type, "GetChecker");

            MpCompat.harmony.Patch(AccessTools.Method("RimWorld.ITab_Pawn_Gear:DrawThingRow"),
                                   prefix: new HarmonyMethod(typeof(CommonSense), nameof(CommonSensePatchPrefix)),
                                   postfix: new HarmonyMethod(typeof(CommonSense), nameof(CommonSensePatchPostix)));
        }
        public AvoidFriendlyFire(ModContentPack mod)
        {
            Type type;
            {
                type = extendedPawnDataType = AccessTools.TypeByName("AvoidFriendlyFire.ExtendedPawnData");
                MP.RegisterSyncWorker <object>(SyncWorkerFor, type);

                avoidFriendlyFireField = type.GetField("AvoidFriendlyFire");
            }
            {
                type = AccessTools.TypeByName("AvoidFriendlyFire.Pawn_DraftController_GetGizmos_Patch");
                MP.RegisterSyncDelegate(type, "<>c__DisplayClass0_0", "<Postfix>b__1");
            }
        }
        private static void LatePatch()
        {
            // BuildingAltar continuation
            {
                // TempleCardUtility is used for UI drawing, called from BuildingAltar
                var type = AccessTools.TypeByName("Corruption.Worship.TempleCardUtility");
                MP.RegisterSyncDelegate(type, "<>c__DisplayClass4_1", "<OpenDedicationSelectMenu>b__1");
                // We patch the modded method to intercept some of their calls that will need syncing and call them through our methods,
                // as syncing the actual methods themselves will sync way too much (methods might/will be called often)
                MpCompat.harmony.Patch(AccessTools.Method(type, "DrawSermonTemplate"),
                                       prefix: new HarmonyMethod(typeof(CorruptionWorship), nameof(DrawSermonTemplatePrefix)),
                                       postfix: new HarmonyMethod(typeof(CorruptionWorship), nameof(DrawSermonTemplatePostfix)),
                                       transpiler: new HarmonyMethod(typeof(CorruptionWorship), nameof(PatchDrawSermonTemplate)));

                // The previous inner class (<>c__DisplayClass4_1) needs the following one to be synced too, but this one uses sermon
                // which requires a bit more data to sync, so we make SyncWorker manually instead of using RegisterSyncDelegate
                var inner = AccessTools.Inner(type, "<>c__DisplayClass4_0");
                templeCardUtilityInnerAltarField  = AccessTools.FieldRefAccess <Building>(inner, "altar");
                templeCardUtilityInnerSermonField = AccessTools.FieldRefAccess <object>(inner, "template");

                MP.RegisterSyncMethod(typeof(CorruptionWorship), nameof(SyncedInterceptedReceiveMemo));
                MP.RegisterSyncMethod(typeof(CorruptionWorship), nameof(SyncedInterceptedEndSermon));
                MP.RegisterSyncMethod(typeof(CorruptionWorship), nameof(SyncedTryStartSermon)).SetDebugOnly();
                MP.RegisterSyncMethod(typeof(CorruptionWorship), nameof(SyncSimpleSermonData));
            }

            // Dialog_ReligiousRiot, opened when there's enough pawns of different religion
            // Should open for all players, so we assume we can get it/sync it using Find.WindowStack
            {
                religiousRiotType = AccessTools.TypeByName("Corruption.Worship.Dialog_ReligiousRiot");
                MP.RegisterSyncMethod(religiousRiotType, "ChooseNewReligion");
                MP.RegisterSyncMethod(religiousRiotType, "PreserveReligion");
                MP.RegisterSyncWorker <Window>(SyncReligiousRiotDialog, religiousRiotType);
            }

            // Other stuff
            {
                // Rotating worship statue
                var type = AccessTools.TypeByName("Corruption.Worship.Building_WorshipStatue");
                MpCompat.RegisterLambdaMethod(type, "GetGizmos", 0);

                // Debug ring the bell
                type = AccessTools.TypeByName("Corruption.Worship.CompBellTower");
                MpCompat.RegisterLambdaMethod(type, "CompGetGizmosExtra", 0).SetDebugOnly();

                // Drop effigy
                type = AccessTools.TypeByName("Corruption.Worship.CompShrine");
                MP.RegisterSyncMethod(type, "DropEffigy");
            }
        }
        public RimFridgeCompat(ModContentPack mod)
        {
            // Several Gizmos
            {
                MpCompat.RegisterLambdaDelegate("RimFridge.CompRefrigerator", "CompGetGizmosExtra", 1, 2, 3, 4, 5);
                MpCompat.RegisterLambdaMethod("RimFridge.CompToggleGlower", "CompGetGizmosExtra", 0);

                dialogType  = AccessTools.TypeByName("RimFridge.Dialog_RenameFridge");
                fridgeField = AccessTools.Field(dialogType, "fridge");

                MP.RegisterSyncWorker <Dialog_Rename>(SyncFridgeName, dialogType);
                MP.RegisterSyncMethod(dialogType, "SetName");
            }
        }