Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the seed extractor UI a bit less laggy #3498

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions code/modules/hydroponics/seed_extractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@
if(istype(attacking_item, /obj/item/storage/bag/plants))
var/loaded = 0
for(var/obj/item/seeds/to_store in attacking_item.contents)
if(contents.len >= max_seeds)
if(length(contents) >= max_seeds)
to_chat(user, span_warning("[src] is full."))
break
if(!add_seed(to_store, attacking_item))
continue
loaded += 1
loaded = TRUE

if(loaded)
INVOKE_ASYNC(src, TYPE_PROC_REF(/datum, update_static_data_for_all_viewers)) // monkestation edit: lagfixing
to_chat(user, span_notice("You put as many seeds from [attacking_item] into [src] as you can."))
else
to_chat(user, span_warning("There are no seeds in [attacking_item]."))
Expand All @@ -127,23 +128,26 @@
if(!isnull(generated_seeds))
if((user.istate & ISTATE_SECONDARY))
//find all seeds lying on the turf and add them to the machine
var/loaded = FALSE
for(var/obj/item/seeds/seed as anything in generated_seeds)
//machine is full
if(contents.len >= max_seeds)
if(length(contents) >= max_seeds)
to_chat(user, span_warning("[src] is full."))
break
//add seed to machine. second argument is null which means just force move into the machine
add_seed(seed)
if(add_seed(seed))
loaded = TRUE
if(loaded)
to_chat(user, span_notice("You extract some seeds."))
INVOKE_ASYNC(src, TYPE_PROC_REF(/datum, update_static_data_for_all_viewers)) // monkestation edit: lagfixing
return TRUE

else if(istype(attacking_item, /obj/item/seeds))
if(contents.len >= max_seeds)
if(length(contents) >= max_seeds)
to_chat(user, span_warning("[src] is full."))

else if(add_seed(attacking_item, user))
to_chat(user, span_notice("You add [attacking_item] to [src]."))

INVOKE_ASYNC(src, TYPE_PROC_REF(/datum, update_static_data_for_all_viewers)) // monkestation edit: lagfixing
else
to_chat(user, span_warning("You can't seem to add [attacking_item] to [src]."))
return TRUE
Expand Down Expand Up @@ -222,6 +226,7 @@
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "SeedExtractor", name)
ui.set_autoupdate(FALSE) // monkestation edit: lagfixing
ui.open()

/obj/machinery/seed_extractor/ui_data()
Expand Down Expand Up @@ -283,6 +288,7 @@
else
found_seed.forceMove(drop_location())
visible_message(span_notice("[found_seed] falls onto the floor."), null, span_hear("You hear a soft clatter."), COMBAT_MESSAGE_RANGE)
INVOKE_ASYNC(src, TYPE_PROC_REF(/datum, update_static_data_for_all_viewers)) // monkestation edit: lagfixing
. = TRUE

/obj/machinery/seed_extractor/ui_assets(mob/user)
Expand Down
Loading