/*
 * Entity.cpp
 *
 *  Created on: 2009-07-10
 *      Author: wasyl
 */

#include <cstdio>

#include "Entity.h"
#include "World.h"

void Entity::discard()
{
	mWorld->remove(this);
}


int Entity::loadByte(FILE *f)
{
	return fgetc(f);
}

void Entity::saveByte(FILE *f, int b)
{
	fputc(b, f);
}

void Entity::save(FILE *f)
{
	saveByte(f, code()[0]);
	saveByte(f, code()[1]);
	saveByte(f, int(mPos.x) / 20 );
	saveByte(f, int(mPos.y) / 20 );
}

void Entity::load(FILE *f)
{
	int x = loadByte(f);
	int y = loadByte(f);
	mPos.x = x * 20.0;
	mPos.y = y * 20.0;
}
