a
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
/*! Material datum
|
||||
|
||||
Simple datum which is instanced once per type and is used for every object of said material. It has a variety of variables that define behavior. Subtyping from this makes it easier to create your own materials.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/datum/material
|
||||
/// What the material is referred to as IC.
|
||||
var/name = "material"
|
||||
/// A short description of the material. Not used anywhere, yet...
|
||||
var/desc = "its..stuff."
|
||||
/// What the material is indexed by in the SSmaterials.materials list. Defaults to the type of the material.
|
||||
var/id
|
||||
|
||||
///Base color of the material, is used for greyscale. Item isn't changed in color if this is null.
|
||||
var/color
|
||||
///Base alpha of the material, is used for greyscale icons.
|
||||
var/alpha
|
||||
///Bitflags that influence how SSmaterials handles this material.
|
||||
// var/init_flags = MATERIAL_INIT_MAPLOAD
|
||||
///Materials "Traits". its a map of key = category | Value = Bool. Used to define what it can be used for
|
||||
var/list/categories = list()
|
||||
///The type of sheet this material creates. This should be replaced as soon as possible by greyscale sheets
|
||||
@@ -22,7 +31,7 @@ Simple datum which is instanced once per type and is used for every object of sa
|
||||
var/value_per_unit = 0
|
||||
///Armor modifiers, multiplies an items normal armor vars by these amounts.
|
||||
var/armor_modifiers = list("melee" = 1, "bullet" = 1, "laser" = 1, "energy" = 1, "bomb" = 1, "bio" = 1, "rad" = 1, "fire" = 1, "acid" = 1)
|
||||
///How beautiful is this material per unit?
|
||||
///How beautiful is this material per unit.
|
||||
var/beauty_modifier = 0
|
||||
///Can be used to override the sound items make, lets add some SLOSHing.
|
||||
var/item_sound_override
|
||||
@@ -30,14 +39,31 @@ Simple datum which is instanced once per type and is used for every object of sa
|
||||
var/turf_sound_override
|
||||
///what texture icon state to overlay
|
||||
var/texture_layer_icon_state
|
||||
///a cached filter for the texture icon
|
||||
///a cached icon for the texture filter
|
||||
var/cached_texture_filter
|
||||
///What type of shard the material will shatter to
|
||||
var/obj/item/shard_type
|
||||
|
||||
|
||||
/** Handles initializing the material.
|
||||
*
|
||||
* Arugments:
|
||||
* - _id: The ID the material should use. Overrides the existing ID.
|
||||
*/
|
||||
/datum/material/proc/Initialize(_id, ...)
|
||||
if(_id)
|
||||
id = _id
|
||||
else if(isnull(id))
|
||||
id = type
|
||||
|
||||
if(texture_layer_icon_state)
|
||||
cached_texture_filter = icon('icons/materials/composite.dmi', texture_layer_icon_state)
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/material/New()
|
||||
. = ..()
|
||||
if(texture_layer_icon_state)
|
||||
var/texture_icon = icon('icons/materials/composite.dmi', texture_layer_icon_state)
|
||||
cached_texture_filter = filter(type="layer", icon=texture_icon, blend_mode = BLEND_INSET_OVERLAY)
|
||||
Initialize()
|
||||
|
||||
///This proc is called when the material is added to an object.
|
||||
/datum/material/proc/on_applied(atom/source, amount, material_flags)
|
||||
@@ -48,8 +74,10 @@ Simple datum which is instanced once per type and is used for every object of sa
|
||||
source.alpha = alpha
|
||||
if(texture_layer_icon_state)
|
||||
ADD_KEEP_TOGETHER(source, MATERIAL_SOURCE(src))
|
||||
source.filters += cached_texture_filter
|
||||
source.add_filter("material_texture_[name]",1,layering_filter(icon=cached_texture_filter,blend_mode=BLEND_INSET_OVERLAY))
|
||||
|
||||
if(alpha < 255)
|
||||
source.opacity = FALSE
|
||||
if(material_flags & MATERIAL_ADD_PREFIX)
|
||||
source.name = "[name] [source.name]"
|
||||
|
||||
@@ -59,7 +87,7 @@ Simple datum which is instanced once per type and is used for every object of sa
|
||||
if(istype(source, /obj)) //objs
|
||||
on_applied_obj(source, amount, material_flags)
|
||||
|
||||
else if(isturf(source, /turf)) //turfs
|
||||
if(istype(source, /turf)) //turfs
|
||||
on_applied_turf(source, amount, material_flags)
|
||||
|
||||
source.mat_update_desc(src)
|
||||
@@ -67,8 +95,9 @@ Simple datum which is instanced once per type and is used for every object of sa
|
||||
///This proc is called when a material updates an object's description
|
||||
/atom/proc/mat_update_desc(/datum/material/mat)
|
||||
return
|
||||
|
||||
///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)
|
||||
/datum/material/proc/on_applied_obj(obj/o, amount, material_flags)
|
||||
if(material_flags & MATERIAL_AFFECT_STATISTICS)
|
||||
var/new_max_integrity = CEILING(o.max_integrity * integrity_modifier, 1)
|
||||
o.modify_max_integrity(new_max_integrity)
|
||||
@@ -92,43 +121,73 @@ Simple datum which is instanced once per type and is used for every object of sa
|
||||
I.hitsound = item_sound_override
|
||||
I.usesound = item_sound_override
|
||||
I.throwhitsound = item_sound_override
|
||||
// I.mob_throw_hit_sound = item_sound_override
|
||||
// I.equip_sound = item_sound_override
|
||||
// I.pickup_sound = item_sound_override
|
||||
// I.drop_sound = item_sound_override
|
||||
|
||||
/datum/material/proc/on_applied_turf(var/turf/T, amount, material_flags)
|
||||
/datum/material/proc/on_applied_turf(turf/T, amount, material_flags)
|
||||
if(isopenturf(T))
|
||||
if(!turf_sound_override)
|
||||
return
|
||||
var/turf/open/O = T
|
||||
O.footstep = turf_sound_override
|
||||
O.barefootstep = turf_sound_override
|
||||
O.clawfootstep = turf_sound_override
|
||||
O.heavyfootstep = turf_sound_override
|
||||
if(turf_sound_override)
|
||||
var/turf/open/O = T
|
||||
O.footstep = turf_sound_override
|
||||
O.barefootstep = turf_sound_override
|
||||
O.clawfootstep = turf_sound_override
|
||||
O.heavyfootstep = turf_sound_override
|
||||
// if(alpha < 255)
|
||||
// T.AddElement(/datum/element/turf_z_transparency, TRUE)
|
||||
return
|
||||
|
||||
///This proc is called when the material is removed from an object.
|
||||
/datum/material/proc/on_removed(atom/source, material_flags)
|
||||
/datum/material/proc/on_removed(atom/source, amount, material_flags)
|
||||
if(material_flags & MATERIAL_COLOR) //Prevent changing things with pre-set colors, to keep colored toolboxes their looks for example
|
||||
if(color)
|
||||
source.remove_atom_colour(FIXED_COLOUR_PRIORITY, color)
|
||||
source.alpha = initial(source.alpha)
|
||||
if(texture_layer_icon_state)
|
||||
source.filters -= cached_texture_filter
|
||||
source.remove_filter("material_texture_[name]")
|
||||
REMOVE_KEEP_TOGETHER(source, MATERIAL_SOURCE(src))
|
||||
source.alpha = initial(source.alpha)
|
||||
|
||||
if(material_flags & MATERIAL_ADD_PREFIX)
|
||||
source.name = initial(source.name)
|
||||
|
||||
if(istype(source, /obj)) //objs
|
||||
on_removed_obj(source, material_flags)
|
||||
if(beauty_modifier) //component/beauty/InheritComponent() will handle the removal.
|
||||
addtimer(CALLBACK(source, /datum.proc/_AddElement, list(/datum/element/beauty, -beauty_modifier * amount)), 0)
|
||||
|
||||
else if(istype(source, /turf)) //turfs
|
||||
on_removed_turf(source, material_flags)
|
||||
if(istype(source, /obj)) //objs
|
||||
on_removed_obj(source, amount, material_flags)
|
||||
|
||||
if(istype(source, /turf)) //turfs
|
||||
on_removed_turf(source, amount, material_flags)
|
||||
|
||||
///This proc is called when the material is removed from an object specifically.
|
||||
/datum/material/proc/on_removed_obj(obj/o, material_flags)
|
||||
/datum/material/proc/on_removed_obj(obj/o, amount, material_flags)
|
||||
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)
|
||||
|
||||
/datum/material/proc/on_removed_turf(turf/T, material_flags)
|
||||
return
|
||||
/datum/material/proc/on_removed_turf(turf/T, amount, material_flags)
|
||||
// if(alpha)
|
||||
// RemoveElement(/datum/element/turf_z_transparency, FALSE)
|
||||
|
||||
/**
|
||||
* This proc is called when the mat is found in an item that's consumed by accident. see /obj/item/proc/on_accidental_consumption.
|
||||
* Arguments
|
||||
* * M - person consuming the mat
|
||||
* * S - (optional) item the mat is contained in (NOT the item with the mat itself)
|
||||
*/
|
||||
/datum/material/proc/on_accidental_mat_consumption(mob/living/carbon/M, obj/item/S)
|
||||
return FALSE
|
||||
|
||||
/** 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.
|
||||
|
||||
Reference in New Issue
Block a user