Specify unit type name.

This commit is contained in:
Steve 2018-01-31 08:08:50 +00:00
parent eeeee41ef1
commit 81000d7948
5 changed files with 6 additions and 14 deletions

View File

@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "pistolBlob.h" #include "pistolBlob.h"
static int canFire(Entity *target); static int canFire(Entity *target);
static void (*superSave)(cJSON *root);
static void save(cJSON *root);
Entity *initPistolBlob(void) Entity *initPistolBlob(void)
{ {
@ -32,6 +30,8 @@ Entity *initPistolBlob(void)
initEvilBlob(u); initEvilBlob(u);
u->unitType = "PistolBlob";
u->sprite[FACING_LEFT] = getSprite("PistolBlobLeft"); u->sprite[FACING_LEFT] = getSprite("PistolBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("PistolBlobRight"); u->sprite[FACING_RIGHT] = getSprite("PistolBlobRight");
u->sprite[FACING_DIE] = getSprite("PistolBlobSpin"); u->sprite[FACING_DIE] = getSprite("PistolBlobSpin");
@ -40,10 +40,7 @@ Entity *initPistolBlob(void)
u->maxShotsToFire = 3; u->maxShotsToFire = 3;
superSave = u->save;
u->canFire = canFire; u->canFire = canFire;
u->save = save;
return (Entity*)u; return (Entity*)u;
} }
@ -52,10 +49,3 @@ static int canFire(Entity *target)
{ {
return 1; return 1;
} }
static void save(cJSON *root)
{
superSave(root);
cJSON_AddStringToObject(root, "type", "PistolBlob");
}

View File

@ -30,6 +30,8 @@ Entity *initPistolDroid(void)
initEyeDroid(u); initEyeDroid(u);
u->unitType = "PistolEyeDroid";
u->sprite[FACING_LEFT] = getSprite("PistolDroidLeft"); u->sprite[FACING_LEFT] = getSprite("PistolDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("PistolDroidRight"); u->sprite[FACING_RIGHT] = getSprite("PistolDroidRight");
u->sprite[FACING_DIE] = getSprite("PistolDroidDie"); u->sprite[FACING_DIE] = getSprite("PistolDroidDie");

View File

@ -21,5 +21,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h" #include "../../common.h"
extern Sprite *getSprite(char *name); extern Sprite *getSprite(char *name);
extern Structure *createStructure(void);
extern Entity *initDoor(void); extern Entity *initDoor(void);

View File

@ -244,7 +244,7 @@ static void save(cJSON *root)
u = (Unit*)self; u = (Unit*)self;
cJSON_AddStringToObject(root, "type", "Unit"); cJSON_AddStringToObject(root, "type", u->unitType);
cJSON_AddNumberToObject(root, "canCarryItem", u->canCarryItem); cJSON_AddNumberToObject(root, "canCarryItem", u->canCarryItem);
cJSON_AddNumberToObject(root, "startX", u->startX); cJSON_AddNumberToObject(root, "startX", u->startX);
cJSON_AddNumberToObject(root, "startY", u->startY); cJSON_AddNumberToObject(root, "startY", u->startY);

View File

@ -161,6 +161,7 @@ struct EntityExt {
struct Unit { struct Unit {
struct EntityExt; struct EntityExt;
char *unitType;
int weaponType; int weaponType;
int canCarryItem; int canCarryItem;
int reload; int reload;