Example #1
0
        static bool Stat_GetModifier_Pre(Stat __instance, ref float __result, ref IList <Tag> _tags, ref int baseModifier)
        {
            #region quit
            if (!_multiplicativeStacking)
            {
                return(true);
            }
            #endregion

            DictionaryExt <string, StatStack> multipliers = __instance.m_multiplierStack;
            __result = baseModifier;
            for (int i = 0; i < multipliers.Count; i++)
            {
                if (multipliers.Values[i].HasEnded)
                {
                    multipliers.RemoveAt(i--);
                }
                else if (multipliers.Values[i].SameTags(_tags))
                {
                    float value = multipliers.Values[i].EffectiveValue;
                    if (!__instance.NullifyPositiveStat || value <= 0f)
                    {
                        __result *= (1f + value);
                    }
                }
            }
            return(false);
        }
        public static bool Prefix(ref DictionaryExt <GlobalAudioManager.Sounds, GlobalAudioManager.MusicSource> ___s_musicSources,
                                  ref GlobalAudioManager.Sounds ___s_currentMusic)
        {
            string name = SceneManager.GetActiveScene().name;

            for (int i = 0; i < ___s_musicSources.Values.Count; i++)
            {
                var key   = ___s_musicSources.Keys[i];
                var value = ___s_musicSources.Values[i];

                if (key != ___s_currentMusic && value.SceneName != name)
                {
                    if (CustomAudio.ReplacedClips.Contains(key))
                    {
                        //SL.Log("Game tried to clean up " + key + ", but we skipped it!");
                        continue;
                    }

                    UnityEngine.Object.Destroy(value.Source.gameObject);
                    ___s_musicSources.Remove(key);
                    i--;
                }
            }

            return(false);
        }
Example #3
0
        public void Start(FSPParam param, uint playerId)
        {
            mParam        = param;
            mMinePlayerId = playerId;
            LOG_TAG       = "FSPManager[" + playerId + "]";

            if (!mParam.useLocal)
            {
                mClientLockedFrame = mParam.clientFrameRateMultiple - 1;

                mClient = new FSPClient();
                mClient.SetSessionId((ushort)param.sid);
                mClient.SetFSPAuthInfo(param.authId);
                mClient.Connect(param.host, param.port);
                mClient.SetFSPListener(OnFSPListener);
                mClient.VerifyAuth();
            }
            else
            {
                mClientLockedFrame = param.maxFrameId;
            }

            mFrameCtrl = new FSPFrameController();
            mFrameCtrl.Start(param);

            mFrameBuffer = new DictionaryExt <int, FSPFrame>();

            mIsRunning         = true;
            mGameState         = FSPGameState.Create;
            mCurrentFrameIndex = 0;
        }
Example #4
0
 public void Init()
 {
     m_mapPTLType      = new DictionaryExt <uint, Type>();
     m_mapPID2Listener = new DictionaryExt <uint, PTLListenerHelper>();
     m_lstRspListener  = new List <PTLListenerHelper>();
     m_recvBufferTemp  = new NetBuffer(PTLStreamMaxLen);
     m_sendBufferTemp  = new NetBuffer(PTLStreamMaxLen);
 }
Example #5
0
    private void AISquadManager_TryDeactivateSquad(On.AISquadManager.orig_TryDeactivateSquad orig, AISquadManager self, AISquad _squad)
    {
        List <AISquad> _reserve           = (List <AISquad>)AccessTools.Field(typeof(AISquadManager), "m_squadsInReserve").GetValue(self);
        List <AISquad> _play              = (List <AISquad>)AccessTools.Field(typeof(AISquadManager), "m_squadsInPlay").GetValue(self);
        DictionaryExt <UID, AISquad> _all = (DictionaryExt <UID, AISquad>)AccessTools.Field(typeof(AISquadManager), "m_allSquads").GetValue(self);

        OLogger.Log($"TryDeactivateSquad {(_squad != null ? _squad.name : "(null)")}");
        OLogger.Log($" > All={_all.Count} Play={_play.Count} Reserve={_reserve.Count}");
        orig(self, _squad);
    }
