I'm busy surgically removing the "Engine" from my latest projects and building it into its own reusable library which I can then host in its own SVN project etc etc and avoid having to maintain multiple copys across each project, this will also allow for me to post it in an open-source repo and anyone who is interested in trying out the component based entitys stuff I've been developing in it can.
One of the problems I'm not sure how to handle is the message subject enumerations, I use a message system for communication and a message is as such:
struct Message { MessageSubject::ENUM Subject; int SenderID; int ReceiverID; float SendTime; void* Data; };
And message's are defined in an enum, there is also a matching array of strings so that we can convert string - enum, or enum - string at any time, these files are generated using a tool to keep them synced.
Here's the file as in its most recent form:
/***********************************************************//* This File was Auto-generated by the Message Maker App *//* Authors: Christopher Pepper & Scott Bevin *//***********************************************************///AUTO GENERATED VERSION:176#include <string>#pragma once#define NO_MESSAGE 999namespace XF{namespace MessageSubject{ enum ENUM { //Group:Graphics API PLEASE_SEND_RENDERER=0, // Params -: :- SENT_RENDERER, // Params -: :- //End Of Group: Graphics API //Group:Sound API ADD_MUSIC, // Params -: std::String tag, (this loads the music into memory ready to be played, paused etc it will automaticaly loop :- PLAY_MUSIC, // Params -: std::string tag of music (must be Added first :- STOP_MUSIC, // Params -: std::String tag, will remove the music from memory :- STOP_SOUND, // Params -: std::string tag (this is used for internal messageS) :- PAUSE_MUSIC, // Params -: std::string tag, will pause the music :- PLAY_SOUND_EX, // Params -: PropertyContainer (why didnt i think of this already =]) :- //this is currently for the PlaySound component to use //it can be sent a variety of properties via the PropertyContainer //currently that includes the track, the position and the length of the track, the minimum distance it can be heard from //if it doesnt have a lengthh property it will play the sound looped until the sound is destroyed by a STOP_SOUND message STOP_SOUND_EX, // Params -: :- // used for stoping sounds using a specially UID, this is all managed in playsound component and sent to the sound component UPDATE_MUSIC_TRACK_POSITION, // Params -: sound data packet :- PLAY_SOUND, // Params -: std::String :- PLAY_3D_SOUND, // Params -: SoundDataPacket struct :- SET_LISTENER_DATA, // Params -: ListenerInformation struct :- ADD_SOUND, // Params -: Use only if you want to add a sound that is not pre-loaded, SEND a std::string filepath :- //End Of Group: Sound API //Group:Particle API CREATE_PARTICLE_SYSTEM, // Params -: :- //End Of Group: Particle API //Group:Collision system SEND_ME_ENITIES_IN_RADIUS, // Params -: float :- SEND_ME_ENITIES_IN_RAY, // Params -: XF::GameEntity :- SENT_YOU_ENTITIES_IN_RAY, // Params -: std::vector<XF::GameEntity> :- SENT_YOU_ENTITIES_IN_RADUIS, // Params -: std::vector<XF::GameEntity> :- SEND_ME_DETECTION_RADIUS, // Params -: :- SENT_YOU_DETECTION_RADIUS, // Params -: float :- //End Of Group: Collision system //Group:GUI SENT_GUI, // Params -: :- PLEASE_SEND_GUI, // Params -: :- PLEASE_SEND_ME_ACTION_CAMERA, // Params -: :- SENT_YOU_ACTION_CAMERA, // Params -: Ogre::Camera* :- STOP_USING_ACTION_CAMERA, // Params -: :- ESCAPE_SCREEN, // Params -: :- //End Of Group: GUI //Group:Error Processing ERROR_MESSAGE, // Params -: std::String :- //End Of Group: Error Processing //Group:Cosole SEND_ME_DISPLAY, // Params -: :- SENT_CONSOLE_DISPLAY, // Params -: :- SHOW_PAUSE_MENU, // Params -: :- TRACK_GAME_ENTITY, // Params -: :- STOP_TRACKING_GAME_ENTITY, // Params -: :- //End Of Group: Cosole //Group:Game world -> HUD TOWER_CLICKED, // Params -: GameEntity* :- MULITPLE_TOWER_CLICKED, // Params -: std::list<GameEntity*> :- NOTHING_CLICKED, // Params -: NULL :- SET_LEFT_PANE_CAMERA, // Params -: :- //End Of Group: Game world -> HUD //Group:HUD OUT TELL_ME_COST_OF, // Params -: string (containing filepath of towerFile) :- HOW_MUCH_DO_YOU_COST_TO_UPGRADE, // Params -: :- WHAT_IS_YOUR_UPGRADE_FILE, // Params -: :- WHAT_IS_YOUR_SELL_VALUE, // Params -: :- ARE_YOU_UPGRADABLE, // Params -: :- YES_I_AM_UPGRADABLE, // Params -: :- MY_UPGRADE_FILE_IS, // Params -: std::string :- SHOW_UPGRADE, // Params -: :- SEND_ME_UPGRADE_DESCRIPTION, // Params -: :- STOP_SHOWING_UPGRADE, // Params -: :- BUILD_TOWER, // Params -: SEND string containing filepath of towerFile :- UPGRADE_TOWER, // Params -: NULL :- SELL, // Params -: NULL :- UPDATE_SELECTED, // Params -: NULL :- POINT_CAMERA_AT, // Params -: xf::vector3 :- //End Of Group: HUD OUT //Group:Entity managment COST_IS, // Params -: string (containing filepath of towerFile) :- MY_UPGRADE_COST_IS, // Params -: :- MY_SELL_VALUE_IS, // Params -: :- ATTATCH_CAMERA_TO_ENTITY, // Params -: :- ATTATCH_CAMERA_TO_RANDOM_ENTITY, // Params -: :- REMOVE_ENEMY, // Params -: GameEntity* :- SPAWN_NEXT_WAVE, // Params -: :- BUILD_SPACE_STATION, // Params -: :- //End Of Group: Entity managment //Group:Game Stuff SPACE_STATION_SELECTED, // Params -: :- ADD_PROJECTILE_TO_WORLD, // Params -: :- ADJUST_MONEY, // Params -: // int (will add to money) :- ADJUST_LIFE, // Params -: int (will add to life) :- HOW_MUCH_MONEY_IS_LEFT, // Params -: :- SENT_HOW_MUCH_MONEY_LEFT, // Params -: :- MONEY_HAS_CHANGED_TO, // Params -: :- LIFE_HAS_CHANGED_TO, // Params -: :- GAME_OVER, // Params -: bool, if true the game was won, if false the game was lost :- NO_MORE_ENEMIES_AND_ALL_WAVES_SPAWNED, // Params -: :- //End Of Group: Game Stuff //Group:Entity To Entity REDUCE_LIFE, // Params -: float :- YOU_HAVE_BEEN_SHOT, // Params -: :- YOU_KILLED_ME, // Params -: GameEnity* (the enity sending the message) :- //This message is sent when one entity kills another //End Of Group: Entity To Entity //Group:Tower Stuff UPGRADE_YOURSELF, // Params -: NULL :- BEEN_SOLD, // Params -: NULL in case we want a component to make a sparkly effect or something :- TARGET_PRIORITY_CHANGED, // Params -: enum TargetPriotiry :- YOU_ARE_BEING_PLACED, // Params -: :- UN_CLICKED, // Params -: :- LOOK_AT, // Params -: :- CLICKED, // Params -: :- FIRE_AT_ENTITIES, // Params -: :- SET_ACTION_CAMERA, // Params -: :- FIRE_AT_NOTHING, // Params -: :- //End Of Group: Tower Stuff //Group:Station stuff SELL_STATION, // Params -: :- SELL_ALL_TOWERS, // Params -: :- UPGRADE_ALL_TOWERS, // Params -: :- //End Of Group: Station stuff //Group:AI control AI_PAUSE_THINKING, // Params -: :- AI_RESUME_THINKING, // Params -: :- AI_SET_AGGRESSIVE, // Params -: :- AI_SET_PASSIVE, // Params -: :- AI_SET_DEFENSIVE, // Params -: :- ENTITIES_DETECTED, // Params -: :- ENEMIES_DETECTED, // Params -: :- //End Of Group: AI control //Group:Steering STEERING_TURN_OFF_ALL, // Params -: :- STEERING_TURN_ON_ALL, // Params -: :- STEERING_SEEK_TO_TARGET_POS, // Params -: XF::vector3 :- STEERING_FOLLOW_PATH, // Params -: PathDataPacket :- STEERING_ARRIVE_AT_TARGET_POS, // Params -: XF::vector3 :- STEERING_SET_ARRIVE_DECELERATION, // Params -: float :- STEERING_WANDER, // Params -: :- STEERING_UPDATE_STEER_DATA, // Params -: steering data :- PATH_DATA, // Params -: :- UPDATE_TARGET_POS, // Params -: :- UPDATE_TARGET_ENTITY, // Params -: :- SEND_ME_DISTANCE_TO_GOAL, // Params -: :- SENT_DISTANCE_TO_GOAL, // Params -: float :- TURN_ON_STEERING_BEHAVIOUR, // Params -: :- TURN_OFF_STEERING_BEHAVIOUR, // Params -: :- ADD_STEERING_BEHAVIOUR, // Params -: :- REMOVE_STEERING_BEHAVIOUR, // Params -: :- //End Of Group: Steering //Group:Body APPLY_FORCE, // Params -: :- SET_POSITION, // Params -: :- ROTATE_TO_FACE, // Params -: vector3 :- //End Of Group: Body //Group:Entity To Self CREATE_FIRE_AND_FORGET_ENTITY, // Params -: :- DIED, // Params -: :- CREATED, // Params -: :- FIRE, // Params -: :- ROAD_MAP_CHANGED, // Params -: :- ARRIVED_AT_GOAL, // Params -: :- OOPS, // Params -: :- //This message is sent to itself if the entity kills someone on their own team HEALTH_CHANGED, // Params -: :- YOU_ARE_FROZEN, // Params -: :- YOU_ARE_UNFROZEN, // Params -: :- YOU_ARE_SLOWED, // Params -: :- YOU_ARE_NOT_SLOWED, // Params -: :- //End Of Group: Entity To Self //Group:Entity Out DECREASE_ENEMIES, // Params -: :- //End Of Group: Entity Out }; std::string MessageSubjectToString(XF::MessageSubject::ENUM sub); XF::MessageSubject::ENUM StringToMessageSubject(std::string message);}}
Now as you can see, this file is buryed deep inside the engine, and requires modifying every time a new message is needed, not very good for compiling the library into a .lib and jsut using that instead of recompiling it from source every time.
Now, I would rather steer clear of the obvious "change messageSubject to a string" if possible, so does anyone have any suggestions as to how I can change this?
Thanks all, Scott
Code posted to google code: https://code.google.com/p/xframeworkcomponentsengine/
[Edited by - gameXcore on June 1, 2010 5:24:43 PM]