コード例 #1
0
        public override void GameComponentTick()
        {
            if (Current.Game.tickManager.TicksGame % 100 != 0)
            {
                return;
            }

            TimeSpan timeSinceLastUpdate = DateTime.Now - lastUpdateCycle;

            if (timeSinceLastUpdate.Minutes >= ToolkitPointsSettings.minutesBetweenRewards)
            {
                lastUpdateCycle = DateTime.Now;
                Rewarder.TryRewardingViewers();
            }
        }
コード例 #2
0
        public void DoWindowContents(Rect inRect)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            GameFont original = Text.Font;

            Text.Font = GameFont.Medium;

            // Button texts
            string rewardButtonText = "Reward Viewers";
            string activeLedgerText = "Active Ledger";
            string allLedgersText   = "All Ledgers";

            // Rect regions
            float estBtnWidth = Mathf.Max(
                Text.CalcSize(rewardButtonText).x,
                Text.CalcSize(activeLedgerText).x,
                Text.CalcSize(allLedgersText).x
                )
                                + 24f;

            Rect buttonRegion   = new Rect(inRect.width - estBtnWidth, 0f, estBtnWidth, inRect.height);
            Rect settingsRegion = new Rect(0f, 0f, inRect.width - buttonRegion.width - 23f, inRect.height);

            GUI.BeginGroup(inRect);

            Listing_Standard listing = new Listing_Standard(GameFont.Medium);

            listing.Begin(settingsRegion);
            DrawSettingsPanel(listing);
            listing.End();

            float btnLineHeight = inRect.height * 0.9f;

            Widgets.DrawLineVertical(
                settingsRegion.x + settingsRegion.width + 12f,
                0f,
                btnLineHeight
                );

            listing.Begin(buttonRegion);

            if (listing.ButtonText(rewardButtonText))
            {
                Rewarder.TryRewardingViewers();
            }

            if (listing.ButtonText(activeLedgerText))
            {
                ManageLedgerWindow window = new ManageLedgerWindow();
                Find.WindowStack.TryRemove(window.GetType());
                Find.WindowStack.Add(window);
            }

            if (listing.ButtonText(allLedgersText))
            {
                LedgersWindow window = new LedgersWindow();
                Find.WindowStack.TryRemove(window.GetType());
                Find.WindowStack.Add(window);
            }

            listing.End();
            GUI.EndGroup();

            Text.Font = original;
        }