Files
ZandarioandGitHub 8eed21e1cf Singletons and abstract_types! (#4760)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
I finally have the pleasure of killing decl by giving it a new name and
updated handling.
Also abstract_types now have universal support!

Based on:
Baystation12/Baystation12/pull/32114
Baystation12/Baystation12/pull/32687

## Changelog
🆑
code: /decl/ is now /singleton/
code: abstract_type is now on the /datum/ level
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2022-11-27 23:24:30 -08:00

32 lines
893 B
Plaintext

/singleton/hierarchy
var/name = "Hierarchy"
var/hierarchy_type
var/singleton/hierarchy/parent
var/list/singleton/hierarchy/children
/singleton/hierarchy/New(var/full_init = TRUE)
children = list()
if(!full_init)
return
var/list/all_subtypes = list()
all_subtypes[type] = src
for(var/subtype in subtypesof(type))
all_subtypes[subtype] = new subtype(FALSE)
for(var/subtype in (all_subtypes - type))
var/singleton/hierarchy/subtype_instance = all_subtypes[subtype]
var/singleton/hierarchy/subtype_parent = all_subtypes[subtype_instance.parent_type]
subtype_instance.parent = subtype_parent
dd_insertObjectList(subtype_parent.children, subtype_instance)
/singleton/hierarchy/proc/is_category()
return hierarchy_type == type || children.len
/singleton/hierarchy/proc/is_hidden_category()
return hierarchy_type == type
/singleton/hierarchy/dd_SortValue()
return name