Example #6
0
        public static void Init(Transform viewRoot)
        {
            if (isInit)
            {
                return;
            }
            isInit = true;

            viewRoot = viewRoot;

            mapObjectList = new DictionaryExt <EntityObject, ViewObject>();
            objRecycler   = new Recycler();
        }
Example #7
0
            public static bool Prefix(SplitScreenManager __instance, DictionaryExt <int, SplitPlayer> ___m_localCharacterUIs)
            {
                if (__instance.CurrentSplitType == SplitScreenManager.SplitType.Horizontal)
                {
                    //Orig_DelayedRefresh(__instance, ___m_localCharacterUIs);
                    return(true);
                }
                else
                {
                    RefreshVertical(__instance, ___m_localCharacterUIs);
                }

                return(false);
            }
Example #8
0
            public static void InitMappings(ControlMappingPanel __instance, ControlMappingSection ___m_sectionTemplate,
                                            DictionaryExt <int, ControlMappingSection> ___m_sectionList, Controller ___m_lastJoystickController)
            {
                // filter our custom keybindings for this context
                var filter = s_customKeyDict.Values
                             .Where(it => it.category == CUSTOM_CATEGORY &&
                                    (it.controllerType == ControlType.Both || (int)it.controllerType == (int)__instance.ControllerType));

                // check if any keybindings in "custom" category were defined
                if (!filter.Any())
                {
                    return;
                }

                // set up our custom localization (if not already)
                InitLocalization();

                // set the template active while we clone from it
                ___m_sectionTemplate.gameObject.SetActive(true);
                // Create the UI (copied from how game does it)
                var mapSection = UnityEngine.Object.Instantiate(___m_sectionTemplate, ___m_sectionTemplate.transform.parent);

                // set the template inactive again
                ___m_sectionTemplate.gameObject.SetActive(false);

                // move our custom section to the top
                mapSection.transform.SetAsFirstSibling();

                // Setup our custom map section
                ___m_sectionList.Add(CUSTOM_CATEGORY, mapSection);
                mapSection.ControllerType = __instance.ControllerType;
                mapSection.SetCategory(CUSTOM_CATEGORY);

                // Init the custom keys
                if (__instance.ControllerType == ControlMappingPanel.ControlType.Keyboard)
                {
                    var kbMap = ReInput.mapping.GetKeyboardMapInstance(CUSTOM_CATEGORY, 0);
                    InitCustomSection(mapSection, kbMap, filter);

                    var mouseMap = ReInput.mapping.GetMouseMapInstance(CUSTOM_CATEGORY, 0);
                    InitCustomSection(mapSection, mouseMap, filter);
                }
                else
                {
                    var joyMap = ReInput.mapping.GetJoystickMapInstance(___m_lastJoystickController as Joystick, CUSTOM_CATEGORY, 0);
                    InitCustomSection(mapSection, joyMap, filter);
                }
            }
        internal static void OnEnvironmentSaveLoaded(DictionaryExt <string, CharacterSaveInstanceHolder> charSaves)
        {
            var host = CharacterManager.Instance.GetWorldHostCharacter();

            if (!host || !host.IsPhotonPlayerLocal)
            {
                SL.WasLastSceneReset = false;
                return;
            }

            if (charSaves.TryGetValue(host.UID, out CharacterSaveInstanceHolder holder))
            {
                if (At.GetField(holder.CurrentSaveInstance, "m_loadedScene") is EnvironmentSave loadedScene)
                {
                    var areaHolder = AreaManager.Instance.GetAreaFromSceneName(loadedScene.AreaName);
                    if (areaHolder == null)
                    {
                        SLCharacterSaveManager.SceneResetWanted = true;
                    }
                    else
                    {
                        var area = (AreaManager.AreaEnum)AreaManager.Instance.GetAreaFromSceneName(loadedScene.AreaName).ID;
                        if (IsPermanent(area))
                        {
                            SLCharacterSaveManager.SceneResetWanted = false;
                        }
                        else
                        {
                            float age = (float)(loadedScene.GameTime - EnvironmentConditions.GameTime);
                            SLCharacterSaveManager.SceneResetWanted = AreaManager.Instance.IsAreaExpired(loadedScene.AreaName, age);
                        }
                    }
                }
                else
                {
                    SLCharacterSaveManager.SceneResetWanted = true;
                }
            }
            else
            {
                SLCharacterSaveManager.SceneResetWanted = true;
            }

            SL.WasLastSceneReset = SLCharacterSaveManager.SceneResetWanted;

            SL.Log("Set SceneResetWanted: " + SLCharacterSaveManager.SceneResetWanted);
        }
