Feedback round: bots that keep working, Sky Mower, calmer HUD, faster menus, new map
- Robot docks and drone pads with no belt ship straight to Earth; robots widen their rings up to 4x once everything in reach is mown, travel 2.5x faster empty, hoppers 60/150 kg. Drone reach 70 m + 25 m per upgrade. - New Sky Mower: a big mowing drone on a pad, 91 sectors, flies over the grass. - Cut paint follows the blade as a strip, no disc ahead of the machine. - Sector toasts aggregate, chimes and till sounds throttled, toasts moved and narrowed. - Menus no longer rebuild on every money change (price tint follows the wallet), scroll position kept. - Map drawn as one mesh, opens near the player, ME / + / - / GLOBE, scale bar. - Key-art still (x_key) and -shotsize for the store stills; -demobots test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -48,6 +48,55 @@ namespace GrassCutter
|
||||
return b;
|
||||
}
|
||||
|
||||
// ───────────────────────── prices that follow the wallet ─────────────────────────
|
||||
|
||||
/// <summary>A price on something: the wallet only recolours it (<see cref="FollowWallet"/>), it never rebuilds the card.</summary>
|
||||
sealed class Price { public double cost; public string yes, no; }
|
||||
|
||||
/// <summary>
|
||||
/// Mark a button (green when you can pay, grey when you can't) or a tag (with <paramref name="yes"/> when you can) as
|
||||
/// costing this much. The money changes every second once robots and belts run; rebuilding a card for that threw
|
||||
/// away the scroll and the button under the cursor, so a click landed one time in two.
|
||||
/// </summary>
|
||||
public static T Costs<T>(T e, double cost, string yes = "btn-green", string no = "btn-grey") where T : VisualElement
|
||||
{
|
||||
e.AddToClassList("costs");
|
||||
e.userData = new Price { cost = cost, yes = yes, no = no };
|
||||
Tint(e, TeamState.Instance ? TeamState.Instance.Money.Value : 0d);
|
||||
return e;
|
||||
}
|
||||
|
||||
static void Tint(VisualElement e, double money)
|
||||
{
|
||||
if (!(e.userData is Price p)) return;
|
||||
bool can = money >= p.cost;
|
||||
if (!string.IsNullOrEmpty(p.yes)) e.EnableInClassList(p.yes, can);
|
||||
if (!string.IsNullOrEmpty(p.no)) e.EnableInClassList(p.no, !can);
|
||||
}
|
||||
|
||||
/// <summary>Recolour every price on the card a few times a second as the wallet moves.</summary>
|
||||
public static void FollowWallet(VisualElement card, long everyMs = 250)
|
||||
{
|
||||
card.schedule.Execute(() =>
|
||||
{
|
||||
var ts = TeamState.Instance;
|
||||
if (!ts) return;
|
||||
double money = ts.Money.Value;
|
||||
card.Query(className: "costs").ForEach(e => Tint(e, money));
|
||||
}).Every(everyMs);
|
||||
}
|
||||
|
||||
/// <summary>Can the team pay this right now (checked when the button is pressed, not when it was drawn).</summary>
|
||||
public static bool CanPay(double cost) => TeamState.Instance && TeamState.Instance.Money.Value >= cost;
|
||||
|
||||
/// <summary>Rebuild what is inside a scroll view without it jumping back to the top.</summary>
|
||||
public static void KeepScroll(ScrollView list, Vector2 offset)
|
||||
{
|
||||
if (list == null) return;
|
||||
list.scrollOffset = offset;
|
||||
list.schedule.Execute(() => list.scrollOffset = offset);
|
||||
}
|
||||
|
||||
public static VisualElement Img(Texture2D tex, string classes = null, VisualElement parent = null)
|
||||
{
|
||||
var e = El(classes, parent);
|
||||
|
||||
Reference in New Issue
Block a user