Porting a couple material datums code updates and fixes.

This commit is contained in:
Ghommie
2020-03-04 15:59:46 +01:00
parent 7a539d0a78
commit f2c8a7cd6f
28 changed files with 70 additions and 72 deletions
+7 -7
View File
@@ -42,7 +42,7 @@
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/OnExamine)
for(var/mat in mat_list) //Make the assoc list ref | amount
var/datum/material/M = getmaterialref(mat) || mat
var/datum/material/M = SSmaterials.GetMaterialRef(mat)
materials[M] = 0
/datum/component/material_container/proc/OnExamine(datum/source, mob/user, list/examine_list)
@@ -130,7 +130,7 @@
/// For inserting an amount of material
/datum/component/material_container/proc/insert_amount_mat(amt, var/datum/material/mat)
if(!istype(mat))
mat = getmaterialref(mat)
mat = SSmaterials.GetMaterialRef(mat)
if(amt > 0 && has_space(amt))
var/total_amount_saved = total_amount
if(mat)
@@ -145,7 +145,7 @@
/// Uses an amount of a specific material, effectively removing it.
/datum/component/material_container/proc/use_amount_mat(amt, var/datum/material/mat)
if(!istype(mat))
mat = getmaterialref(mat)
mat = SSmaterials.GetMaterialRef(mat)
var/amount = materials[mat]
if(mat)
if(amount >= amt)
@@ -157,7 +157,7 @@
/// Proc for transfering materials to another container.
/datum/component/material_container/proc/transer_amt_to(var/datum/component/material_container/T, amt, var/datum/material/mat)
if(!istype(mat))
mat = getmaterialref(mat)
mat = SSmaterials.GetMaterialRef(mat)
if((amt==0)||(!T)||(!mat))
return FALSE
if(amt<0)
@@ -190,7 +190,7 @@
for(var/x in mats) //Loop through all required materials
var/datum/material/req_mat = x
if(!istype(req_mat))
req_mat = getmaterialref(req_mat) //Get the ref if necesary
req_mat = SSmaterials.GetMaterialRef(req_mat) //Get the ref if necesary
if(!materials[req_mat]) //Do we have the resource?
return FALSE //Can't afford it
var/amount_required = mats[x] * multiplier
@@ -251,7 +251,7 @@
var/datum/material/req_mat = x
if(!istype(req_mat))
if(ispath(req_mat)) //Is this an actual material, or is it a category?
req_mat = getmaterialref(req_mat) //Get the ref
req_mat = SSmaterials.GetMaterialRef(req_mat) //Get the ref
else // Its a category. (For example MAT_CATEGORY_RIGID)
if(!has_enough_of_category(req_mat, mats[req_mat], multiplier)) //Do we have enough of this category?
@@ -316,5 +316,5 @@
/// Returns the amount of a specific material in this container.
/datum/component/material_container/proc/get_material_amount(var/datum/material/mat)
if(!istype(mat))
mat = getmaterialref(mat)
mat = SSmaterials.GetMaterialRef(mat)
return(materials[mat])
+17 -15
View File
@@ -41,20 +41,21 @@ Simple datum which is instanced once per type and is used for every object of sa
///This proc is called when the material is added to an object specifically.
/datum/material/proc/on_applied_obj(var/obj/o, amount, material_flags)
var/new_max_integrity = CEILING(o.max_integrity * integrity_modifier, 1)
o.modify_max_integrity(new_max_integrity)
o.force *= strength_modifier
o.throwforce *= strength_modifier
if(material_flags & MATERIAL_AFFECT_STATISTICS)
var/new_max_integrity = CEILING(o.max_integrity * integrity_modifier, 1)
o.modify_max_integrity(new_max_integrity)
o.force *= strength_modifier
o.throwforce *= strength_modifier
var/list/temp_armor_list = list() //Time to add armor modifiers!
var/list/temp_armor_list = list() //Time to add armor modifiers!
if(!istype(o.armor))
return
var/list/current_armor = o.armor?.getList()
if(!istype(o.armor))
return
var/list/current_armor = o.armor?.getList()
for(var/i in current_armor)
temp_armor_list[i] = current_armor[i] * armor_modifiers[i]
o.armor = getArmor(arglist(temp_armor_list))
for(var/i in current_armor)
temp_armor_list[i] = current_armor[i] * armor_modifiers[i]
o.armor = getArmor(arglist(temp_armor_list))
///This proc is called when the material is removed from an object.
/datum/material/proc/on_removed(atom/source, material_flags)
@@ -71,7 +72,8 @@ Simple datum which is instanced once per type and is used for every object of sa
///This proc is called when the material is removed from an object specifically.
/datum/material/proc/on_removed_obj(var/obj/o, amount, material_flags)
var/new_max_integrity = initial(o.max_integrity)
o.modify_max_integrity(new_max_integrity)
o.force = initial(o.force)
o.throwforce = initial(o.throwforce)
if(material_flags & MATERIAL_AFFECT_STATISTICS)
var/new_max_integrity = initial(o.max_integrity)
o.modify_max_integrity(new_max_integrity)
o.force = initial(o.force)
o.throwforce = initial(o.throwforce)