コード例 #1
0
        public bool AddObjective(Objective objective, int order, bool alertPlayer, out string result)
        {
            if (!this.AddObjectiveData(objective, ref order, out result))
            {
                return(false);
            }

            //

            var myplayer = CustomPlayerData.GetPlayerData <ObjectivesCustomPlayer>(Main.myPlayer);

            // Load data
            bool isPrevComplete = myplayer?.IsObjectiveByNameComplete(objective.Title) ?? false;

            objective.Initialize(isPrevComplete);

            ObjectivesMod.Instance
            .ObjectivesTabUI
            .AddObjective(objective, order);                            // Initializes objective

            if (!objective.IsComplete.Value && alertPlayer)
            {
                UtilityPanelsTabs.AddTabAlert(ObjectivesMod.UtilityPanelsName, true);

                Main.NewText("New objective added: " + objective.Title, Color.Yellow);

                Main.PlaySound(SoundID.Chat, Main.LocalPlayer.MountedCenter);
            }

            this.NotifySubscribers(objective, true);

            return(true);
        }
コード例 #2
0
ファイル: MyMod.cs プロジェクト: hamstar0/tml-objectives-mod
        public override void PostSetupContent()
        {
            if (!Main.dedServ && Main.netMode != NetmodeID.Server)
            {
                // Add player stats tab
                ModUtilityPanelsMod.Instance.OnUtilityPanelsInitialize += () => {
                    this.ObjectivesTabUI = new UIObjectivesTab(UITheme.Vanilla);

                    UtilityPanelsTabs.AddTab(ObjectivesMod.UtilityPanelsName, this.ObjectivesTabUI);
                };
            }
        }
コード例 #3
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            var mymod = (ObjectivesMod)this.mod;

            try {
                if (mymod.UtilityPanelsHotkey != null && mymod.UtilityPanelsHotkey.JustPressed)
                {
                    if (UtilityPanelsTabs.IsDialogOpen())
                    {
                        UtilityPanelsTabs.CloseDialog();
                    }
                    else
                    {
                        UtilityPanelsTabs.OpenTab(ObjectivesMod.UtilityPanelsName);
                    }
                }
            } catch { }
        }
コード例 #4
0
        ////////////////

        private void LoadWidget()
        {
            var dim = new Vector2(176f, 52f);
            var pos = new Vector2(
                ((float)Main.screenWidth - dim.X) * 0.5f,
                (float)Main.screenHeight - dim.Y - 32f
                );

            //

            this.ObjectivesProgressHUD = new CompletionStatHUD(
                pos: pos,
                dim: dim,
                title: "Objectives",
                stat: () => {
                var mngr = ModContent.GetInstance <ObjectiveManager>();
                ICollection <Objective> objs = mngr.CurrentObjectives.Values;
                int complete = objs.Count(o => o.IsComplete == true);

                return(complete, objs.Count - complete);
            },
                enabler: () => Main.playerInventory
                );

            //

            this.ObjectivesProgressHUD.TitleColor = ObjectiveManager.GetTextColor(false);

            this.ObjectivesProgressHUD.OnClick += (_, __) => {
                UtilityPanelsTabs.OpenTab(ObjectivesMod.UtilityPanelsName);
            };

            //

            HUDElementsLibAPI.AddWidget(this.ObjectivesProgressHUD);
        }