Added the SpawnSystem and created a test factory function in setup.lua

Merge pull request #3 from Revolutionary-Games/master

Syncing

Added spawn_system.lua to create a simple SpawnSystem and created a test factory function in SpawnSystem's constructor.

Added a newline to the end of spawn_system.lua

Made a few fixes to spawn_system.lua and moved the test function to setup.lua.

Changed the spawning algorithm. It should now be good for all stationary entities.

Randomized the orientation of spawned emitters

Fixed issue with local/global variables and unhelpful variable names, and changed the spawning method to utilize the built in functions of Vector3

Merge branch 'master' of https://github.com/Revolutionary-Games/Thrive

Fixed some bugs, changed addSpawnType to use spawnDensity rather than spawnFrequency, and added several comments.

Fixed some bugs, changed addSpawnType to use spawnDensity rather than spawnFrequency, and added several comments.
Merge pull request #71 from patowen95/40_spawn_system

Added spawn_system.lua to create a simple SpawnSystem and created a test factory function in SpawnSystem's constructor.
Add GameState concept

Closes #46

* Systems are now initialized by their GameState instead of the
  Engine directly
* Mouse and keyboard are not handled by systems anymore, but are
  special objects updated by the Engine object directly
* Saving and loading are not handled by systems anymore, but
  by the Engine object directly
* Entity filters now take the game state instead of the
  entity manager in their init function. The rationale of
  this change is that an entity is better thought of as
  belonging to a game state than to an entity manager,
  which is really just a book keeper.

Fix crash when GameState has no viewport system

Fix ownership transfer of systems when adding new GameState from Lua

Add GameState bindings to Lua

They don't contain anything (yet), but are required because
System::init takes a GameState parameter.

Expose Engine::setCurrentGameState to Lua

Add GameState testing script

Add Lua bindings to all systems

Change MicrobeControlSystem to use Keyboard instead of KeyboardSystem

Fix MicrobeSystem::init() for game states

Switch microbe setup script to game states

Remove deprecated ADD_SYSTEM

GameStates should properly shut down their systems

Remove deprecated files

Re-enable saving / loading

Only allow the Engine to create GameStates

Update documentation

Rename System::active to System::enabled

To avoid confusion with the next commit

Enable systems to react to their GameStates activation / deactivation

This removes the ugly hack of the GameState explicitly asking
the OgreViewportSystem to remove / restore the viewports.

Remove GameState::setPhysicsDebugDrawingEnabled

Clients should just enable / disable the debug draw system

Add GameState::name()

Pass around GameState pointers instead of their names

Add Keyboard::wasKeyPressed and Keyboard::wasKeyReleased

These methods are more convenient than systems keeping track of
the key state themselves. Furthermore, they solve the problem of
systems not knowing the actual key state when activated by
a key stroke.

Make TextOverlaySystem handle state switch gracefully

All overlay elements need to be removed / restored on a state
switch.

Refactor OgreViewportSystem to be closer to TextOverlaySystem

Reduces code duplication

Make Entity class use GameState in its public API

Script authors shouldn't have to care about the EntityManager.
They *should* care about the game state an entity is living in.
This change reflects this.

Unfortunately, since GameState cannot exist without a
full-fledged Engine object, this change makes Entity pretty
awkward to test, so the tests have been removed for now.

Add initializer function to GameState

Update scripts to use GameState initializer

Also adds a SwitchGameStateSystem that toggles between two
alternate microbe universes on pressing F1. Purely for testing.

Reinstated entity test

Only switch game state at the beginning of a frame

Immediately activating a game state during setCurrentGameState
can potentially cause problems as the systems are only partially
updated during the current frame.

Make EntityFilter handle additions / removals in the same frame

If an entity is added to a filter and then removed during the
exact same frame (and before clearChanges() has been called on
the filter), remove that entity from the addedEntities collection
and *don't* add it to removedEntities. For an observer of the
filter, it's as if the entity never existed, after all.

Remove debug output

Safeguard some systems against loading, then switching game state

For RigidBodySystem, OgreCameraSystem and OgreLightSystem, there
is a situation where a new game is started, a savegame is loaded
and then the gamestate is switched. The systems try to remove
internal data structures because due to the game loading, some
entities were removed. Those entities were never initialized with
internal data, however, which can lead to crashes when trying
to remove that data.

The simple solution is to skip the removal for non-initialized
internal data.

Clear entity changes after restoring all entities

TextOverlaySystem and OgreViewportSystem reinitialize all their
entities on activation. Not only is it efficient to clear their
filters' changes after that, it also prevents a crash related to
loading a savegame.

The crash occurs when a savegame is loaded that contains
matching entities with the same id as the current game. In the
systems' activate functions, the newly loaded entities' internal
state is restored. However, the entity filter still has those
ids in its "removed" set as they were also present in the old game
world and have been replaced. Thus, the internal state of the
entities is cleared during update(). Unfortunately, this doesn't
clear the component's pointer to the internal state, which makes
it difficult to detect that situation and deal with it accordingly.

The easiest solution is the one implemented. Resetting the
entity filter will prevent the unwanted clearing of internal
state.

Add missing documentation

Remove unused code

Rename Engine::addGameState to Engine::createGameState

Add Engine::getGameState()

Update documentation

Fix spawn system initialization in game state
Merge pull request #63 from Revolutionary-Games/46_gamestates

GameState
Add explicit "this->" in SystemWrapper

Just to get it in line with the styleguide.
Catch luabind::error and print a more helpful error message
Merge pull request #73 from Revolutionary-Games/72_luabind_error

