-
Notifications
You must be signed in to change notification settings - Fork 269
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
Cleaner slimes are now far more intelligent #2350
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2c2fb4a
Cleaner slimes are now far more intelligent
Absolucy 0b8ef76
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy 54a4b62
fixups
Absolucy 2e235d2
bweh why no worky??
Absolucy 91fddfb
whoopsie
Absolucy 0bb3828
wheee it all works now!
Absolucy 0ae2113
Remove unused changes
Absolucy d59d013
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy 6372a1b
used dna mutators are now trash
Absolucy bcd4624
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy 216b145
glue can now be trash too
Absolucy b70c318
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy c5cdc22
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy b14380e
Optimize cleaner slime targeting
Absolucy d4be533
hmmm
Absolucy bbb1caa
bweh
Absolucy 5c54607
bweh
Absolucy 9482da0
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy e5d5b4e
byeah
Absolucy e30e00a
fix inverted logic
Absolucy e79a4c9
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/datum/element/trash_if_empty | ||
var/attach_type = /obj | ||
var/static/list/update_signals = list( | ||
COMSIG_ATOM_ENTERED, | ||
COMSIG_ATOM_EXITED | ||
) | ||
|
||
/datum/element/trash_if_empty/Attach(datum/source) | ||
. = ..() | ||
if(!istype(source, attach_type)) | ||
return ELEMENT_INCOMPATIBLE | ||
register_signals(source) | ||
|
||
/datum/element/trash_if_empty/Detach(datum/source) | ||
unregister_signals(source) | ||
REMOVE_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type)) | ||
return ..() | ||
|
||
/datum/element/trash_if_empty/proc/register_signals(datum/source) | ||
RegisterSignals(source, update_signals, PROC_REF(update_trash_trait)) | ||
|
||
/datum/element/trash_if_empty/proc/unregister_signals(datum/source) | ||
UnregisterSignal(source, update_signals) | ||
|
||
/datum/element/trash_if_empty/proc/update_trash_trait(obj/source) | ||
SIGNAL_HANDLER | ||
if(is_empty_or_trash(source)) | ||
ADD_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type)) | ||
else | ||
REMOVE_TRAIT(source, TRAIT_TRASH_ITEM, ELEMENT_TRAIT(type)) | ||
|
||
/datum/element/trash_if_empty/proc/is_empty_or_trash(obj/source) | ||
. = TRUE | ||
if(!length(source.contents)) | ||
return TRUE | ||
for(var/obj/item/stored_obj in source.contents) | ||
if(!QDELING(stored_obj) && !HAS_TRAIT(stored_obj, TRAIT_TRASH_ITEM)) | ||
return FALSE | ||
|
||
// Variant for reagent containers | ||
/datum/element/trash_if_empty/reagent_container | ||
attach_type = /obj/item/reagent_containers | ||
var/static/list/reagent_signals = list( | ||
COMSIG_REAGENTS_NEW_REAGENT, | ||
COMSIG_REAGENTS_ADD_REAGENT, | ||
COMSIG_REAGENTS_DEL_REAGENT, | ||
COMSIG_REAGENTS_REM_REAGENT | ||
) | ||
|
||
/datum/element/trash_if_empty/reagent_container/register_signals(obj/item/reagent_containers/source) | ||
RegisterSignals(source.reagents, reagent_signals, PROC_REF(update_trash_trait)) | ||
|
||
/datum/element/trash_if_empty/reagent_container/unregister_signals(obj/item/reagent_containers/source) | ||
UnregisterSignal(source.reagents, reagent_signals) | ||
|
||
/datum/element/trash_if_empty/reagent_container/is_empty_or_trash(datum/reagents/source) | ||
return !source?.total_volume | ||
|
||
/// Variant that never considers non-prefilled containers as empty | ||
/datum/element/trash_if_empty/reagent_container/if_prefilled | ||
|
||
/datum/element/trash_if_empty/reagent_container/if_prefilled/is_empty_or_trash(datum/reagents/source) | ||
var/obj/item/reagent_containers/container = source?.my_atom | ||
if(!container.list_reagents) | ||
return FALSE | ||
return ..() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/obj/item/cigbutt/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) | ||
|
||
/obj/item/match/matchburnout() | ||
if(!lit) | ||
return | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/popsicle_stick/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/food/candy_trash/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/storage/fancy/cigarettes/Initialize(mapload) | ||
. = ..() | ||
AddElement(/datum/element/trash_if_empty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/trash/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/obj/item/light/tube/broken/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) | ||
|
||
/obj/item/light/bulb/broken/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) |
25 changes: 25 additions & 0 deletions
25
monkestation/code/modules/projectiles/ammunition/_ammunition.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/obj/item/ammo_casing/Initialize(mapload) | ||
. = ..() | ||
update_trash_trait() | ||
|
||
/obj/item/ammo_casing/newshot() | ||
. = ..() | ||
update_trash_trait() | ||
|
||
/obj/item/ammo_casing/on_accidental_consumption(mob/living/carbon/victim, mob/living/carbon/user, obj/item/source_item, discover_after = TRUE) | ||
. = ..() | ||
update_trash_trait() | ||
|
||
/obj/item/ammo_casing/throw_proj(atom/target, turf/targloc, mob/living/user, params, spread, atom/fired_from) | ||
. = ..() | ||
update_trash_trait() | ||
|
||
/obj/item/ammo_casing/refresh_shot() | ||
. = ..() | ||
update_trash_trait() | ||
|
||
/obj/item/ammo_casing/proc/update_trash_trait() | ||
if(QDELETED(loaded_projectile)) | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, TRAIT_GENERIC) | ||
else | ||
REMOVE_TRAIT(src, TRAIT_TRASH_ITEM, TRAIT_GENERIC) |
3 changes: 3 additions & 0 deletions
3
monkestation/code/modules/reagents/reagent_containers/condiment.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/reagent_containers/condiment/pack/Initialize(mapload, vol) | ||
. = ..() | ||
AddElement(/datum/element/trash_if_empty/reagent_container) |
3 changes: 3 additions & 0 deletions
3
monkestation/code/modules/reagents/reagent_containers/cups/_cup.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/reagent_containers/cup/Initialize(mapload, vol) | ||
. = ..() | ||
AddElement(/datum/element/trash_if_empty/reagent_container/if_prefilled) |
3 changes: 3 additions & 0 deletions
3
monkestation/code/modules/reagents/reagent_containers/cups/glassbottle.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/obj/item/broken_bottle/Initialize(mapload) | ||
. = ..() | ||
ADD_TRAIT(src, TRAIT_TRASH_ITEM, INNATE_TRAIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm giving things that are already in the cleaner slime target typecache the trait, just so this trait can be useful for other things in the future