Skip to content

Commit 74c1ae6

Browse files
committed
Updated Flaxen API
1 parent 5364912 commit 74c1ae6

17 files changed

+205
-2
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ haxelib.zip
77
*.eot
88
*.woff
99
assets/font/*.svg
10-
dox
11-
pages
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html lang="en"><head><meta charset="utf-8"/><link href="../bootstrap-combined.min.css" rel="stylesheet" /><script type="text/javascript" src="../jquery-1.9.1.min.js"></script><script type="text/javascript" src="../bootstrap.min.js"></script><link href="../styles.css" rel="stylesheet" /><link rel="icon" href="../favicon.ico" type="image/x-icon"></link><script type="text/javascript" src="../nav.js"></script><script type="text/javascript" src="../index.js"></script><script type="text/javascript">var dox = {rootPath: "../",platforms: ["dox"]};</script><title>ComponentSet - Flaxen API 28-Apr-15</title></head><body><div class="navbar navbar-inverse navbar-fixed-top"><div class="navbar-inner"><form class="navbar-search pull-left" id="searchForm"><input id="search" type="text" class="search-query" placeholder="Filter" autocomplete="off"/></form><ul class="nav"><li id="select-platform" class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Platform<b class="caret"></b></a><ul class="dropdown-menu"><li data="all"><a href="#">All Platforms</a></li><li data="dox"><a href="#">dox</a></li></ul></li></ul></div></div><div id="container"><div id="nav"></div><div id="content"><div class="header"><span class="viewsource"><a href="https://github.com/scriptorum/flaxen/blob/master/source/flaxen/ComponentSet.hx">View source</a></span><h1><code><span class="directive">class </span><span class="type">flaxen.ComponentSet</span></code></h1></div><div class="body"><p class="availability">Available on all platforms</p><div class="doc"><p>A ComponentSet is a list of steps that can be added (installed) into an entity
3+
(or ideally more). Most steps are for adding instances of components. This is its
4+
primary function, to quickly add components to an entity. Steps can also be used
5+
to remove components from entities, or execute arbitrary functions that may or may
6+
not return the instance to be added.</p>
7+
<p>This set adds some base components to two different entities, and ensures neither
8+
entity contains an Animation:</p>
9+
<pre><code> flaxen.newComponentSet("base")
10+
.add(Origin.center)
11+
.add(new Offset(10, 10))
12+
.addClass(Position, [0, 0])
13+
.remove(Animation);
14+
flaxen.addSet(entity1, "base");
15+
flaxen.addSet(entity2, "base");</code></pre></div><h2>Instance Fields</h2><div class="platform platform-dox"><a name="new"></a><h3><p><code><span class="keyword">function</span> <a href="#new"><span class="identifier">new</span></a>():<span class="type">Void</span></code></p></h3><div class="doc"><p></p></div></div><div class="platform platform-dox"><a name="add"></a><h3><p><code><span class="keyword">function</span> <a href="#add"><span class="identifier">add</span></a>&lt;<span class="type">T</span>&gt;(component:<span class="type">T</span>):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>Adds a component instance to the component set. Note that all entities using this set
16+
will be sharing the same single instance of this component. See addClass.
17+
TODO Verify this is not a Class or Function being passed in.</p></div></div><div class="platform platform-dox"><a name="addClass"></a><h3><p><code><span class="keyword">function</span> <a href="#addClass"><span class="identifier">addClass</span></a>(clazz:<span class="type">Class</span>&lt;<span class="type">Dynamic</span>&gt;, ?args:<span class="type">Array</span>&lt;<span class="type">Dynamic</span>&gt; = null):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>Adds a class and parameters to the set. The class will be instantiated with the
18+
supplied paramters every time the set is installed in an entity. This prevents
19+
sharing of instances that happens when you call set.add(new MyComponent(A, B, C)).
20+
For example: set.addClass(MyComponent, [A, B, C]);</p></div></div><div class="platform platform-dox"><a name="addEntity"></a><h3><p><code><span class="keyword">function</span> <a href="#addEntity"><span class="identifier">addEntity</span></a>(entity:<span class="type">Entity</span>):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>Adds all the components from one entity into the set. Note that these components
21+
are added immediately, so if you add or remove from the supplied entity at a
22+
later point, these changes will not be reflected in the component set.</p></div></div><div class="platform platform-dox"><a name="addFunction"></a><h3><p><code><span class="keyword">function</span> <a href="#addFunction"><span class="identifier">addFunction</span></a>(func:<span class="type">Entity</span> -&gt;<span class="type">Dynamic</span>):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>Adds a function. This function must accept installing entity as a parameter.
23+
The function will be executed when the set is installed into an entity. If the
24+
function returns a component instance, it will be added to the entity. If it
25+
returns null, it will be ignored.
26+
TODO Allow functions with no parameters as well</p></div></div><div class="platform platform-dox"><a name="addSet"></a><h3><p><code><span class="keyword">function</span> <a href="#addSet"><span class="identifier">addSet</span></a>(set:<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a>):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>Adds a ComponentSet to this set. When the set is installed in an entity,
27+
the supplied set will also be installed to the entity. Use this to implement
28+
a component set hiearchy of parent/child sets. For instance, a gun is a weapon.
29+
You could create a WeaponSet and a GunSet and install them both to your new gun
30+
entity, or instead add the WeaponSet to the GunSet using this method. Then when
31+
install GunSet, the entity will also get WeaponSet installed.</p></div></div><div class="platform platform-dox"><a name="install"></a><h3><p><code><span class="keyword">function</span> <a href="#install"><span class="identifier">install</span></a>(entity:<span class="type">Entity</span>):<span class="type">Void</span></code></p></h3><div class="doc"><p>Installs the components into the entity</p></div></div><div class="platform platform-dox"><a name="remove"></a><h3><p><code><span class="keyword">function</span> <a href="#remove"><span class="identifier">remove</span></a>(clazz:<span class="type">Class</span>&lt;<span class="type">Dynamic</span>&gt;):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>\*
32+
Does not add an instance. Instead, when installed, removes the supplied
33+
component from the entity, if it has one.</p></div></div><div class="platform platform-dox"><a name="removeAll"></a><h3><p><code><span class="keyword">function</span> <a href="#removeAll"><span class="identifier">removeAll</span></a>(?except:<span class="type">Array</span>&lt;<span class="type">Class</span>&lt;<span class="type">Dynamic</span>&gt;&gt; = null):<a class="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><div class="doc"><p>Does not add an instance. Instead, when installed, removes all components
34+
from an entity. Completely blanks out an entity. Do this before any add calls.
35+
If an array of component classes is supplied, these components will be
36+
spared removal</p></div></div><div class="platform platform-dox"><a name="toString"></a><h3><p><code><span class="keyword">function</span> <a href="#toString"><span class="identifier">toString</span></a>():<span class="type">String</span></code></p></h3><div class="doc"><p>TODO This reports "[func]" if it encounters a remove or removeAll. This
37+
could be fixed by adding all steps as independent class objects.</p></div></div></div></div></div></body></html>

flaxen/dox/flaxen/EntityRef.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<html lang="en"><head><meta charset="utf-8"/><link href="../bootstrap-combined.min.css" rel="stylesheet" /><script type="text/javascript" src="../jquery-1.9.1.min.js"></script><script type="text/javascript" src="../bootstrap.min.js"></script><link href="../styles.css" rel="stylesheet" /><link rel="icon" href="../favicon.ico" type="image/x-icon"></link><script type="text/javascript" src="../nav.js"></script><script type="text/javascript" src="../index.js"></script><script type="text/javascript">var dox = {rootPath: "../",platforms: ["dox"]};</script><title>EntityRef - Flaxen API 28-Apr-15</title></head><body><div class="navbar navbar-inverse navbar-fixed-top"><div class="navbar-inner"><form class="navbar-search pull-left" id="searchForm"><input id="search" type="text" class="search-query" placeholder="Filter" autocomplete="off"/></form><ul class="nav"><li id="select-platform" class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Platform<b class="caret"></b></a><ul class="dropdown-menu"><li data="all"><a href="#">All Platforms</a></li><li data="dox"><a href="#">dox</a></li></ul></li></ul></div></div><div id="container"><div id="nav"></div><div id="content"><div class="header"><span class="viewsource"><a href="https://github.com/scriptorum/flaxen/blob/master/source/flaxen/Flaxen.hx">View source</a></span><h1><code><span class="directive">abstract </span><span class="type">flaxen.EntityRef</span>(<span class="type">Either</span>&lt;<span class="type">Entity</span>, <span class="type">String</span>&gt;)</code></h1></div><div class="body"><p><code class="dark"><span class="directive">import</span> <span class="type">flaxen.Flaxen</span>;</code></p><p class="availability">Available on all platforms</p><div class="doc"><p>In many methods where an Entity is expected you can instead pass a String
3+
that is the name of an Entity in Ash. EntityRef is an abstract type that
4+
could be referring to either an Entity or a String. A class may use
5+
ref.toEntity() to validate the reference and return a full Entity instance.</p></div><h2>Class Fields</h2><div class="platform platform-dox"><a name="fromEntity"></a><h3><p><code><span class="keyword">function</span> <a href="#fromEntity"><span class="identifier">fromEntity</span></a>(e:<span class="type">Entity</span>):<a class="type" href="../flaxen/EntityRef.html">EntityRef</a></code></p></h3><div class="doc"><p></p></div></div><div class="platform platform-dox"><a name="fromString"></a><h3><p><code><span class="keyword">function</span> <a href="#fromString"><span class="identifier">fromString</span></a>(str:<span class="type">String</span>):<a class="type" href="../flaxen/EntityRef.html">EntityRef</a></code></p></h3><div class="doc"><p></p></div></div><h2>Instance Fields</h2><div class="platform platform-dox"><a name="type"></a><h3><p><code><span class="keyword">var</span> <a href="#type"><span class="identifier">type</span></a>:<span class="type">Either</span>&lt;<span class="type">Entity</span>, <span class="type">String</span>&gt;</code></p></h3><div class="doc"><p></p></div></div><div class="platform platform-dox"><a name="get_type"></a><h3><p><code><span class="keyword">function</span> <a href="#get_type"><span class="identifier">get_type</span></a>():<span class="type">Either</span>&lt;<span class="type">Entity</span>, <span class="type">String</span>&gt;</code></p></h3><div class="doc"><p></p></div></div><div class="platform platform-dox"><a name="toEntity"></a><h3><p><code><span class="keyword">function</span> <a href="#toEntity"><span class="identifier">toEntity</span></a>(f:<a class="type" href="../flaxen/Flaxen.html">Flaxen</a>, ?compulsory:<span class="type">Bool</span> = true):<span class="type">Entity</span></code></p></h3><div class="doc"><p>Converts the EntityRef into an Entity. If the EntityRef already
6+
references an Entity, does not do a lookup to verify the entity
7+
exists in the Ash engine.</p><table class="table table-condensed"><tbody><col width="10%"/> <col width="100%"/><tr><td>f</td><td><p>The Flaxen object</p></td></tr><tr><td>compulsory</td><td><p>If true, throws exception instead of returning null</p></td></tr><tr><td>returns</td><td><p>The Entity object, or null if string lookup fails or ref was null</p></td></tr></tbody></table></div></div><div class="platform platform-dox"><a name="toString"></a><h3><p><code><span class="keyword">function</span> <a href="#toString"><span class="identifier">toString</span></a>():<span class="type">String</span></code></p></h3><div class="doc"><table class="table table-condensed"><tbody><col width="10%"/> <col width="100%"/><tr><td>returns</td><td><p>The entity's name</p></td></tr></tbody></table></div></div></div></div></div></body></html>

0 commit comments

Comments
 (0)