Esempio n. 1
0
    private void UiCombatActionBarRender(WidgetContainer container)
    {
        // Get the on-screen content rect
        var contentRect = container.GetContentArea();

        var v21      = true;
        var tbStatus = GameSystems.D20.Actions.curSeqGetTurnBasedStatus()?.Copy();

        if (GameSystems.Combat.IsCombatActive() && tbStatus != null)
        {
            var actor = GameSystems.D20.Initiative.CurrentActor;
            if (uiCombat_10C040B0)
            {
                if (!GameSystems.D20.Actions.IsCurrentlyPerforming(actor))
                {
                    uiCombat_10C040B0 = false;
                    if (GameSystems.Party.IsPlayerControlled(actor))
                    {
                        Logger.Info("Combat UI for {0} ending turn (button)...", actor);
                        GameSystems.Combat.AdvanceTurn(actor);
                    }
                }
            }

            // TODO ui_render_img_file/*0x101e8460*/(dword_10C04088/*0x10c04088*/, uiCombatMainWndX/*0x10c04040*/, uiCombatMainWndY/*0x10c04044*/);
            if (GameSystems.Combat.IsCombatActive() &&
                GameSystems.Party.IsPlayerControlled(GameSystems.D20.Initiative.CurrentActor) && !uiCombat_10C040B0)
            {
                var maxFullRoundMoveDist = UiCombatActionBarGetMaximumMoveDistance();
                if (maxFullRoundMoveDist <= 0.0f)
                {
                    maxFullRoundMoveDist = 30.0f;
                }

                if (actor != actionBarActor)
                {
                    GameSystems.Vagrant.ActionBarStopActivity(_actionBar);
                    actionBarEndingMoveDist = 0;
                }

                float actualRemainingMoveDist;
                if (GameSystems.Vagrant.ActionBarIsActive(_actionBar))
                {
                    actualRemainingMoveDist = GameSystems.Vagrant.ActionBarGetValue(_actionBar);
                    v21 = false;
                }
                else if (GameSystems.D20.Actions.IsCurrentlyPerforming(actor))
                {
                    actualRemainingMoveDist = actionBarEndingMoveDist;
                    v21 = false;
                }
                else
                {
                    actualRemainingMoveDist = UiCombatActionBarGetRemainingMoveDistance(tbStatus);
                }

                var factor = Math.Clamp(actualRemainingMoveDist / maxFullRoundMoveDist, 0.0f, 1.0f);

                var v13 = (int)(contentRect.Height * factor);
                int v14 = v13;
                if (v13 > 0)
                {
                    var a1  = new Render2dArgs();
                    var v22 = new Rectangle(0,
                                            contentRect.Height - v13,
                                            contentRect.Width,
                                            v13);

                    var v23 = new Rectangle(
                        contentRect.X,
                        contentRect.Y + contentRect.Height - v13,
                        v22.Width,
                        v22.Height
                        );
                    a1.customTexture = _combatBarFill.Resource;
                    a1.srcRect       = v22;
                    a1.destRect      = v23;
                    a1.flags         = Render2dFlag.BUFFERTEXTURE;
                    Tig.ShapeRenderer2d.DrawRectangle(ref a1);
                }

                if (UiIntgameActionbarShouldUpdate() && v21)
                {
                    if (GameSystems.D20.Actions.seqCheckFuncs(out tbStatus) != ActionErrorCode.AEC_OK)
                    {
                        UiCombatActionBarDrawButton(contentRect, _combatBarFillInvalid.Resource);
                    }
                    else
                    {
                        var v16 = Math.Clamp(
                            UiCombatActionBarGetRemainingMoveDistance(tbStatus) / maxFullRoundMoveDist, 0.0f, 1.0f);
                        int v17 = v14 - (int)(contentRect.Height * v16);
                        if (v17 >= 1)
                        {
                            Render2dArgs a1      = new Render2dArgs();
                            var          srcRect = new Rectangle(
                                0,
                                contentRect.Height - v14,
                                contentRect.Width,
                                v17
                                );
                            var destRect = new Rectangle(
                                contentRect.X,
                                srcRect.Y + contentRect.Y,
                                srcRect.Width,
                                srcRect.Height
                                );
                            a1.flags = Render2dFlag.BUFFERTEXTURE | Render2dFlag.VERTEXCOLORS |
                                       Render2dFlag.VERTEXALPHA;
                            a1.srcRect       = srcRect;
                            a1.destRect      = destRect;
                            a1.customTexture = _combatBarHighlight2.Resource;

                            var alpha = GameSystems.Vagrant.ActionBarGetValue(_pulseAnimation);
                            var color = new PackedLinearColorA(255, 255, 255, (byte)alpha);
                            a1.vertexColors = new[]
                            {
                                color, color, color, color
                            };

                            if (v17 > 0)
                            {
                                Tig.ShapeRenderer2d.DrawRectangle(ref a1);
                            }
                        }
                    }
                }
            }
            else
            {
                UiCombatActionBarDrawButton(contentRect, _combatBarGrey.Resource);
            }
        }
    }