{"id":270,"date":"2010-03-05T18:08:47","date_gmt":"2010-03-06T02:08:47","guid":{"rendered":"http:\/\/technofovea.com\/blog\/?p=270"},"modified":"2010-03-05T18:12:45","modified_gmt":"2010-03-06T02:12:45","slug":"fgd-api-example","status":"publish","type":"post","link":"https:\/\/technofovea.com\/blog\/archives\/270","title":{"rendered":"FGD API example"},"content":{"rendered":"<p>Just a sample from the FGD code I wrote for the <a href=\"http:\/\/technofovea.com\/blog\/projects\/hl2parse\">Hl2Parse library<\/a>. This snippet loads the TF2 FGD file and then re-outputs the FGD format to show it has parsed everything. It also prints the &#8220;default&#8221; version and then the &#8220;combined&#8221; version which collapses all the inheritance.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\nfinal String fgdPath = &quot;...&quot;;\r\nFgdSpec spec = new FgdSpec();\r\nspec.loadFrom(new File(fgd));\r\n\r\nfinal String entName = &quot;func_respawnroom&quot;;\r\nFgdEntClass spawnroom = spec.getEntClass(entName); \/\/ Get normal version\r\nSystem.out.println(spawnroom.toText(entName)); \/\/ Print sparse form\r\n\r\nFgdEntClass combined = spawnroom.getInherited(spec); \/\/ Do inheritance\r\nSystem.out.println(combined.toText(entName)); \/\/ Print comnined form\r\n<\/pre>\n<p>The first print statement replicates the set-up in the original file, using the base(&#8230;) modifier to do inheritance.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n@SolidClass base(Targetname,TeamNum,EnableDisable,Toggle) = func_respawnroom :\r\n&quot;Designates a respawn room for a team.&quot; [\r\n]\r\n<\/pre>\n<p>The second prints statement shows how it looks after the inheritance rules have been applied.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n@SolidClass  = func_respawnroom :\r\n&quot;Designates a respawn room for a team.&quot; [\r\ntargetname(target_source) : &quot;Name&quot; : &quot;&quot; : &quot;The name that other entities refer to this entity by.&quot;\r\nStartDisabled(choices) : &quot;Start Disabled&quot; : 0 : &quot;&quot; =\r\n[\r\n0:&quot;No&quot;\r\n1:&quot;Yes&quot;\r\n]\r\nTeamNum(choices) : &quot;Team&quot; : 0 : &quot;Team&quot; =\r\n[\r\n0:&quot;Any&quot;\r\n2:&quot;Red&quot;\r\n3:&quot;Blue&quot;\r\n]\r\ninput KillHierarchy(void) : &quot;Removes this entity and all its children from the world.&quot;\r\ninput Enable(void) : &quot;Enable this entity.&quot;\r\ninput Disable(void) : &quot;Disable this entity.&quot;\r\ninput SetTeam(integer) : &quot;Changes the entity's team.&quot;\r\ninput Kill(void) : &quot;Removes this entity from the world.&quot;\r\ninput FireUser4(void) : &quot;Causes this entity's OnUser4 output to be fired.&quot;\r\ninput FireUser3(void) : &quot;Causes this entity's OnUser3 output to be fired.&quot;\r\ninput FireUser2(void) : &quot;Causes this entity's OnUser2 output to be fired.&quot;\r\ninput AddOutput(string) : &quot;Adds an entity I\/O connection to this entity. Format: &lt;output name&gt; &lt;targetname&gt;:&lt;inputname&gt;:&lt;parameter&gt;:&lt;delay&gt;:&lt;max times to fire (-1 == infinite)&gt;. Very dangerous, use with care.&quot;\r\ninput FireUser1(void) : &quot;Causes this entity's OnUser1 output to be fired.&quot;\r\ninput Toggle(void) : &quot;Toggle the enabled\/disabled status of this entity.&quot;\r\noutput OnUser1(void) : &quot;Fired in response to FireUser1 input.&quot;\r\noutput OnUser4(void) : &quot;Fired in response to FireUser4 input.&quot;\r\noutput OnUser2(void) : &quot;Fired in response to FireUser2 input.&quot;\r\noutput OnUser3(void) : &quot;Fired in response to FireUser3 input.&quot;\r\n]\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Just a sample from the FGD code I wrote for the Hl2Parse library. This snippet loads the TF2 FGD file and then re-outputs the FGD format to show it has parsed everything. It also prints the &#8220;default&#8221; version and then the &#8220;combined&#8221; version which collapses all the inheritance. The first print statement replicates the set-up [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[6,9,8],"_links":{"self":[{"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/270"}],"collection":[{"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":6,"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":276,"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions\/276"}],"wp:attachment":[{"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}