The file is a UI component that renders a goal card for the player. It displays the goal definition, conditions, and current progress or achievements based on whether the goal has been claimed.
@namespace CitySim
@using CitySim.Match
@inherits Sandbox.UI.Panel
<root class="goal-card @(Goal.Claim != null ? "claimed" : "")">
<div class="goal-card-name">@(GameText.Plain($"{Definition.Icon} {Definition.Name}"))</div>
<div class="goal-condition">@(GameText.Plain(Definition.Description))</div>
@if (Goal.Claim != null) { <div class="goal-status">@(GameText.Get("ui.goal_card_panel.round", Goal.Claim.Round)+string.Join(" · ",Goal.Claim.Awards.Select(a =>GameText.Get("ui.goal_card_panel.vp", City.Match.Players[a.Player].Name, a.Vp))))</div> }
else { <div class="goal-status">@(GameText.Get("ui.goal_card_panel.your_progress", Progress.Detail))</div> }
</root>
@code {
[Parameter] public CityGame City { get; set; }
[Parameter] public PublicGoal Goal { get; set; }
[Parameter] public ObjectiveProgress Progress { get; set; }
GoalDef Definition => GoalLibrary.Get(Goal.GoalId);
string lastKey;
float flip = 10;
protected override void OnParametersSet() { base.OnParametersSet(); var key = $"{Goal.GoalId}:{Goal.Claim?.Round}"; if (key != lastKey) { lastKey = key; flip = 0; } }
public override void Tick() { base.Tick(); if (flip >= 0.35f) return; flip += Time.Delta; var t = Math.Clamp(flip/0.35f,0,1); Style.Set("transform",FormattableString.Invariant($"scaleX({Math.Max(0.02f,1-MathF.Pow(1-t,3)):0.###})")); }
}