Example #10
0
    private void AISquadManager_TryActivateSquad(On.AISquadManager.orig_TryActivateSquad orig, AISquadManager self, AISquad _squad, bool _resetPositions)
    {
        List <AISquad> _reserve           = (List <AISquad>)AccessTools.Field(typeof(AISquadManager), "m_squadsInReserve").GetValue(self);
        List <AISquad> _play              = (List <AISquad>)AccessTools.Field(typeof(AISquadManager), "m_squadsInPlay").GetValue(self);
        DictionaryExt <UID, AISquad> _all = (DictionaryExt <UID, AISquad>)AccessTools.Field(typeof(AISquadManager), "m_allSquads").GetValue(self);

        OLogger.Log($"TryActivateSquad {(_squad != null ? _squad.name : "(null)")}");
        OLogger.Log($" > All={_all.Count} Play={_play.Count} Reserve={_reserve.Count}");
        OLogger.Log($" > InReserve={_reserve.Contains(_squad)}");

        /*if (_squad != null && !_reserve.Contains(_squad))
         * {
         *  _reserve.Add(_squad);
         *  AccessTools.Field(typeof(AISquadManager), "m_squadsInReserve").SetValue(self, _reserve);
         * }*/
        orig(self, _squad, _resetPositions);
    }
Example #11
0
        public static void RefreshVertical(SplitScreenManager self, DictionaryExt <int, SplitPlayer> localUIs)
        {
            if (GameDisplayInUI.Instance.gameObject.activeSelf != self.RenderInImage)
            {
                GameDisplayInUI.Instance.gameObject.SetActive(self.RenderInImage);
            }

            for (int i = 0; i < localUIs.Count; i++)
            {
                SplitPlayer splitPlayer    = localUIs.Values[i];
                Vector3     default_OFFSET = CharacterCamera.DEFAULT_OFFSET;
                Vector2     zero           = Vector2.zero;
                Vector2     zero2          = Vector2.zero;
                Rect        splitRect      = new Rect(0f, 0f, 0f, 0f);
                RawImage    rawImage       = (!self.RenderInImage) ? null : GameDisplayInUI.Instance.Screens[i];
                float       foV;
                if (localUIs.Count == 1)
                {
                    splitRect.position = Vector2.zero;
                    splitRect.size     = Vector2.one;
                    foV = OptionManager.Instance.GetFoVSolo(i);
                    if (self.RenderInImage)
                    {
                        rawImage.rectTransform.localScale = Vector3.one;
                        GameDisplayInUI.Instance.Screens[1].gameObject.SetActive(false);
                    }
                    GameDisplayInUI.Instance.SetMultiDisplayActive(false);
                }
                else
                {
                    if (localUIs.Count != 2)
                    {
                        throw new NotImplementedException("Support for more than 2 players is not implemented.");
                    }

                    int num = i + 1;
                    if (self.RenderInImage)
                    {
                        splitRect.position = ((i != 0) ? new Vector2(0.5f, 0f) : Vector2.zero);
                        splitRect.size     = new Vector2(0.5f, 1f);
                    }
                    else
                    {
                        splitRect.position = new Vector2(0.5f * (float)((i != 0) ? 1 : -1), 0f);
                        splitRect.size     = Vector2.one;
                    }

                    foV = OptionManager.Instance.GetFoVSplit(i);
                    default_OFFSET.z = -2.5f;
                    zero2.x          = -0.5f;
                    zero.x           = (float)((num % 2 != 1) ? -1 : 1) * 0.5f;

                    if (self.RenderInImage)
                    {
                        GameDisplayInUI.Instance.Screens[1].gameObject.SetActive(true);
                    }
                }

                CameraSettings settings;
                settings.FoV         = foV;
                settings.SplitRect   = splitRect;
                settings.Offset      = default_OFFSET;
                settings.CameraDepth = 2 * i;
                settings.Image       = rawImage;
                splitPlayer.RefreshSplitScreen(zero, zero2, settings);
            }

            if ((bool)CONFIG.GetValue(Settings.moveGlobalUiToPlayer1.ToString()))
            {
                Vector2 zero3 = Vector2.zero;
                Vector2 zero4 = Vector2.zero;
                if (self.LocalPlayers.Count == 2)
                {
                    zero4.x = -0.5f;
                    zero3.x = 0.5f;
                }

                Vector2 vector           = Vector2.Scale(zero4, MenuManager.Instance.ScreenSize);
                Vector2 anchoredPosition = Vector2.Scale(zero3, vector);

                if (At.GetField(MenuManager.Instance, "m_masterLoading") is LoadingFade loadingFade)
                {
                    RectTransform componentInChildren = loadingFade.GetComponentInChildren <RectTransform>();
                    bool          flag7 = componentInChildren != null;
                    if (flag7)
                    {
                        componentInChildren.sizeDelta        = vector;
                        componentInChildren.anchoredPosition = anchoredPosition;
                    }
                }

                if (At.GetField(MenuManager.Instance, "m_prologueScreen") is ProloguePanel prologuePanel)
                {
                    RectTransform rectTransform = prologuePanel.RectTransform;
                    rectTransform.sizeDelta        = vector;
                    rectTransform.anchoredPosition = anchoredPosition;
                }
            }
        }
