mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Merge pull request #10023 from VOREStation/upstream-merge-8011
[MIRROR] Ported updated decls repository from Neb.
This commit is contained in:
committed by
Chompstation Bot
parent
d268d57227
commit
877dfbc049
@@ -502,3 +502,5 @@ GLOBAL_LIST_INIT(all_volume_channels, list(
|
||||
#define APPEARANCECHANGER_CHANGED_F_HAIRSTYLE "Facial Hair Style"
|
||||
#define APPEARANCECHANGER_CHANGED_F_HAIRCOLOR "Facial Hair Color"
|
||||
#define APPEARANCECHANGER_CHANGED_EYES "Eye Color"
|
||||
|
||||
#define GET_DECL(D) (ispath(D, /decl) ? (decls_repository.fetched_decls[D] || decls_repository.get_decl(D)) : null)
|
||||
|
||||
@@ -74,7 +74,7 @@ SUBSYSTEM_DEF(plants)
|
||||
S.update_seed()
|
||||
|
||||
//Might as well mask the gene types while we're at it.
|
||||
var/list/gene_datums = decls_repository.decls_of_subtype(/decl/plantgene)
|
||||
var/list/gene_datums = decls_repository.get_decls_of_subtype(/decl/plantgene)
|
||||
var/list/used_masks = list()
|
||||
var/list/plant_traits = ALL_GENES
|
||||
while(plant_traits && plant_traits.len)
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
/var/repository/decls/decls_repository = new()
|
||||
// /decl is a subtype used for singletons that should never have more than one instance
|
||||
// in existence at a time. If you want to use a /decl you should use a pattern like:
|
||||
// var/decl/somedecl/mydecl = GET_DECL(/decl/somedecl)
|
||||
|
||||
// /decls are created the first time they are fetched from decls_repository and will
|
||||
// automatically call Initialize() and such when created in this way.
|
||||
|
||||
// decls_repository.get_decls_of_type() and decls_repository.get_decls_of_subtype()
|
||||
// can be used similarly to typesof() and subtypesof(), returning assoc instance lists.
|
||||
|
||||
// The /decl commandments:
|
||||
// I. Thou shalt not create a /decl with new().
|
||||
// II. Thou shalt not del() or qdel() a /decl.
|
||||
// III. Thou shalt not write a decl that relies on arguments supplied to New().
|
||||
// IV. Thou shalt not call Initialize() on a /decl.
|
||||
|
||||
var/repository/decls/decls_repository = new()
|
||||
|
||||
/repository/decls
|
||||
var/list/fetched_decls
|
||||
@@ -11,29 +27,45 @@
|
||||
fetched_decl_types = list()
|
||||
fetched_decl_subtypes = list()
|
||||
|
||||
/repository/decls/proc/decls_of_type(var/decl_prototype)
|
||||
. = fetched_decl_types[decl_prototype]
|
||||
if(!.)
|
||||
. = get_decls(typesof(decl_prototype))
|
||||
fetched_decl_types[decl_prototype] = .
|
||||
|
||||
/repository/decls/proc/decls_of_subtype(var/decl_prototype)
|
||||
. = fetched_decl_subtypes[decl_prototype]
|
||||
if(!.)
|
||||
. = get_decls(subtypesof(decl_prototype))
|
||||
fetched_decl_subtypes[decl_prototype] = .
|
||||
|
||||
/repository/decls/proc/get_decl(var/decl_type)
|
||||
ASSERT(ispath(decl_type))
|
||||
. = fetched_decls[decl_type]
|
||||
if(!.)
|
||||
. = new decl_type()
|
||||
fetched_decls[decl_type] = .
|
||||
|
||||
var/decl/decl = .
|
||||
if(istype(decl))
|
||||
decl.Initialize()
|
||||
|
||||
/repository/decls/proc/get_decls(var/list/decl_types)
|
||||
. = list()
|
||||
for(var/decl_type in decl_types)
|
||||
.[decl_type] = get_decl(decl_type)
|
||||
|
||||
/decls/Destroy()
|
||||
/repository/decls/proc/get_decls_unassociated(var/list/decl_types)
|
||||
. = list()
|
||||
for(var/decl_type in decl_types)
|
||||
. += get_decl(decl_type)
|
||||
|
||||
/repository/decls/proc/get_decls_of_type(var/decl_prototype)
|
||||
. = fetched_decl_types[decl_prototype]
|
||||
if(!.)
|
||||
. = get_decls(typesof(decl_prototype))
|
||||
fetched_decl_types[decl_prototype] = .
|
||||
|
||||
/repository/decls/proc/get_decls_of_subtype(var/decl_prototype)
|
||||
. = fetched_decl_subtypes[decl_prototype]
|
||||
if(!.)
|
||||
. = get_decls(subtypesof(decl_prototype))
|
||||
fetched_decl_subtypes[decl_prototype] = .
|
||||
|
||||
/decl/proc/Initialize()
|
||||
//SHOULD_CALL_PARENT(TRUE)
|
||||
//SHOULD_NOT_SLEEP(TRUE)
|
||||
return
|
||||
|
||||
/decl/Destroy()
|
||||
//SHOULD_CALL_PARENT(FALSE)
|
||||
crash_with("Prevented attempt to delete a decl instance: [log_info_line(src)]")
|
||||
return QDEL_HINT_LETMELIVE // Prevents Decl destruction
|
||||
return QDEL_HINT_LETMELIVE // Prevents decl destruction
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
var/plantname
|
||||
var/potency = 1
|
||||
|
||||
/obj/item/weapon/grown/New(newloc,planttype)
|
||||
/obj/item/weapon/grown/Initialize(ml, planttype)
|
||||
|
||||
..()
|
||||
. = ..()
|
||||
|
||||
var/datum/reagents/R = new/datum/reagents(50)
|
||||
reagents = R
|
||||
R.my_atom = src
|
||||
create_reagents(50)
|
||||
|
||||
//Handle some post-spawn var stuff.
|
||||
if(planttype)
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
/datum/unit_test/integrated_circuit_prefabs_shall_respect_complexity_and_size_contraints/start_test()
|
||||
var/list/failed_prefabs = list()
|
||||
for(var/prefab_type in subtypesof(/decl/prefab/ic_assembly))
|
||||
var/decl/prefab/ic_assembly/prefab = decls_repository.get_decl(prefab_type)
|
||||
var/list/prefab_types = decls_repository.get_decls_of_subtype(/decl/prefab/ic_assembly)
|
||||
for(var/prefab_type in prefab_types)
|
||||
var/decl/prefab/ic_assembly/prefab = prefab_types[prefab_type]
|
||||
var/obj/item/device/electronic_assembly/assembly = prefab.assembly_type
|
||||
|
||||
var/available_size = initial(assembly.max_components)
|
||||
@@ -33,9 +34,9 @@
|
||||
|
||||
/datum/unit_test/integrated_circuit_prefabs_shall_not_fail_to_create/start_test()
|
||||
var/list/failed_prefabs = list()
|
||||
for(var/prefab_type in subtypesof(/decl/prefab/ic_assembly))
|
||||
var/decl/prefab/ic_assembly/prefab = decls_repository.get_decl(prefab_type)
|
||||
|
||||
var/list/prefab_types = decls_repository.get_decls_of_subtype(/decl/prefab/ic_assembly)
|
||||
for(var/prefab_type in prefab_types)
|
||||
var/decl/prefab/ic_assembly/prefab = prefab_types[prefab_type]
|
||||
try
|
||||
var/built_item = prefab.create(get_standard_turf())
|
||||
if(built_item)
|
||||
|
||||
Reference in New Issue
Block a user