private static void OnGameFinish(Result <ExitStatus, TimeSpan, GClass_GameFinish> result)
        {
            GInterface22    backend         = ClientAppUtils.GetBackendSession();
            MainApplication mainApplication = MainAppUtils.GetMainApp();

            if (backend?.Profile == null || mainApplication == null)
            {
                _gameCallBack(result);
                return;
            }

            ESideType?eSideType = PrivateValueAccessor.GetPrivateFieldValue(mainApplication.GetType(),
                                                                            "esideType_0", mainApplication) as ESideType?;
            Profile profile      = backend.Profile;
            bool    isPlayerScav = false;

            if (eSideType != null && eSideType.GetValueOrDefault() == ESideType.Savage)
            {
                profile      = backend.ProfileOfPet;
                isPlayerScav = true;
            }

            try
            {
                CreatePlayerOwnerMonitor.Catched = false;
                ProfileSaveUtil.SaveProfileProgress(profile, result.Value0, backend.GetPhpSessionId(), isPlayerScav);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            _gameCallBack(result);
        }
Beispiel #2
0
        /// <summary>
        /// Create a new instance of this device
        /// </summary>
        /// <param name="dfbSimulatorWrapper"></param>
        public CodeStoreModel(Wrapper dfbSimulatorWrapper)
        {
            string[] programLines = dfbSimulatorWrapper.Parameters.Code.Replace("\n", "").Split(new char[] { '\r' }, StringSplitOptions.None);
            programLineList = programLines.ToList();

            var states = (Dictionary <int, DFB_v1_40.Asm.CyState>)PrivateValueAccessor.GetPrivateFieldValue(typeof(CyDfbAsm), "m_stateTable", Wrapper.DfbAsm);

            stateTable = states.OrderBy(x => x.Value.Line).Select(x => x.Value).ToList();

            instructionList = new List <CyControlWord>();

            var compactor = (CyDFBOptimizer)Wrapper.GetCyDfbAsmPrivateFieldCurr("m_compactor");

            if (compactor != null)
            {
                instructionAList = Wrapper.DfbAsm.CommandsA.OrderBy(x => x.Line).ToList();
                instructionBList = Wrapper.DfbAsm.CommandsB.OrderBy(x => x.Line).ToList();
                instructionList.AddRange(Wrapper.DfbAsm.CommandsA);
                instructionList.AddRange(Wrapper.DfbAsm.CommandsB);
            }
            else
            {
                instructionAList = Wrapper.DfbAsm.Commands.OrderBy(x => x.Line).ToList();
                instructionBList = Wrapper.DfbAsm.Commands.OrderBy(x => x.Line).ToList();
                instructionList.AddRange(Wrapper.DfbAsm.Commands);
            }

            instructionList = instructionList.OrderBy(x => x.Line).ToList();
        }
        private static void OnGameFinish(Result <ExitStatus, TimeSpan, GameFinish> result)
        {
            MainApplication mainApplication = ClientAppUtils.GetMainApp();
            ISession        session         = ClientAppUtils.GetBackendSession();
            string          backendUrl      = ClientConfig.Config.BackendUrl;

            if (session?.Profile == null || mainApplication == null)
            {
                _gameCallBack(result);
                return;
            }

            ESideType?eSideType    = PrivateValueAccessor.GetPrivateFieldValue(mainApplication.GetType(), "esideType_0", mainApplication) as ESideType?;
            Profile   profile      = session.Profile;
            bool      isPlayerScav = false;

            if (eSideType != null && eSideType.GetValueOrDefault() == ESideType.Savage)
            {
                profile      = session.ProfileOfPet;
                isPlayerScav = true;
            }

            try
            {
                SaveLootUtil.SaveProfileProgress(backendUrl, session.GetPhpSessionId(), result.Value0, profile, isPlayerScav);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            _gameCallBack(result);
        }
        static bool PatchPrefix(ref bool __result, object __instance)
        {
            EPlayerSide playerSide = (EPlayerSide)PrivateValueAccessor.GetPrivateFieldValue(__instance.GetType(), "side", __instance);

            if (playerSide == EPlayerSide.Savage)
            {
                __result = true;

                return(false);
            }

            return(true);
        }
Beispiel #5
0
    public void SetThirst(int multiplier)
    {
        multiplier *= -1;
        float adjustedRate;

        if (multiplier != 0)
        {
            adjustedRate = (multiplier > 0) ? (defaultThirstRate / multiplier) : (defaultThirstRate * (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedRate = defaultThirstRate;
        }
        Stat_Thirst thirst = network.GetLocalPlayer().Stats.stat_thirst;

        PrivateValueAccessor.GetPrivateFieldInfo(typeof(Stat_Thirst), "thirstLostPerSecondDefault").SetValue(thirst, adjustedRate);
        RConsole.Log(modPrefix + "Thirst rate set.");
    }
Beispiel #6
0
    public void SetSharkAttackInterval(int multiplier)
    {
        var   sharks = FindObjectsOfType <Shark>();
        float adjustedInterval;

        if (multiplier != 0)
        {
            adjustedInterval = (multiplier > 0) ? (defaultBiteRaftInterval * multiplier) : (defaultBiteRaftInterval / (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedInterval = defaultBiteRaftInterval;
        }
        foreach (Shark shark in sharks)
        {
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Shark), "searchBlockInterval").SetValue(shark, adjustedInterval);
        }
        RConsole.Log(modPrefix + "Shark bite raft interval set.");
    }
Beispiel #7
0
    public void SetHunger(int multiplier)
    {
        multiplier *= -1;
        float adjustedRate;

        if (multiplier != 0)
        {
            adjustedRate = (multiplier > 0) ? (defaultHungerRate / multiplier) : (defaultHungerRate * (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedRate = defaultHungerRate;
        }
        var hunger = network.GetLocalPlayer().Stats.stat_hunger;

        PrivateValueAccessor.GetPrivateFieldInfo(typeof(Stat_Hunger), "hungerLostPerSecondDefault").SetValue(hunger.Bonus, adjustedRate);
        PrivateValueAccessor.GetPrivateFieldInfo(typeof(Stat_Hunger), "hungerLostPerSecondDefault").SetValue(hunger.Normal, adjustedRate);
        RConsole.Log(modPrefix + "Hunger rate set.");
    }
Beispiel #8
0
    public void SetSharkAttackDamage(int multiplier)
    {
        var sharks = FindObjectsOfType <Shark>();
        int adjustedRaftDamage, adjustedPlayerDamage;

        if (multiplier != 0)
        {
            adjustedRaftDamage   = (multiplier > 0) ? (defaultSharkDamageRaft / multiplier) : (defaultSharkDamageRaft * (Math.Abs(multiplier) + 1));
            adjustedPlayerDamage = (multiplier > 0) ? (defaultSharkDamagePerson / multiplier) : (defaultSharkDamagePerson * (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedRaftDamage   = defaultSharkDamageRaft;
            adjustedPlayerDamage = defaultSharkDamagePerson;
        }
        foreach (Shark shark in sharks)
        {
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Shark), "biteRaftDamage").SetValue(shark, adjustedRaftDamage);
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Shark), "attackPlayerDamage").SetValue(shark, adjustedPlayerDamage);
        }
        RConsole.Log(modPrefix + "Shark damage set.");
    }
Beispiel #9
0
    public void SetDurability(int multiplier)
    {
        List <Item_Base> items = ItemManager.GetAllItems();

        foreach (var item in items)
        {
            int defaultSize = defaultMaxUses[item.UniqueIndex];
            int adjustedSize;
            if (defaultSize <= 1)
            {
                continue;
            }                                   // Avoid changing durability of items that "dont have" durability (like cups)
            if (multiplier != 0)
            {
                adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
            }
            else
            {
                adjustedSize = defaultSize;
            }
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Item_Base), "maxUses").SetValue(item, adjustedSize);
        }
        RConsole.Log(modPrefix + "Durability multiplier set.");
    }
        static bool PatchPrefix(object __instance)
        {
            object weaponController = PrivateValueAccessor.GetPrivateFieldValue(PatcherConstants.FirearmControllerType, PatcherConstants.WeaponControllerFieldName, __instance);

            return((weaponController.GetType().GetField("RemoveFromChamberResult").GetValue(weaponController) == null) ? false : true);
        }
Beispiel #11
0
    public void SetStackSize(int multiplier)
    {
        List <Item_Base> items = ItemManager.GetAllItems();

        // Change base object
        foreach (var item in items)
        {
            int defaultSize = defaultStackSizes[item.UniqueIndex];
            if (defaultSize <= 1)
            {
                continue;
            }                                   // Avoid changing stack size of items that shouldn't stack (like cups)
            int adjustedSize;
            if (multiplier != 0)
            {
                adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
            }
            else
            {
                adjustedSize = defaultSize;
            }
            ItemInstance_Inventory inventory = item.settings_Inventory;
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(ItemInstance_Inventory), "stackSize").SetValue(inventory, adjustedSize);
        }
        RConsole.Log(modPrefix + "BaseItem stack size set.");

        // Change items in players inventory
        foreach (Slot slot in network.GetLocalPlayer().Inventory.allSlots)
        {
            if (!slot.HasValidItemInstance())
            {
                continue;
            }

            Item_Base item        = slot.itemInstance.baseItem;
            int       defaultSize = defaultStackSizes[item.UniqueIndex];
            if (defaultSize <= 1)
            {
                continue;
            }                                   // Avoid changing stack size of items that shouldn't stack (like cups)
            int adjustedSize;
            if (multiplier != 0)
            {
                adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
            }
            else
            {
                adjustedSize = defaultSize;
            }
            ItemInstance_Inventory settings = slot.itemInstance.settings_Inventory;
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(ItemInstance_Inventory), "stackSize").SetValue(settings, adjustedSize);
        }
        RConsole.Log(modPrefix + "Inventory items stack size set.");

        // Change items in storage boxes
        foreach (var storage in StorageManager.allStorages)
        {
            foreach (var slot in storage.GetInventoryReference().allSlots)
            {
                if (!slot.HasValidItemInstance())
                {
                    continue;
                }

                Item_Base item        = slot.itemInstance.baseItem;
                int       defaultSize = defaultStackSizes[item.UniqueIndex];
                if (defaultSize <= 1)
                {
                    continue;
                }                                   // Avoid changing stack size of items that shouldn't stack (like cups)
                int adjustedSize;
                if (multiplier != 0)
                {
                    adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
                }
                else
                {
                    adjustedSize = defaultSize;
                }
                ItemInstance_Inventory settings = slot.itemInstance.settings_Inventory;
                PrivateValueAccessor.GetPrivateFieldInfo(typeof(ItemInstance_Inventory), "stackSize").SetValue(settings, adjustedSize);
            }
        }
        RConsole.Log(modPrefix + "Storage items stack size set.");
    }
 private static void SetMenuControllerFieldValue(MenuController instance, string fieldName, object value)
 {
     PrivateValueAccessor.SetPrivateFieldValue(typeof(MenuController), fieldName, instance, value);
 }
 private static MenuController GetMenuController()
 {
     return(PrivateValueAccessor.GetPrivateFieldValue(typeof(MainApplication),
                                                      kMainControllerFieldName, ClientAppUtils.GetMainApp()) as MenuController);
 }