Example #12
0
 public Recycler()
 {
     idleObjectList = new DictionaryExt <string, Stack <IRecyclableObject> >();
 }
Example #13
0
 public static void Prefix(DictionaryExt <string, CharacterSaveInstanceHolder> ___m_charSaves)
 {
     SLSaveManager.OnEnvironmentSaveLoaded(___m_charSaves);
 }
Example #14
0
        static void CharacterInventory_InventoryIngredients_Post(CharacterInventory __instance, Tag _craftingStationTag, ref DictionaryExt <int, CompatibleIngredient> _sortedIngredient)
        {
            #region quit
            if (!_craftFromStash || PlayerStash == null)
            {
                return;
            }
            #endregion

            __instance.InventoryIngredients(_craftingStationTag, ref _sortedIngredient, PlayerStash.GetContainedItems());
        }
 private static void TestGenerate(IEnumerable<Operator> operators, Func<double> createConstant, int minimalTreeDepth, string expectedSerializedTree, bool isUnBinOpBalancedTree = false)
 {
     Random random = RandomMock.Setup(EnumerableExtensions.Repeat(i => i * 0.1, 10));
     IDictionary<Operator, double> operatorAndProbabilityMap = new DictionaryExt<Operator, double>(operators.Select((op, i) => new KeyValuePair<Operator, double>(op, i % 2 + 1)));
     FormulaTree formulaTree = FormulaTreeGenerator.Generate(random, operatorAndProbabilityMap, createConstant, minimalTreeDepth, isUnBinOpBalancedTree, 0.3, 0.3);
     Assert.AreEqual(expectedSerializedTree, FormulaTreeSerializer.Serialize(formulaTree).ToLower());
 }
Example #16
0
 public void AddRange(IEnumerable <KeyValuePair <K, V> > e) => DictionaryExt.AddRange(_obj, e);
