コード例 #1
0
ファイル: HZMapPinToggle.cs プロジェクト: HunterZ/qudmods
 // called whenever starting a new game
 public void mutate(XRL.World.GameObject player)
 {
     // add part unconditionally
     player.AddPart <HZMapPinTogglePart>();
     // also set up ability
     HZMapPinTogglePart.AddAbility(player);
 }
コード例 #2
0
        //private string DEBUG_LAST_GAME_VIEW = string.Empty; //DEBUG ONLY
        private IEnumerator UIMonitorLoop()
        {
            Debug.Log("QudUX Mod: UI Monitor Activated.");
            for (;;)
            {
                while (this.enabled == true)
                {
                    yield return(new WaitForSeconds(coroutineShortYield));
                }

                ////DEBUG ONLY
                //if (GameManager.Instance.CurrentGameView != this.DEBUG_LAST_GAME_VIEW)
                //{
                //    this.DEBUG_LAST_GAME_VIEW = GameManager.Instance.CurrentGameView;
                //    Debug.Log("QudUX Debug: CurrentGameView == " + GameManager.Instance.CurrentGameView);
                //}
                ////DEBUG ONLY

                try
                {
                    if (XRLCore.Core?.Game?.Player?.Body != this.latestGoWithTrackingPart &&
                        XRLCore.Core?.Game?.Player?.Body != null &&
                        !gameObjsWithTrackingPart.CleanContains(XRLCore.Core.Game.Player.Body) &&
                        !XRLCore.Core.Game.Player.Body.IsNowhere())    //IsNowhere forces us to wait for player to be initialized (otherwise duplicate part won't be loaded from serialization yet and we erroneously add another)
                    {
                        XRL.World.GameObject player = XRLCore.Core.Game.Player.Body;
                        this.latestGoWithTrackingPart = player;
                        gameObjsWithTrackingPart.Add(player);
                        //add part to player (or dominated entity, whatever, etc)
                        if (!player.HasPart("Egcb_PlayerUIHelper")) //may already have the part if it was serialized on the player
                        {
                            player.AddPart <Egcb_PlayerUIHelper>(true);
                        }
                        try
                        {
                            new NalathniAppraiseConnector(); //initialize a new NalathniAppraiseExtender object to complete initial analysis and set up static values
                        }
                        catch (Exception ex)
                        {
                            Debug.Log("QudUX Mod: (Warning) Unable to check if compatible 'Appraise Skill' mod is installed. Details:\n" + ex.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log("QudUX Mod: Encountered exception in coroutine segment 1.\n  Exception:" + ex.ToString() + "\nAttempting to resume...");
                }

                if (GameManager.Instance.CurrentGameView == "Inventory" ||
                    GameManager.Instance.CurrentGameView == "Journal" ||
                    GameManager.Instance.CurrentGameView == "ReviewCharacter" ||
                    GameManager.Instance.CurrentGameView == "WorldCreationProgress" ||
                    GameManager.Instance.CurrentGameView == "AbilityManager" ||
                    GameManager.Instance.CurrentGameView == "Trade" ||
                    GameManager.Instance.CurrentGameView == "Popup:AskString")
                {
                    this.UIMode = GameManager.Instance.CurrentGameView;
                    //TODO: should check whether the overlay inventory option is enabled, and don't do anything if it is.
                    try
                    {
                        if (this.UIMode == "Journal")
                        {
                            try
                            {
                                this.JournalExtender = new Egcb_JournalExtender();
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("QudUX Mod: Encountered exception in Journal extender.\n  Exception: " + ex.ToString() + "\nAttempting to resume...");
                            }
                        }
                        else if (this.UIMode == "Inventory")
                        {
                            try
                            {
                                this.InventoryExtender = new Egcb_InventoryExtender();
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("QudUX Mod: Encountered exception in Inventory extender.\n  Exception: " + ex.ToString() + "\nAttempting to resume...");
                            }
                        }
                        else if (this.UIMode == "Trade")
                        {
                            try
                            {
                                Egcb_PlayerUIHelper.SetTraderInteraction();
                                //one time call - don't need to monitor the menu itself
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("QudUX Mod: Encountered exception in Trader extender.\n  Exception: " + ex.ToString() + "\nAttempting to resume...");
                            }
                        }
                        else if (this.UIMode == "ReviewCharacter")
                        {
                            try
                            {
                                this.ReviewCharExtender = new Egcb_ReviewCharExtender();
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("QudUX Mod: Encountered exception in Character Creation extender.\n  Exception: " + ex.ToString() + "\nAttempting to resume...");
                            }
                        }
                        else if (this.UIMode == "WorldCreationProgress")
                        {
                            //Do nothing here (we're only tracking for when this state is removed)
                        }
                        else if (this.UIMode == "Popup:AskString")
                        {
                            //Do nothing here - we'll listen for keypresses in Egcb_UIMonitor.Update() [not actually implemented]
                        }
                        else if (this.UIMode == "AbilityManager")
                        {
                            try
                            {
                                this.AbilityManagerExtender = new Egcb_AbilityManagerExtender();
                                this.AbilityManagerExtender.UpdateAbilityDescriptions();
                                //this is all we need to do for this one - a single update on menu open. No active monitoring/changes in the menu itself.
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("QudUX Mod: Encountered exception in ability description extender.\n  Exception: " + ex.ToString() + "\nAttempting to resume...");
                            }
                        }
                        this.enabled = true;
                    }
                    catch (Exception ex)
                    {
                        Debug.Log("QudUX Mod: Encountered exception in coroutine segment 2.\n  Exception: " + ex.ToString() + "\nAttempting to resume...");
                    }
                    do
                    {
                        yield return(new WaitForSeconds(coroutineShortYield));
                    } while (this.enabled == true);
                }
                else
                {
                    if (!this.coroutineYieldTimes.ContainsKey(GameManager.Instance.CurrentGameView))
                    {
                        this.coroutineYieldTimes.Add(GameManager.Instance.CurrentGameView, coroutineShortYield);
                    }
                    yield return(new WaitForSeconds(this.coroutineYieldTimes[GameManager.Instance.CurrentGameView]));
                }
            }
        }