fa icon indicating copy to clipboard operation
fa copied to clipboard

Behavior toggles for built units

Open clyfordv opened this issue 2 years ago • 9 comments

Adds a menu to factories that allows toggling stealth/shields etc. for units produced by that factory.

Uses a SimCallback from orders.lua to update a stat on the factory, then applies that in OnStopBeingBuilt of the unit under construction.

Processing for what toggles are available/which factories have which toggles is pushed up as much as possible to blueprints-units. This allows the relevant info to be easily accessible on both sides of the sim/ui divide, and minimizes the processing time when initializing the order popup (likely negligible, but it's the principle of the thing). Also makes overrides (manual or otherwise) much easier to track and apply.

Along with the main changes, it externalizes the pre-check functions in orders.lua (DronePreCheck, ExternalFactoryPreCheck, OnBuildTogglePreCheck) as that section of AddAltOrders was getting unwieldy. Also tightens up the visuals of the OnBuildToggle and Firestate selection popups (the stock width and height didn't look good with the round order buttons, and I wanted the firestate popup to be consistent).

To-do:

  1. Remove hardcoded toggle behavior from remaining units (jamming, cloak, always off etc.) so they can inherit from the factory
  2. Add construction specific tooltip overrides so the purpose of the popup menu is clear
  3. Waterproof the SimCallback to prevent unforeseen stat setting shenanigans
  4. As a toe-dip into non-script-bit OnBuilt behavior toggles, add a "constructed engineers assist factory" toggle alongside the existing options.

clyfordv avatar Oct 10 '23 12:10 clyfordv

Done: X. Remove hardcoded toggle behavior from remaining units (jamming, cloak, always off etc.) so they can inherit from the factory X. Waterproof the SimCallback to prevent unforeseen stat setting shenanigans

To-do:

  1. Tooltips
  2. Re-work auto-deploy to use a StatToggle instead of the weapon toggle so the weapon toggle button doesn't show up (another advantage of the StatToggle system is that it solves a problem where auto-deploy required a little bit of a hacky workaround for the weapon toggle/Transport order).

clyfordv avatar Oct 12 '23 00:10 clyfordv

Most recent changes:

  1. Auto-deploy now uses the StatToggle infrastructure (this also fixes the "set attribute on boolean" issue encountered before)
  2. Maintenance consumption is properly applied to OnBuiltStatToggle units, whether they're created in a carrier or not

to-do:

  • in the future, use merge instead of rebase to avoid jacking up comment history

clyfordv avatar Oct 16 '23 20:10 clyfordv

@clyfordv I'm going to push this pull request into the new year. It's a bit too close to the release at the moment

Garanas avatar Oct 23 '23 14:10 Garanas

~~@clyfordv I may be a bit lost, but where is the menu you're referring to?~~

I didn't git gud, there it is:

image

And it is looking great!

Garanas avatar Oct 25 '23 08:10 Garanas

I'll do a more in-depth review at another time; it is great to see the current state. It's already better than I imagined it would be 😃

Garanas avatar Oct 25 '23 08:10 Garanas

This menu will overlap with queue, wont it?

4z0t avatar Oct 25 '23 11:10 4z0t

I'm not sure; I'll check and confirm 😃

Garanas avatar Oct 25 '23 11:10 Garanas

Menu is in the same spot as the firestate popup (maybe I should highlight that it is a popup, and it isn't just swinging in the wind whenever the order grid is present).

clyfordv avatar Oct 25 '23 16:10 clyfordv