You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<htmllang="en"><head><metacharset="utf-8"/><linkhref="../bootstrap-combined.min.css" rel="stylesheet" /><scripttype="text/javascript" src="../jquery-1.9.1.min.js"></script><scripttype="text/javascript" src="../bootstrap.min.js"></script><linkhref="../styles.css" rel="stylesheet" /><linkrel="icon" href="../favicon.ico" type="image/x-icon"></link><scripttype="text/javascript" src="../nav.js"></script><scripttype="text/javascript" src="../index.js"></script><scripttype="text/javascript">vardox={rootPath: "../",platforms: ["dox"]};</script><title>ComponentSet - Flaxen API 28-Apr-15</title></head><body><divclass="navbar navbar-inverse navbar-fixed-top"><divclass="navbar-inner"><formclass="navbar-search pull-left" id="searchForm"><inputid="search" type="text" class="search-query" placeholder="Filter" autocomplete="off"/></form><ulclass="nav"><liid="select-platform" class="dropdown"><ahref="#" class="dropdown-toggle" data-toggle="dropdown">Platform<bclass="caret"></b></a><ulclass="dropdown-menu"><lidata="all"><ahref="#">All Platforms</a></li><lidata="dox"><ahref="#">dox</a></li></ul></li></ul></div></div><divid="container"><divid="nav"></div><divid="content"><divclass="header"><spanclass="viewsource"><ahref="https://github.com/scriptorum/flaxen/blob/master/source/flaxen/ComponentSet.hx">View source</a></span><h1><code><spanclass="directive">class </span><spanclass="type">flaxen.ComponentSet</span></code></h1></div><divclass="body"><pclass="availability">Available on all platforms</p><divclass="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><divclass="platform platform-dox"><aname="new"></a><h3><p><code><spanclass="keyword">function</span><ahref="#new"><spanclass="identifier">new</span></a>():<spanclass="type">Void</span></code></p></h3><divclass="doc"><p></p></div></div><divclass="platform platform-dox"><aname="add"></a><h3><p><code><spanclass="keyword">function</span><ahref="#add"><spanclass="identifier">add</span></a><<spanclass="type">T</span>>(component:<spanclass="type">T</span>):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="addClass"></a><h3><p><code><spanclass="keyword">function</span><ahref="#addClass"><spanclass="identifier">addClass</span></a>(clazz:<spanclass="type">Class</span><<spanclass="type">Dynamic</span>>, ?args:<spanclass="type">Array</span><<spanclass="type">Dynamic</span>> = null):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="addEntity"></a><h3><p><code><spanclass="keyword">function</span><ahref="#addEntity"><spanclass="identifier">addEntity</span></a>(entity:<spanclass="type">Entity</span>):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="addFunction"></a><h3><p><code><spanclass="keyword">function</span><ahref="#addFunction"><spanclass="identifier">addFunction</span></a>(func:<spanclass="type">Entity</span> -><spanclass="type">Dynamic</span>):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="addSet"></a><h3><p><code><spanclass="keyword">function</span><ahref="#addSet"><spanclass="identifier">addSet</span></a>(set:<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a>):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="install"></a><h3><p><code><spanclass="keyword">function</span><ahref="#install"><spanclass="identifier">install</span></a>(entity:<spanclass="type">Entity</span>):<spanclass="type">Void</span></code></p></h3><divclass="doc"><p>Installs the components into the entity</p></div></div><divclass="platform platform-dox"><aname="remove"></a><h3><p><code><spanclass="keyword">function</span><ahref="#remove"><spanclass="identifier">remove</span></a>(clazz:<spanclass="type">Class</span><<spanclass="type">Dynamic</span>>):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="removeAll"></a><h3><p><code><spanclass="keyword">function</span><ahref="#removeAll"><spanclass="identifier">removeAll</span></a>(?except:<spanclass="type">Array</span><<spanclass="type">Class</span><<spanclass="type">Dynamic</span>>> = null):<aclass="type" href="../flaxen/ComponentSet.html">ComponentSet</a></code></p></h3><divclass="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><divclass="platform platform-dox"><aname="toString"></a><h3><p><code><spanclass="keyword">function</span><ahref="#toString"><spanclass="identifier">toString</span></a>():<spanclass="type">String</span></code></p></h3><divclass="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>
<htmllang="en"><head><metacharset="utf-8"/><linkhref="../bootstrap-combined.min.css" rel="stylesheet" /><scripttype="text/javascript" src="../jquery-1.9.1.min.js"></script><scripttype="text/javascript" src="../bootstrap.min.js"></script><linkhref="../styles.css" rel="stylesheet" /><linkrel="icon" href="../favicon.ico" type="image/x-icon"></link><scripttype="text/javascript" src="../nav.js"></script><scripttype="text/javascript" src="../index.js"></script><scripttype="text/javascript">vardox={rootPath: "../",platforms: ["dox"]};</script><title>EntityRef - Flaxen API 28-Apr-15</title></head><body><divclass="navbar navbar-inverse navbar-fixed-top"><divclass="navbar-inner"><formclass="navbar-search pull-left" id="searchForm"><inputid="search" type="text" class="search-query" placeholder="Filter" autocomplete="off"/></form><ulclass="nav"><liid="select-platform" class="dropdown"><ahref="#" class="dropdown-toggle" data-toggle="dropdown">Platform<bclass="caret"></b></a><ulclass="dropdown-menu"><lidata="all"><ahref="#">All Platforms</a></li><lidata="dox"><ahref="#">dox</a></li></ul></li></ul></div></div><divid="container"><divid="nav"></div><divid="content"><divclass="header"><spanclass="viewsource"><ahref="https://github.com/scriptorum/flaxen/blob/master/source/flaxen/Flaxen.hx">View source</a></span><h1><code><spanclass="directive">abstract </span><spanclass="type">flaxen.EntityRef</span>(<spanclass="type">Either</span><<spanclass="type">Entity</span>, <spanclass="type">String</span>>)</code></h1></div><divclass="body"><p><codeclass="dark"><spanclass="directive">import</span><spanclass="type">flaxen.Flaxen</span>;</code></p><pclass="availability">Available on all platforms</p><divclass="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><divclass="platform platform-dox"><aname="fromEntity"></a><h3><p><code><spanclass="keyword">function</span><ahref="#fromEntity"><spanclass="identifier">fromEntity</span></a>(e:<spanclass="type">Entity</span>):<aclass="type" href="../flaxen/EntityRef.html">EntityRef</a></code></p></h3><divclass="doc"><p></p></div></div><divclass="platform platform-dox"><aname="fromString"></a><h3><p><code><spanclass="keyword">function</span><ahref="#fromString"><spanclass="identifier">fromString</span></a>(str:<spanclass="type">String</span>):<aclass="type" href="../flaxen/EntityRef.html">EntityRef</a></code></p></h3><divclass="doc"><p></p></div></div><h2>Instance Fields</h2><divclass="platform platform-dox"><aname="type"></a><h3><p><code><spanclass="keyword">var</span><ahref="#type"><spanclass="identifier">type</span></a>:<spanclass="type">Either</span><<spanclass="type">Entity</span>, <spanclass="type">String</span>></code></p></h3><divclass="doc"><p></p></div></div><divclass="platform platform-dox"><aname="get_type"></a><h3><p><code><spanclass="keyword">function</span><ahref="#get_type"><spanclass="identifier">get_type</span></a>():<spanclass="type">Either</span><<spanclass="type">Entity</span>, <spanclass="type">String</span>></code></p></h3><divclass="doc"><p></p></div></div><divclass="platform platform-dox"><aname="toEntity"></a><h3><p><code><spanclass="keyword">function</span><ahref="#toEntity"><spanclass="identifier">toEntity</span></a>(f:<aclass="type" href="../flaxen/Flaxen.html">Flaxen</a>, ?compulsory:<spanclass="type">Bool</span> = true):<spanclass="type">Entity</span></code></p></h3><divclass="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><tableclass="table table-condensed"><tbody><colwidth="10%"/><colwidth="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><divclass="platform platform-dox"><aname="toString"></a><h3><p><code><spanclass="keyword">function</span><ahref="#toString"><spanclass="identifier">toString</span></a>():<spanclass="type">String</span></code></p></h3><divclass="doc"><tableclass="table table-condensed"><tbody><colwidth="10%"/><colwidth="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