Example #17
0
        public static void SplitScreenManager_DelayedRefreshSplitScreen_Vertical(On.SplitScreenManager.orig_DelayedRefreshSplitScreen orig, SplitScreenManager self)
        {
            self.CurrentSplitType = SplitScreenManager.SplitType.Vertical;
            DictionaryExt <int, SplitPlayer> privatePart = Utils.GetPrivatePart <DictionaryExt <int, SplitPlayer>, SplitScreenManager>(self, "m_localCharacterUIs");

            if (GameDisplayInUI.Instance.gameObject.activeSelf != self.RenderInImage)
            {
                GameDisplayInUI.Instance.gameObject.SetActive(self.RenderInImage);
            }

            for (int i = 0; i < privatePart.Count; i++)
            {
                SplitPlayer splitPlayer    = privatePart.Values[i];
                Vector3     default_OFFSET = CharacterCamera.DEFAULT_OFFSET;
                Vector2     zero           = Vector2.zero;
                Vector2     zero2          = Vector2.zero;
                Rect        splitRect      = new Rect(0f, 0f, 0f, 0f);
                RawImage    rawImage       = (!self.RenderInImage) ? null : GameDisplayInUI.Instance.Screens[i];
                float       foV;
                if (privatePart.Count == 1)
                {
                    splitRect.position = Vector2.zero;
                    splitRect.size     = Vector2.one;
                    foV = OptionManager.Instance.GetFoVSolo(i);
                    if (self.RenderInImage)
                    {
                        rawImage.rectTransform.localScale = Vector3.one;
                        GameDisplayInUI.Instance.Screens[1].gameObject.SetActive(false);
                    }

                    GameDisplayInUI.Instance.SetMultiDisplayActive(false);
                }
                else
                {
                    if (privatePart.Count != 2)
                    {
                        throw new NotImplementedException("Support for more than 2 players is not implemented.");
                    }

                    int num = i + 1;
                    if (self.RenderInImage)
                    {
                        splitRect.position = ((i != 0) ? new Vector2(0.5f, 0f) : Vector2.zero);
                        splitRect.size     = new Vector2(0.5f, 1f);
                    }
                    else
                    {
                        splitRect.position = new Vector2(0.5f * (float)((i != 0) ? 1 : -1), 0f);
                        splitRect.size     = Vector2.one;
                    }

                    foV = OptionManager.Instance.GetFoVSplit(i);
                    default_OFFSET.z = -2.5f;
                    zero2.x          = -0.5f;
                    zero.x           = (float)((num % 2 != 1) ? -1 : 1) * 0.5f;
                    if (self.RenderInImage)
                    {
                        GameDisplayInUI.Instance.Screens[1].gameObject.SetActive(true);
                    }
                }

                CameraSettings cameraSettings;
                cameraSettings.FoV         = foV;
                cameraSettings.SplitRect   = splitRect;
                cameraSettings.Offset      = default_OFFSET;
                cameraSettings.CameraDepth = 2 * i;
                cameraSettings.Image       = rawImage;
                splitPlayer.RefreshSplitScreen(zero, zero2, cameraSettings);
            }

            if (moveGlobalUiToPlayer1)
            {
                Vector2 zero3 = Vector2.zero;
                Vector2 zero4 = Vector2.zero;
                if (self.LocalPlayers.Count == 2)
                {
                    zero4.x = -0.5f;
                    zero3.x = 0.5f;
                }

                Vector2     vector           = Vector2.Scale(zero4, MenuManager.Instance.ScreenSize);
                Vector2     anchoredPosition = Vector2.Scale(zero3, vector);
                LoadingFade privatePart2     = Utils.GetPrivatePart <LoadingFade, MenuManager>(MenuManager.Instance, "m_masterLoading");
                if (privatePart2 != null)
                {
                    RectTransform componentInChildren = privatePart2.GetComponentInChildren <RectTransform>();
                    if (componentInChildren != null)
                    {
                        componentInChildren.sizeDelta        = vector;
                        componentInChildren.anchoredPosition = anchoredPosition;
                    }
                }

                ProloguePanel privatePart3 = Utils.GetPrivatePart <ProloguePanel, MenuManager>(MenuManager.Instance, "m_prologueScreen");
                if (privatePart3 != null)
                {
                    RectTransform rectTransform = privatePart3.RectTransform;
                    rectTransform.sizeDelta        = vector;
                    rectTransform.anchoredPosition = anchoredPosition;
                }
            }
        }
