mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 23:54:14 +01:00
0098ffca01
## About The Pull Request Currently mech construction icons correspond 1:1 with construction step <img width="1357" height="349" alt="image" src="https://github.com/user-attachments/assets/65763f51-776c-44a7-bc9e-b710db9342a1" /> This means if you want to add a new step in the middle of an existing construction chain you are SOL and have to update everything manually This suuuucks, and you will notice in the picture above that many states *are identical* So I have lightly refactored it: - When steps are instantiated, it will automatically attempt to fill in `icon_state`s according to the index in the list, as it does currently - If the step specifies its own icon state, nothing happens, but index goes up - If the step specifies `skip_state`, it will neither set an icon state nor increment the index This means you can insert a step in the middle of an existing chain with `skip_state = TRUE` if your state has no icon associated, OR you can insert a step with `icon_state = "new_state", skip_state = TRUE` to add your icon without needing to edit every existing icon Now in an ideal world we get rid of this auto-setting system wholesale and set bespoke icon states (`mecha_wires`, `mecha_internal_armor`, etc). We would just define a step's `state = "wired"`, `state = "armored"`, and so on. However, I feel like having the option of using "default states" makes it easier during development. Also I *could* go through and remove all the duplicate states and replace them with `skip_state` instructions but I'm lazy. (Maybe I'll do it anyways though) Other changes - Completing a construction step sends you a chat message about the next step, so you don't have to examine the chassis to find out - Changed around how the Phazon accepts its anomaly core ## Changelog 🆑 Melbert refactor: Refactored how mech icons update mid-construction, report any disappearing mechs please fix: One of the Phazon's mid construction icons was not visible in the past, now it is again. Yippee. /🆑
40 lines
1.9 KiB
Plaintext
40 lines
1.9 KiB
Plaintext
/datum/unit_test/mecha_construction_icons
|
|
|
|
/datum/unit_test/mecha_construction_icons/Run()
|
|
for(var/chassis_type in subtypesof(/obj/item/mecha_parts/chassis))
|
|
var/obj/item/mecha_parts/chassis/chassis = allocate(chassis_type)
|
|
var/datum/component/construction/unordered/mecha_chassis/chassis_comp = chassis.GetComponent(/datum/component/construction/unordered/mecha_chassis)
|
|
if(isnull(chassis_comp))
|
|
TEST_FAIL("[chassis_type]: Mecha chassis without a construction component")
|
|
continue
|
|
chassis_comp.spawn_result()
|
|
|
|
var/datum/component/construction/mecha/construction_comp = chassis.GetComponent(/datum/component/construction/mecha)
|
|
if(isnull(construction_comp))
|
|
TEST_FAIL("[chassis_type]: Finished chassis without a mech construction component")
|
|
continue
|
|
if(!QDELETED(chassis_comp))
|
|
TEST_FAIL("[chassis_type]: Chassis construction component was not deleted after applying the mecha construction component")
|
|
continue
|
|
if(isnull(construction_comp.base_icon))
|
|
continue // apparently valid, for construction which don't have *any* icon states
|
|
|
|
var/list/all_chassis_icon_states = icon_states_fast(chassis.icon)
|
|
var/list/step_icon_states = list()
|
|
for(var/list/step_data as anything in construction_comp.steps)
|
|
var/icon_state = step_data["icon_state"]
|
|
if(isnull(icon_state))
|
|
continue // valid, it just means the step doesn't change the icon
|
|
|
|
if(!(icon_state in all_chassis_icon_states))
|
|
TEST_FAIL("[chassis_type]: Mecha construction step has invalid icon_state '[icon_state]'")
|
|
continue
|
|
|
|
step_icon_states += icon_state
|
|
|
|
for(var/icon_state in all_chassis_icon_states - step_icon_states)
|
|
// little extra logic here to avoid false positives like finding "mech" in "darkmech"
|
|
if(!findtext("test-[icon_state]", "test-[construction_comp.base_icon]"))
|
|
continue
|
|
TEST_FAIL("[chassis_type]: Mecha construction has an unused icon state '[icon_state]'")
|