Fixed: Catch luabind::error and print a more helpful error message
Add Collision system for handling custom events upon collisions.

squashed commits:
Implementation of custom collision events. Some questionable design choices within. (Untested)

Updated collision system to new structure. Now uses CollisionHandlerComponent and CollisionSystem. Manifolds used instead of global callback.

Fixed previous compile error - a new one has taken it's place (uintptr_tr not defined)

Basic working state achieved. m_collisionCallbackKey assignment from lua does not seem to take effect.

Also storage and load still needs implementing, and agentabsorber system needs refactoring.

Storage and load implemented.
AgentAbsorber system & component refactored to use this system.
Acceptance tests performed

Collision filters added, not fully functional

Collision functionality nearly updated.
Needs cleanup, testing and integration with agentabsorber.

Working CollisionFilter class.

Attempt at exposing CollisionFilter to lua. Not successful.

Fixes to improve usage of CollisionFilter. Now uses Collision struct instead of typedef to pair of entityIds.
Better model for exposure to lua (still doesn't quite work).
Cleaned up documentation and header includes.

Fixed minor compile error

Collision system finalized.
- Added a member to Collision to represent the duration of collision represented since last clearCollisions().
  This member will allow more fine grained control of collision handling (damage every 0.5 second, etc).
- Cleaned up documentation and debugging code.

Renamed CollisionHandlerComponent to CollisionComponent.
Added removeCollisionGroup to CollisionComponent.
Added constructor taking a collision group to CollisionComponent

Refactoring of CollisionSystem. Stopped using mutable keyword in collision class and instead uses unordered map.
Added a vector<collision*> mirroring the contents of the unordered_map to allow iteration in lua.

Changed to using boost::map_values for iteration.

Rebased onto master.
Fixed setup.lua
Various relevant fixes.
Code is currently not functioning due to strange bug.

Implementation of custom collision events. Some questionable design choices within. (Untested)

Updated collision system to new structure. Now uses CollisionHandlerComponent and CollisionSystem. Manifolds used instead of global callback.

Fixed previous compile error - a new one has taken it's place (uintptr_tr not defined)

Basic working state achieved. m_collisionCallbackKey assignment from lua does not seem to take effect.

Also storage and load still needs implementing, and agentabsorber system needs refactoring.

Fix typo in Lua script

The previous version crashed because the game state passed to
CollisionFilter's constructor was nil in Lua and consequently
nullptr in C++.

Simplify GameState::findSystem

No need for complicated iteration. Also, dynamic_cast can only
throw an exception if a reference type is cast, not for pointer
types.

Refactor signature handling of CollisionFilter

Returning a pair of references is a little tricky because it's
not obvious how the std::pair template will handle it. Returning
a reference to a pair, however, is more predictable.

Use static initializers when possible

Minor refactoring

* Use typedefs (i.e. CollisionFilter::Signature) instead of repeating
the type
* Use emplace when possible, it's more readable than constructing
  the collection item manually
* Rename permutation -> combination

Do not register collision filter in Implementation constructor

At that point, the m_impl field of the CollisionFilter is not
initialized yet (because the Implementation object is not
fully constructed). The CollisionSystem asks the filter for
its signature, which is saved in the m_impl object. Since this
doesn't point to anything useful yet, it crashes.

Added CollisionFilter.init and CollisionFilter.shutdown to allow users to create their CollisionFilters in constructors.
Removed debugging code.

Minor refactorings for CollisionFilter and CollisionSystem

Removed typedefs in collision_filter.cpp.

Removed minor error in rebasing
Merge pull request #64 from Revolutionary-Games/62-Collision-functionality

Implementation of custom collision events.
Add ProcessOrganelle for converting compounds
Closes #41

squashed commits:
Add ProcessOrganelle for converting compounds

Closes #41

Add ProcessOrganelle

Fixed syntax in process_organelle.lua and added hasInputAgent method to ProcessOrganelle class

Added ProcessOrganelle support into Microbe class, and added process_organelle.lua to manifest

Added code to setup.lua to test ProcessOrganelle (currently not working)
Minor fixes to ProcessOrganelle related code in process_organelle.lua and microbe.lua

Minor formatting and reintroduced function missing in process_organelle.lua

Fix some minor errors in the ProcessOrganelle script

* Use table.insert instead of a[#a+1] to not repeat the table name
* Call superclass' constructor in ProcessOrganelle.__init
* Explicitly pass self to Organelle.update in ProcessOrganelle.update
* Lua has no -= (or += for that matter)
* Typos

Fixed error in loading a savegame with ProcessOrganelle.

Removed debugging code in microbe.lua

Created cooldown system for Process organelles, limiting the frequency of agent absorbtion and production

Fixed missing local specifier on two variables in process_organelle.lua

Implemeneted colours for process organelles to reflect how filled it is. Also minor bugfixes

Move "local" to where it belongs

Made distribution of agents, dependant on time elapsed instead of frames. (1 agent per agent type distributed per 100ms)

Release candidate 1 Done.

- Fixed compile error
- Removed debugging code
- Changed setup of compounds/agents to reflect mitochondrion

Added additional documentation for processing compounds.
Minor refactoring to compound distribution for more accuracy.

Replaced magic value with proper constant

Re-changed emitters to use new oxygen, glucose, atp, co2 system.
Cleanup of old variable and comment names in setup.lua
Merge pull request #57 from Revolutionary-Games/41-processing-organelles

Process Organelles
Add missing <iostream> include

A fresh Ubuntu 12.04 installation complains about not knowing
std::cerr in scripting/luabind.h when compiling with the mingw
environment. A simple additional include fixes it.