Hi
I have class called BaseEntity. I also have a class Entity that inheritse from that. Then I have a class WalkingEntity that inherits from Entity. Then I have a class called IntelligentEntity that inherits from WalkingEntity.I also have a class called EntityFactory that is supposedd to take in a message and return one of these Entity types.
This is my factory:
.
Code:
//execute the arbitration results
Advisor v = arbitrationer.decide(arbitration_list);
//assigns an entity to the Advisor
switch(v.m.event)
{
case BASE_ENTITY:
v.e = new BaseEntity;
break;
case ENTITY:
v.e = new Entity;
break;
case WEAPON_ENTITY:
v.e = new WeaponEntity;
break;
case WALKING_ENTITY:
v.e = new WalkingEntity;
break;
case INTELLIGENT_ENTITY:
v.e = new IntelligentEntity;
break;
case EMPTY_PAWN:
v.e = new EmptyPawn;
break;
case PLAYERCHARACTER:
v.e = new PlayerCharacter;
break;
case STATIC_MESH:
v.e = new StaticMesh;
}
*/
And advisor looks like:
Code:
class Advisor
{
public:
Message m;
BaseEntity e;
float weight;
};
And a message looks like;
Code:
class Message
{
public:
BaseEntity entity; //FSM to use
PlayerInputEnum event; //messages payload
void* payload; //dependent upon the event type. will look at this pointer
//for payload information
int priority; //used to calculate scheduling. 0 is immediately , 5 is slower, etc.
void load_entity(); //loads an FSM into Base Entity entity;
};
I would like to use the factory to generate types of entities. But the code above - the inhertiance is all wrong. I just need to be able to populate the BaseEntity field of the Message class, with any of the Entity classes (WALKING_ENTITY) for examples.
Does that make sense?