Example #18
0
        public static bool OnIngredientSelectorClicked(CraftingMenu __instance, int _selectorIndex)
        {
            try
            {
                IngredientSelector[] m_ingredientSelectors         = (IngredientSelector[])AccessTools.Field(typeof(CraftingMenu), "m_ingredientSelectors").GetValue(__instance);
                List <int>           ingredientSelectorCachedItems = (List <int>)AccessTools.Field(typeof(CraftingMenu), "ingredientSelectorCachedItems").GetValue(__instance);
                int m_lastRecipeIndex = (int)AccessTools.Field(typeof(CraftingMenu), "m_lastRecipeIndex").GetValue(__instance);
                List <KeyValuePair <int, Recipe> > m_complexeRecipes = (List <KeyValuePair <int, Recipe> >)AccessTools.Field(typeof(CraftingMenu), "m_complexeRecipes").GetValue(__instance);
                List <RecipeDisplay> m_recipeDisplays = (List <RecipeDisplay>)AccessTools.Field(typeof(CraftingMenu), "m_recipeDisplays").GetValue(__instance);
                DictionaryExt <int, CompatibleIngredient> m_availableIngredients = (DictionaryExt <int, CompatibleIngredient>)AccessTools.Field(typeof(CraftingMenu), "m_availableIngredients").GetValue(__instance);
                CharacterUI      m_characterUI        = (CharacterUI)AccessTools.Field(typeof(CraftingMenu), "m_characterUI").GetValue(__instance);
                ItemListSelector m_tempSelectorWindow = (ItemListSelector)AccessTools.Field(typeof(CraftingMenu), "m_tempSelectorWindow").GetValue(__instance);
                Transform        m_selectorWindowPos  = (Transform)AccessTools.Field(typeof(CraftingMenu), "m_selectorWindowPos").GetValue(__instance);
                bool             m_simpleMode         = (bool)AccessTools.Field(typeof(CraftingMenu), "m_simpleMode").GetValue(__instance);

                IngredientSelector ingredientSelector = m_ingredientSelectors[_selectorIndex];
                ingredientSelectorCachedItems.Clear();
                if (m_lastRecipeIndex != -1)
                {
                    if (m_complexeRecipes[m_lastRecipeIndex].Value.Ingredients[_selectorIndex].ActionType == RecipeIngredient.ActionTypes.AddGenericIngredient)
                    {
                        IList <int> stepCompatibleIngredients = m_recipeDisplays[m_lastRecipeIndex].GetStepCompatibleIngredients(_selectorIndex);
                        for (int i = 0; i < stepCompatibleIngredients.Count; i++)
                        {
                            if (m_availableIngredients.TryGetValue(stepCompatibleIngredients[i], out CompatibleIngredient _outValue) && _outValue.AvailableQty > 0)
                            {
                                ingredientSelectorCachedItems.Add(_outValue.ItemID);
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < m_availableIngredients.Count; j++)
                    {
                        if (m_availableIngredients.Values[j].AvailableQty > 0 || ingredientSelector.AssignedIngredient == m_availableIngredients.Values[j])
                        {
                            // lasyan3 : Disallow cleaning water without cooking pot
                            if (m_availableIngredients.Values[j].IsWaterItem && m_simpleMode)
                            {
                                continue;
                            }
                            // lasyan3 : Disallow use of rancid water
                            //if (m_availableIngredients.Values[j].IsWaterItem && m_availableIngredients.Values[j].ItemPrefab.ItemID == (int)eItemIDs.RancidWater) continue;
                            ingredientSelectorCachedItems.Add(m_availableIngredients.Values[j].ItemID);
                        }
                    }
                }
                if (ingredientSelectorCachedItems.Count > 0)
                {
                    m_tempSelectorWindow = m_characterUI.GetListSelector();
                    if ((bool)m_tempSelectorWindow)
                    {
                        m_tempSelectorWindow.onItemHovered = __instance.RefreshItemDetailDisplay;
                        m_tempSelectorWindow.onItemClicked = delegate(IItemDisplay _display)
                        {
                            __instance.IngredientSelectorHasChanged(_selectorIndex, _display?.RefItem.ItemID ?? (-1));
                            m_tempSelectorWindow.Hide();
                        };
                        m_tempSelectorWindow.Position = (((bool)m_selectorWindowPos) ? m_selectorWindowPos.position : __instance.transform.position);
                        m_tempSelectorWindow.Title    = ingredientSelector.Text;
                        m_tempSelectorWindow.ShowSelector(ingredientSelectorCachedItems, ingredientSelector.gameObject, m_lastRecipeIndex == -1);
                    }
                }
            }
            catch (Exception ex)
            {
                WorkInProgress.Instance.MyLogger.LogError("OnIngredientSelectorClicked: " + ex.Message);
            }
            return(false);
        }
        public static void InventoryIngredients(CharacterInventory __instance, Tag _craftingStationTag, ref DictionaryExt <int, CompatibleIngredient> _sortedIngredient)
        {
            try
            {
                if (InnRentStash.CurrentStash == null || !InnRentStash.CurrentStash.IsInteractable || !InnRentStash.Instance.ConfigStashSharing.Value)
                {
                    return;
                }
                //InnRentStash.MyLogger.LogDebug($"InventoryIngredients for {_craftingStationTag}");

                /*foreach (var m in AccessTools.GetDeclaredMethods(typeof(CharacterInventory)))
                 * {
                 *  InnRentStash.MyLogger.LogDebug($"{m.Name}");
                 *  if (m.Name == "InventoryIngredients")
                 *  {
                 *      foreach (var p in m.GetParameters())
                 *      {
                 *          InnRentStash.MyLogger.LogDebug($"  |- {p.Name} {p.IsOut} {p}");
                 *      }
                 *  }
                 * }*/
                MethodInfo mi = AccessTools.GetDeclaredMethods(typeof(CharacterInventory)).FirstOrDefault(m => m.Name == "InventoryIngredients" &&
                                                                                                          m.GetParameters().Any(p => p.Name == "_items"));
                //InnRentStash.MyLogger.LogDebug($"{mi}");
                //InnRentStash.MyLogger.LogDebug($"Before={_sortedIngredient.Count}");
                mi.Invoke(__instance, new object[] {
                    _craftingStationTag, _sortedIngredient, InnRentStash.CurrentStash.GetContainedItems()
                });
                //InnRentStash.MyLogger.LogDebug($"After={_sortedIngredient.Count}");
            }
            catch (Exception ex)
            {
                InnRentStash.MyLogger.LogError("InventoryIngredients: " + ex.Message);
            }
        }
Example #20
0
 public void Init()
 {
     m_mapConnection = new DictionaryExt <uint, IConnection>();
 }
Example #21
0
 public void AddRange(IReadOnlyCollection <KeyValuePair <K, V> > s) => DictionaryExt.AddRange(_obj, s);
    private void DefeatScenariosContainer_StartInit(On.DefeatScenariosContainer.orig_StartInit orig, DefeatScenariosContainer self)
    {
        orig(self);
        try
        {
            DictionaryExt <string, DefeatScenario> m_events = (DictionaryExt <string, DefeatScenario>)AccessTools.Field(typeof(DefeatScenariosContainer), "m_events").GetValue(self);
            //OLogger.Log($"Count={m_events.Count}");
            for (int i = 0; i < m_events.Count; i++)
            {
                OLogger.Log($"{i}={m_events.Values[i].GetType().Name}");
                DefeatScenario _scenario = m_events.Values[i];
                if (_scenario is DefeatScenarioRespawn)
                {
                    //OLogger.Log($"DefeatScenarioRespawn");
                    DefeatScenarioRespawn test = _scenario as DefeatScenarioRespawn;

                    /*OLogger.Log($"AffectBackpack={test.AffectBackpack}");
                     * OLogger.Log($"RespawnAnimation={test.RespawnAnimation}");
                     * OLogger.Log($"SpawnSelectionType={test.SpawnSelectionType}");
                     * OLogger.Log($"m_respawnTimeLapse={(RespawnTimeLapseType)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_respawnTimeLapse").GetValue(test)}");*/
                    StatAffect s;
                    ChangeType c;
                    Vector2    r;
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_burntHealthModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_burntHealthModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_burntManaModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_burntManaModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_burntStaminaModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_burntStaminaModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_drinkModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_drinkModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_foodModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_foodModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_healthModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_healthModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_manaModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_manaModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_sleepModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_sleepModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_staminaModifer").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_staminaModifier={c} - {r}");
                    }
                    s = (StatAffect)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_temperatureModifier").GetValue(test);
                    c = (ChangeType)AccessTools.Field(typeof(StatAffect), "m_changeType").GetValue(s);
                    r = (Vector2)AccessTools.Field(typeof(StatAffect), "m_ratio").GetValue(s);
                    if (!s.IsUnchanged)
                    {
                        OLogger.Log($"m_temperatureModifier={c} - {r}");
                    }

                    //OLogger.Log($"ContractedStatuses_CNT={((StatusEffectContraction[])AccessTools.Field(typeof(DefeatScenarioRespawn), "ContractedStatuses").GetValue(test)).Length}");
                    foreach (var item in (StatusEffectContraction[])AccessTools.Field(typeof(DefeatScenarioRespawn), "ContractedStatuses").GetValue(test))
                    {
                        StatusEffect se = (StatusEffect)AccessTools.Field(typeof(StatusEffectContraction), "m_statusEffect").GetValue(item);
                        int          m_chancesToContract = (int)AccessTools.Field(typeof(StatusEffectContraction), "m_chancesToContract").GetValue(item);
                        OLogger.Log($"Status={se} ({m_chancesToContract}%)");
                    }

                    /*OLogger.Log($"m_addedQuestEvents_CNT={((QuestEventReference[])AccessTools.Field(typeof(DefeatScenarioRespawn), "m_addedQuestEvents").GetValue(test)).Length}");
                     * OLogger.Log($"m_defeatSpawns_CNT={((DefeatSpawn[])AccessTools.Field(typeof(DefeatScenarioRespawn), "m_defeatSpawns").GetValue(test)).Length}");
                     * foreach (var item in (DefeatSpawn[])AccessTools.Field(typeof(DefeatScenarioRespawn), "m_defeatSpawns").GetValue(test))
                     * {
                     *  OLogger.Log($"   {item.DefeatScenario.GetType().Name}");
                     * }
                     *
                     * OLogger.Log($"m_nextTimeSlots_CNT={((EnvironmentConditions.TimeOfDayTimeSlot[])AccessTools.Field(typeof(DefeatScenarioRespawn), "m_nextTimeSlots").GetValue(test)).Length}");
                     * OLogger.Log($"m_removedQuestEvents_CNT={((QuestEventReference[])AccessTools.Field(typeof(DefeatScenarioRespawn), "m_removedQuestEvents").GetValue(test)).Length}");
                     *
                     * /*OLogger.Log($"m_hourRange={(Vector2)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_hourRange").GetValue(test)}");
                     * OLogger.Log($"m_lastSpawn={(int)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_lastSpawn").GetValue(test)}");
                     * OLogger.Log($"m_nextTimeSlotJumpRange={(Vector2)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_nextTimeSlotJumpRange").GetValue(test)}");*/
                    //OLogger.Log($"m_samePlacePos={(Vector3)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_samePlacePos").GetValue(test)}");
                    //OLogger.Log($"m_samePlaceSpawnIndex={(int)AccessTools.Field(typeof(DefeatScenarioRespawn), "m_samePlaceSpawnIndex").GetValue(test)}");
                }
            }
        }
        catch (Exception ex)
        {
            OLogger.Error(ex.Message);
        }
    }
        private static void TestCreateGrammar(IEnumerable<Operator> operators)
        {
            IEnumerable<string> expectedFromSymbols = new[] { "V", "C", "InfGuard", "RegOp2Operands", "OpNode", "OpOrOp0NodeOperands", "OpOrVNodeOperands", "OpOrVNode" };
            expectedFromSymbols = expectedFromSymbols.Concat(operators.GroupBy(op => op.Arity).Select(g => "Op" + g.Key + "Node"))
                .Concat(operators.Where(op => op.Arity > 0).Select(op => op.Name + "Node"));

            expectedFromSymbols = expectedFromSymbols.OrderBy(s => s);

            Random random = RandomMock.Setup(EnumerableExtensions.Repeat(i => i * 0.1, 10));
            IDictionary<Operator, double> operatorAndProbabilityMap = new DictionaryExt<Operator, double>(operators.Select((op, i) => new KeyValuePair<Operator, double>(op, i % 2 + 1)));
            Grammar<Operator> grammar = FormulaTreeGenerator.CreateGrammar(random, operatorAndProbabilityMap, () => 0, 1, false, 0.3, 0.3);
            IEnumerable<string> fromSymbols = grammar.Rules.Select(r => r.From.Name).OrderBy(s => s);
            Assert.AreElementsEqual(expectedFromSymbols.ToArray(), fromSymbols.ToArray());
        }
Example #24
0
 partial void OnInitBegin()
 {
     _logger.Trace();
     this._DicNodes = new DictionaryExt <string, ITreeConfigNode>(1000, true, true,
                                                                  (ki, v) => { }, (kr, v) => { }, () => { });
 }