Sunday, October 7, 2012

Priority Change

I added the asteroids near each player waypoint.  Unfortunately, the faction control script broke again.  I originally envisioned a dynamic system to utilized a redimensionable array to track factions in a mission.  Unfortunately, it was less than efficient, both in speed and reliability.  Before progressing any further, I need to fix the faction system.

Consequently, I am scrapping the old design and will create a new faction tracking system for the game.  First, I need to break the control script into two scripts: faction manager and faction controller.  The faction manager will load the faction data for the mission and pass that information to the faction controller.  The faction controller will do the actual work of identifying friends and foes for the individual fighters. 

This means that the faction manager will need to be added to the manager game object.  It's only functions are to load the faction data, store that data, pass that data to other scripts through various methods and functions. 

The faction control script will be attached to each game object.  It will load individual ship (or other game object) faction data from the faction manager, process the data and pass that information to other scripts.

Instead of the previous array system, I will use a nested list concept.  At the database level, each faction entry will have the following fields: missions, faction, friend list and enemy list.  I might add a neutral list; however, I haven't needed it so far.  It's inclusion might come later in the development cycle.  When loading the factions for a mission, the mission field is used as the primary query key.  This should leave one colonial, one cylon and one of each of the other factions in the mission.  The actual faction manager will use a data structure that has a faction, a friend list and enemy list.  When a faction control list requests faction data, it will request it by faction.  Two different methods will return a friend list or an enemy list. 

On the other side, the faction control script will get the two identification lists and store them.  Some designated functions will use pass a faction for comparison.  For example, the IsFriend() function takes the faction in question as an input.  It checks the friendly list and returns a true value if that faction is in the list.  The control scripts acts as an intermediary between the ship's other scripts and the faction manager. 

Hopefully, this will streamline the faction processes in the game and help the game run smoother.  Unfortunately, I'll have to gut the old scripts.  I'll archive a copy of the current prototype just in case this new approach makes things worse.

1 comment:

  1. Fixed.

    I did not implement a faction manager. I just incorporated it into the resource manager. The load routines for each faction control script just requested the data from the resource manager and put it into its own data structure.

    It seems to be working without any issues, and the performance seems to be stable at this point.