UI/Player/PlayerObjectivesUI.razor
@using Sandbox;
@using Sandbox.UI;
@using Opium.UI;

@namespace Opium
@inherits PanelComponent

<root class="@( IsVisible ? "active" : "" )">
    <div class="corner" />

    <div class="left">

        @if ( IsVisible )
        {
            <div class="hints" style="flex-direction: column; gap: 8px; margin-top: 6px; padding-bottom: 8px;">
                <div class="input">
                    <label>OBJECTIVES</label>
                    <label class="small">What should I be doing next?..</label>
                </div>
            </div>

            @foreach ( var obj in Opium.ObjectiveSystem.GetObjectives() )
            {
                <div class="row key">
                    <label class="color" style="background-color: @obj.GetStateColor();"></label>
                    <label class="name @(obj.State == Opium.ObjectiveState.Finished ? "strike" : "")">
                        @obj.Name
                    </label>
                </div>
            }

            @if ( Opium.ObjectiveSystem.GetObjectives().Count == 0 )
            {
                <div class="row key">
                    <div class="desc">You don't have any objectives..</div>
                </div>
            }

            @if ( KeyInventory.Items.Count > 0 )
            {
                <div class="hints" style="flex-direction: column; gap: 8px; margin-top: 6px;">
                    <div class="input">
                        <label>ITEMS</label>
                        <label class="small">What am I carrying?</label>
                    </div>
                </div>
                <InventoryContainerPanel @Container=@KeyInventory />
            }

            <div class="spacer" />

            @* 
            @if ( ConsumablesInventory is not null && ConsumablesInventory.Items.Count > 0)
            {
                <div class="title">Items</div>
                <div class="divider" />

                <InventoryContainerPanel @Container=@ConsumablesInventory />
            } *@

            <div class="grow" />
        }
    </div>
</root>

@code
{
    public Opium.PlayerController Player => Components.Get<Opium.PlayerController>( FindMode.EverythingInSelfAndParent );
    public PlayerInventory Inventory => Player.Inventory;

    [Property] public Opium.InventoryContainer KeyInventory { get; set; }
    [Property] public Opium.InventoryContainer StoryItemInventory { get; set; }

    public bool IsVisible { get; set; }

    TimeSince timeSinceShown = 100;

    public void ShowObjectiveUI()
    {
        timeSinceShown = 0;
    }

    [ConVar( "op_ui_objectives_force" )] public static bool Force { get; set; } = false;

    protected override void OnUpdate()
    {
        if ( timeSinceShown <= 5f || Input.Down( "Score" ) )
        {
            IsVisible = true;
        }
        else
        {
            IsVisible = false;
        }

        if ( Force ) IsVisible = true;
	}

    protected override int BuildHash()
    {
        return HashCode.Combine( Time.Delta );
    }
}