Fixed teleporter.

This commit is contained in:
Steve 2018-02-03 16:13:37 +00:00
parent e97d38e278
commit d51e96c74a
3 changed files with 28 additions and 1 deletions

View File

@ -120,10 +120,23 @@ static void activate(int active)
static void load(cJSON *root)
{
/* nothing to do */
Structure *s;
s = (Structure*)self;
s->active = cJSON_GetObjectItem(root, "active")->valueint;
s->tx = cJSON_GetObjectItem(root, "tx")->valueint;
s->ty = cJSON_GetObjectItem(root, "ty")->valueint;
}
static void save(cJSON *root)
{
Structure *s;
s = (Structure*)self;
cJSON_AddStringToObject(root, "type", "Teleporter");
cJSON_AddNumberToObject(root, "active", s->active);
cJSON_AddNumberToObject(root, "tx", s->tx);
cJSON_AddNumberToObject(root, "ty", s->ty);
}

View File

@ -798,6 +798,12 @@ void activateEntities(char *names, int active)
void teleportEntity(Entity *e, float tx, float ty)
{
e->tx = tx;
e->ty = ty;
e->flags |= EF_TELEPORTING;
addTeleportStars(e);
}
static void handleTeleport(void)
@ -876,6 +882,13 @@ void teleport(Entity *e, float tx, float ty)
e->flags |= EF_TELEPORTING;
addTeleportStars(e);
if (e == (Entity*)world.bob)
{
terminateJetpack();
world.bob->flags &= ~(EF_WATER_BREATHING | EF_WEIGHTLESS);
}
}
Entity *findEntity(char *name)

View File

@ -37,6 +37,7 @@ extern float limit(float i, float a, float b);
extern int isWalkable(int x, int y);
extern int isLiquid(int x, int y);
extern int isSolid(int x, int y);
extern void terminateJetpack(void);
extern Entity *self;
extern Camera camera;