Permalink
Browse files

+ Some changes see list

  • Loading branch information...
1 parent 839fafc commit 0cd1868091e40e3103115705f8104dbb00655d68 @mikecann committed Jun 28, 2010
View
Binary file not shown.
@@ -10,12 +10,12 @@ package co.uk.swft.base
public class Entity implements IEntity
{
- [Inject]
- public var entityMap:IEntityMap;
+ // Dependencies
+ [Inject] public var entityMap:IEntityMap;
+ // Protecteds
protected var _injector:IInjector;
protected var _components:Array;
- protected var _signals : Array;
public function Entity()
{
@@ -50,28 +50,13 @@ package co.uk.swft.base
component.onRemove();
}
}
-
- public function registerSignal(signal:Signal) : Signal
- {
- if (!_signals){_signals=[];}
- _signals.push(signal);
- return signal;
- }
-
+
public function removeComponents():void
{
var component:IEntityComponent;
while (component = _components.pop())
component.onRemove();
- }
-
- public function removeSignals() : void
- {
- for each (var signal : Signal in _signals)
- {
- signal.removeAll();
- }
- }
+ }
public function mapComponents():void
{
@@ -83,11 +68,10 @@ package co.uk.swft.base
// HOOK: override
}
- public function onRemove():void
+ public function onDestroy():void
{
// HOOK: override
- removeComponents();
- removeSignals();
- }
+ }
+
}
}
@@ -9,29 +9,12 @@ package co.uk.swft.base
{
// Protecteds
protected var _entity : IEntity;
- protected var _signals : Array;
[PostConstruct]
public function init():void
{
entity.registerComponent(this);
}
-
- public function registerSignal(signal:Signal) : Signal
- {
- if (!_signals){ _signals=[]; }
- _signals.push(signal);
- return signal;
- }
-
- public function removeSignals() : void
- {
- for each (var signal : Signal in _signals)
- {
- signal.removeAll();
- signal = null;
- }
- }
public function onRegister():void
{
@@ -41,7 +24,6 @@ package co.uk.swft.base
public function onRemove():void
{
// HOOK: override
- removeSignals();
}
[Inject]
@@ -43,15 +43,18 @@ package co.uk.swft.base
if (index > -1)
{
_entities.splice(index, 1);
- entity.onRemove();
+ entity.onDestroy(); // First allow the entity to destroy any references it has
+ entity.removeComponents(); // Then destroy all the components in this entity
}
}
public function removeEntities():void
{
var entity:IEntity;
while (entity = _entities.pop())
- entity.onRemove();
+ {
+ removeEntity(entity);
+ }
}
}
}
@@ -5,6 +5,7 @@ package co.uk.swft.base
import flash.display.DisplayObjectContainer;
+ import org.osflash.signals.Signal;
import org.robotlegs.base.SignalCommandMap;
import org.robotlegs.core.IMediatorMap;
import org.robotlegs.core.ISignalCommandMap;
@@ -13,6 +14,8 @@ package co.uk.swft.base
public class GameContext extends Context
{
+ private var _sig : Signal; // HOW DO YOU INCLUDE CLASSES IN YOUR LIB WITHOUT REFERENCING THEM?!?
+
protected var _entityMap:IEntityMap;
protected var _gameManagerMap:IGameManagerMap;
protected var _signalCommandMap:ISignalCommandMap;
@@ -1,11 +1,14 @@
package co.uk.swft.base
{
+ import co.uk.swft.core.IEntityMap;
import co.uk.swft.core.IGameManager;
import org.robotlegs.mvcs.Actor;
public class GameManager extends Actor implements IGameManager
{
+ [Inject] public var entityMap : IEntityMap;
+
public function GameManager()
{
}
@@ -47,5 +47,14 @@ package co.uk.swft.base
man.onGameStartup();
}
}
+
+ public function startNextLevel() : void
+ {
+ // Loop through each manager and start the next level
+ for each (var man : IGameManager in _managers)
+ {
+ man.onNextLevel();
+ }
+ }
}
}
@@ -13,6 +13,6 @@ package co.uk.swft.core
function removeComponents():void;
function onRegister():void;
- function onRemove():void;
+ function onDestroy():void;
}
}
@@ -5,5 +5,6 @@ package co.uk.swft.core
function mapManager(managerClazz:Class) : void;
function mapManagerOf(whenAskedFor:Class,provide:Class) : void;
function startGame() : void;
+ function startNextLevel() : void;
}
}

0 comments on commit 0cd1868

Please sign in to comment.