stitches together some tg code to make swarmers able to eat stuff I think (#10287)

* Update atoms.dm

* add return composition bit

* yeah this'll probably work

* ok

* Update swarmer_act.dm
This commit is contained in:
Theos
2020-11-01 13:28:33 -05:00
committed by GitHub
parent 3d7fa639b5
commit 0d2ab1789f
3 changed files with 35 additions and 4 deletions

View File

@@ -65,3 +65,14 @@ Simple datum which is instanced once per type and is used for every object of sa
o.max_integrity = new_max_integrity
o.force = initial(o.force)
o.throwforce = initial(o.throwforce)
/** Returns the composition of this material.
*
* Mostly used for alloys when breaking down materials.
*
* Arguments:
* - amount: The amount of the material to break down.
* - breakdown_flags: Some flags dictating how exactly this material is being broken down.
*/
/datum/material/proc/return_composition(amount=1, breakdown_flags=NONE)
return list((src) = amount) // Yes we need the parenthesis, without them BYOND stringifies src into "src" and things break.

View File

@@ -1116,6 +1116,25 @@
/atom/proc/intercept_zImpact(atom/movable/AM, levels = 1)
return FALSE
/**Returns the material composition of the atom.
*
* Used when recycling items, specifically to turn alloys back into their component mats.
*
* Exists because I'd need to add a way to un-alloy alloys or otherwise deal
* with people converting the entire stations material supply into alloys.
*
* Arguments:
* - flags: A set of flags determining how exactly the materials are broken down.
*/
/atom/proc/get_material_composition(breakdown_flags=NONE)
. = list()
var/list/cached_materials = custom_materials
for(var/mat in cached_materials)
var/datum/material/material = getmaterialref(mat)
var/list/material_comp = material.return_composition(cached_materials[material], breakdown_flags)
for(var/comp_mat in material_comp)
.[comp_mat] += material_comp[comp_mat]
/**
* Causes effects when the atom gets hit by a rust effect from heretics
*

View File

@@ -28,7 +28,8 @@
return 0
/obj/item/integrate_amount() //returns the amount of resources gained when eating this item
if(materials[/datum/material/iron] || materials[/datum/material/glass])
var/list/mats = get_material_composition(ALL) // Ensures that items made from plasteel, and plas/titanium/plastitaniumglass get integrated correctly.
if(length(mats) && (mats[getmaterialref(/datum/material/iron)] || mats[getmaterialref(/datum/material/glass)]))
return 1
return ..()