//Copyright (C) 2007 SiegeLord
//See ReadMe.txt and License.txt for copying information

#pragma once

#include "engine.h"
#include "math_types.h"

#ifndef NUM_OBJECT_TYPES
#define NUM_OBJECT_TYPES 20
#endif

enum EObjectType
{
	dummyobject_type,
	particleholder_type,
	auraparticle_type,
	smokeparticle_type,
	trail_type,
	userobject_type
};

struct SObject
{
	SObject()
	{
		type = dummyobject_type;
	}

	virtual ~SObject() {};
	virtual int Handle() {return 0;};
	virtual void Draw() {};

	int type;

	transform2d local_transform;//local transformation
	transform2d net_transform;//net transformation

	vector2d position;//local position
	float depth;
	float rotation;//local rotation

	SObject* parent;

	list<SObject*> children;

	inline void SetPosition(float x, float y)
	{
		position.Set(x, y);
		local_transform.SetTranslation(x, y);
	}
	inline void SetRotation(float theta)
	{
		local_transform.SetRotation(theta);
		rotation = theta;
	}
	inline vector2d GetGlobalPosition()
	{
		vector2d vec;
		net_transform.TransformVector(&vec);
		return vec;
	}

};

//this gets the net position of the object by going up towards its parent,
//transforming its local transformation
void UpdatePosition(SObject* obj);

int HandleObject(SObject* obj);

void DrawObject(SObject* obj);

int DoObjectLogic(SObject* obj);

void DestroyObject(SObject* obj);

SObject* InitObject(SObject* obj, SObject* parent);
