Template:CD/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎top: clean up, replaced: {{Documentation subpage → {{Doc/subpage)
No edit summary
 
(21 intermediate revisions by 2 users not shown)
Line 5: Line 5:
== Usage ==
== Usage ==
<nowiki>{{CD|<entity_class>|file1=<file_where_the_class_is_defined_in>}}</nowiki>
<nowiki>{{CD|<entity_class>|file1=<file_where_the_class_is_defined_in>}}</nowiki>
{{tip|If the template fails for some classname try using [[Template:CD2]]}}
{{tip|If the template fails for some classname try using [[Template:CD2]] (usage same as shown above)}}
 
* {{param|1}} - <entity_class>, using ??? will add hidden [[:Category:Unknown Classname]] to the page.
 
* If {{param|file1}} param is specified there will be a lookup using the classname specified in {{param|1}} into [[Template:CD/classlink]] (lookup fallbacks into [[Template:CD/classlink/asw]]) to automatically link to Valve Source SDK 2013 githup repo (multiplayer files are linked).
 
* {{param|goldsrc}} - should be used instead of {{param|file1}} when adding class hierarchy for GoldSrc entities. It adds '<code> (GoldSrc)</code>' to all links and the lookup for file link will use [[Template:CD/classlink/hl]].
{{important|If nothing is found during the file link lookup mentioned above or {{param|nolink}} is specified then {{param|file1}} or {{param|goldsrc}} params are shown as they were specified. If neither file1 or goldsrc params were specified then automatic file link lookup won't be done at all.}}
 
* {{param|base}} can be specified to explicitly choose the superclass which can be useful in case there isn't the desired class in [[Template:CD/superclass]] or it is defined there but it's already used for something else.


== Examples and Parameters ==
== Examples and Parameters ==
{{tip|The arrow symbol left to the class is a separate link that is linking to category representing subclasses of the given class}}
{| class="wikitable"
{| class="wikitable"
|-
|-
| <nowiki>{{CD|CGasCan|file1=somefile.cpp}}</nowiki>
| <nowiki>{{CD|CGasCan|file1=somefile.cpp}}</nowiki>
| {{CD|CGasCan|file1=somefile.cpp}}
| {{CD|CGasCan|file1=somefile.cpp}}
|-
| <nowiki>{{CD|CPhysicsProp|file1=1}}</nowiki>
| {{CD|CPhysicsProp|file1=1}}
|-
| <nowiki>{{CD|???|base=CDynamicProp}}</nowiki>
| {{CD|???|base=CDynamicProp|nocat=1}}
|}
|}
== Template performance ==
CD2 repeatedly calls [[Template:CD/superclass]] to build the hierarchy
CD calls that once and then builds the rest from smaller defined templates like [[Template:CD CPointEntity]]
specifying the <code>base</code> parameter avoids the first [[Template:CD/superclass]] call which makes it stuff even faster
Tests:
<nowiki>{{CD2|Hunter}}</nowiki> CPU time: ~0.26s
<nowiki>{{CD|Hunter}}</nowiki> CPU time: ~0.1s
<nowiki>{{CD|Hunter|base=BossZombiePlayerBot}}</nowiki> CPU time: ~0.03s
{{Expand|title=Hunter class hierarchy|{{CD|Hunter|base=BossZombiePlayerBot}}}}
== See Also ==
* [[List of Source SDK 2013 Entities]]
* [[List of Alien Swarm: Reactive Drop Entities]]
* {{t|code class}}, which this template deprecates
[[Category:CD template]]

Latest revision as of 01:44, 29 May 2025

Edit-copy.png
This is a documentation subpage for Template:CD.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

This template is used to generate class hierarchy for an entity.

Usage

{{CD|<entity_class>|file1=<file_where_the_class_is_defined_in>}}

Tip.pngTip:If the template fails for some classname try using Template:CD2 (usage same as shown above)
  • If {{{file1}}} param is specified there will be a lookup using the classname specified in {{{1}}} into Template:CD/classlink (lookup fallbacks into Template:CD/classlink/asw) to automatically link to Valve Source SDK 2013 githup repo (multiplayer files are linked).
  • {{{goldsrc}}} - should be used instead of {{{file1}}} when adding class hierarchy for GoldSrc entities. It adds ' (GoldSrc)' to all links and the lookup for file link will use Template:CD/classlink/hl.
Icon-Important.pngImportant:If nothing is found during the file link lookup mentioned above or {{{nolink}}} is specified then {{{file1}}} or {{{goldsrc}}} params are shown as they were specified. If neither file1 or goldsrc params were specified then automatic file link lookup won't be done at all.
  • {{{base}}} can be specified to explicitly choose the superclass which can be useful in case there isn't the desired class in Template:CD/superclass or it is defined there but it's already used for something else.

Examples and Parameters

Tip.pngTip:The arrow symbol left to the class is a separate link that is linking to category representing subclasses of the given class
{{CD|CGasCan|file1=somefile.cpp}}
C++ Class hierarchy
CGasCan
CCarriedPropWeapon
CCarriedProp
CBaseBackpackItem
CTerrorWeapon
CWeaponCSBase
CBaseCombatWeapon
CBaseAnimating
CBaseEntity
C++ somefile.cpp
{{CD|CPhysicsProp|file1=1}}
C++ Class hierarchy
CPhysicsProp
CBreakableProp
CBaseProp
CBaseAnimating
CBaseEntity
C++ props.cpp
{{CD|???|base=CDynamicProp}}
C++ Class hierarchy
???
CDynamicProp
CBreakableProp
CBaseProp
CBaseAnimating
CBaseEntity

Template performance

CD2 repeatedly calls Template:CD/superclass to build the hierarchy

CD calls that once and then builds the rest from smaller defined templates like Template:CD CPointEntity

specifying the base parameter avoids the first Template:CD/superclass call which makes it stuff even faster

Tests:

{{CD2|Hunter}} CPU time: ~0.26s

{{CD|Hunter}} CPU time: ~0.1s

{{CD|Hunter|base=BossZombiePlayerBot}} CPU time: ~0.03s

Hunter class hierarchy
C++ Class hierarchy
Hunter
BossZombiePlayerBot
NextBotPlayer
CTerrorPlayer
CCSPlayer
CBaseMultiplayerPlayer
CBasePlayer
CBaseCombatCharacter
CBaseFlex
CBaseAnimatingOverlay
CBaseAnimating
CBaseEntity

See Also