Skip to content

Commit

Permalink
+ Some changes see list
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecann committed Jun 28, 2010
1 parent 839fafc commit 0cd1868
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 45 deletions.
Binary file modified bin/Swft.swc
Binary file not shown.
32 changes: 8 additions & 24 deletions src/co/uk/swft/base/Entity.as
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
{
Expand All @@ -83,11 +68,10 @@ package co.uk.swft.base
// HOOK: override
}

public function onRemove():void
public function onDestroy():void
{
// HOOK: override
removeComponents();
removeSignals();
}
}

}
}
18 changes: 0 additions & 18 deletions src/co/uk/swft/base/EntityComponent.as
Expand Up @@ -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
{
Expand All @@ -41,7 +24,6 @@ package co.uk.swft.base
public function onRemove():void
{
// HOOK: override
removeSignals();
}

[Inject]
Expand Down
7 changes: 5 additions & 2 deletions src/co/uk/swft/base/EntityMap.as
Expand Up @@ -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);
}
}
}
}
3 changes: 3 additions & 0 deletions src/co/uk/swft/base/GameContext.as
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/co/uk/swft/base/GameManager.as
@@ -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()
{
}
Expand Down
9 changes: 9 additions & 0 deletions src/co/uk/swft/base/GameManagerMap.as
Expand Up @@ -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();
}
}
}
}
2 changes: 1 addition & 1 deletion src/co/uk/swft/core/IEntity.as
Expand Up @@ -13,6 +13,6 @@ package co.uk.swft.core
function removeComponents():void;

function onRegister():void;
function onRemove():void;
function onDestroy():void;
}
}
1 change: 1 addition & 0 deletions src/co/uk/swft/core/IGameManagerMap.as
Expand Up @@ -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.