mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
Refactoring aquariums into components (feat: portable fish tanks) (#87866)
## About The Pull Request I've been meaning to do this for some time. I need this for portable/handheld aquariums/fishtanks to be possible. I'll sprite and code them before I call this PR ready, however suggestions and code reviews are welcome in the meantime. Being a pretty heavy refactor, some things might break (we have more than a few unit tests so perhaps not) while others, coincidentally, might be fixed without me knowing. Anyway I'm sure this PR fixes aquarium beauty, which wasn't really working to begin with because the code was so fucking bad. Nothing really worth of a CL entry tho. TODO: - [x] handheld aquariums, craftable with a kit and little plastic or buyable from the fun vendor ig. - [x] an aquarium upgrade for handheld aquariums to bypass possible restrictions. - [x] update the beauty element to consider items, which shouldn't contribute to the area beauty when held or otherwise not on a turf. ## Why It's Good For The Game This should make handheld aquariums possible. ## Changelog 🆑 refactor: refactored aquariums heavily. Please report any fishy bug. add: Added portable/handheld fish tanks to the game. They can be crafted with an aquarium kit and 5 sheets of plastic. While portable, they cannot store fish that are too big or if there're too many already. This restriction can be removed by using the new "bluespace fish tank kit" techweb item. map: Replaced the lawyer's stationary pet aquarium with a fish tank, so you can carry McGill around. balance: Reduced the iron cost of stationary aquariums a little. /🆑
This commit is contained in:
@@ -17,15 +17,6 @@
|
||||
*/
|
||||
var/dupe_mode = COMPONENT_DUPE_HIGHLANDER
|
||||
|
||||
/**
|
||||
* The type to check for duplication
|
||||
*
|
||||
* `null` means exact match on `type` (default)
|
||||
*
|
||||
* Any other type means that and all subtypes
|
||||
*/
|
||||
var/dupe_type
|
||||
|
||||
/// The datum this components belongs to
|
||||
var/datum/parent
|
||||
|
||||
@@ -57,7 +48,7 @@
|
||||
qdel(src, TRUE, TRUE)
|
||||
return
|
||||
|
||||
_JoinParent(parent)
|
||||
_JoinParent()
|
||||
|
||||
/**
|
||||
* Called during component creation with the same arguments as in new excluding parent.
|
||||
@@ -217,7 +208,7 @@
|
||||
*
|
||||
* Use this to do any special cleanup you might need to do before being deregged from an object
|
||||
*/
|
||||
/datum/component/proc/PreTransfer()
|
||||
/datum/component/proc/PreTransfer(datum/new_parent)
|
||||
return
|
||||
|
||||
/**
|
||||
@@ -328,7 +319,6 @@
|
||||
CRASH("[component_type] attempted instantiation!")
|
||||
|
||||
var/dupe_mode = initial(component_type.dupe_mode)
|
||||
var/dupe_type = initial(component_type.dupe_type)
|
||||
var/uses_sources = (dupe_mode == COMPONENT_DUPE_SOURCES)
|
||||
if(uses_sources && !source)
|
||||
CRASH("Attempted to add a sourced component of type '[component_type]' to '[type]' without a source!")
|
||||
@@ -339,10 +329,7 @@
|
||||
|
||||
raw_args[1] = src
|
||||
if(dupe_mode != COMPONENT_DUPE_ALLOWED && dupe_mode != COMPONENT_DUPE_SELECTIVE && dupe_mode != COMPONENT_DUPE_SOURCES)
|
||||
if(!dupe_type)
|
||||
old_component = GetExactComponent(component_type)
|
||||
else
|
||||
old_component = GetComponent(dupe_type)
|
||||
old_component = GetComponent(component_type)
|
||||
|
||||
if(old_component)
|
||||
switch(dupe_mode)
|
||||
@@ -434,11 +421,11 @@
|
||||
* Removes the component from parent, ends up with a null parent
|
||||
* Used as a helper proc by the component transfer proc, does not clean up the component like Destroy does
|
||||
*/
|
||||
/datum/component/proc/ClearFromParent()
|
||||
/datum/component/proc/ClearFromParent(datum/new_parent)
|
||||
if(!parent)
|
||||
return
|
||||
var/datum/old_parent = parent
|
||||
PreTransfer()
|
||||
PreTransfer(new_parent)
|
||||
_RemoveFromParent()
|
||||
parent = null
|
||||
SEND_SIGNAL(old_parent, COMSIG_COMPONENT_REMOVING, src)
|
||||
@@ -455,16 +442,17 @@
|
||||
if(!target || target.parent == src)
|
||||
return
|
||||
if(target.parent)
|
||||
target.ClearFromParent()
|
||||
target.parent = src
|
||||
var/result = target.PostTransfer()
|
||||
target.ClearFromParent(src)
|
||||
var/result = target.PostTransfer(src)
|
||||
switch(result)
|
||||
if(COMPONENT_INCOMPATIBLE)
|
||||
var/c_type = target.type
|
||||
qdel(target)
|
||||
CRASH("Incompatible [c_type] transfer attempt to a [type]!")
|
||||
|
||||
if(target == AddComponent(target))
|
||||
AddComponent(target)
|
||||
if(!QDELETED(target))
|
||||
target.parent = src
|
||||
target._JoinParent()
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user