////////////////////////////////////////////////////////////////////////////////
// GameObject.h
// Class Declaration for objects that can be destroyed in MechVM
// Copyright Bjoern Ganster
// Developed since 2020
////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "BGCPString.h"
#include "Mesh.h"

class GameObject: public Mesh {
public:
	// Constructor
	GameObject(const char* className = "GameObject", 
		BGClassID classID = GameObjectID, RenderableObject* parent = NULL);

	// Destructor
	~GameObject() OVERRIDE;

	// Health measures how much damage an object can before being destroyed
	void setHealth(double newVal);

	// Function to notify object that it is taking damage
	virtual void receiveDamage(RenderableObject* limb, double damage, GameObject* sender, const Point3D& pointOfImpact);

	// Is the game object destroyed?
	virtual bool isDestroyed() const;

	void setDescriptionText(const BGCPString& str);
	const BGCPString& getDescriptionText() const;

	void setInspectionText(const BGCPString& str);
	const BGCPString& getInspectionText() const;

	void setID(const BGCPString& str);

	const BGCPString& getID() const;

	void setPosition(double x, double y, double z);
	void setPosition(const Point3D& pos);
	const Point3D& getPosition() const;
	Point3D getCenterOfMass();

	void setInspected(bool newVal = true);
	bool getInspected() const;

	// Set geometry to use when this object is destroyed
	void setDestroyedGeometry(Mesh* mesh);

	// Set colors for wireframe rendering
	virtual void setWireframeColors();

	// Get/set faction
	void setFaction(const BGCPString& aFaction);
	const BGCPString& getFaction() const;

protected:
	Point3D mPosition;
	double mHealth;
	double mDamageReceived;
	bool mInspected;
	BGCPString mDescriptionText, mInspectionText, mID, mFaction;
	Mesh* mDestroyedGeometry;
};

// Find GameObject with given id in scene recursively
GameObject* findGameObject(RenderableObject* ro, const BGCPString& id);
