src/ai/squirrel/squirrel.hpp
author truelight
Wed, 14 Mar 2007 11:20:56 +0000
branchnoai
changeset 9381 df270ca8eec8
parent 9377 3f1327677bcd
child 9385 56803dfb2ff6
permissions -rw-r--r--
(svn r9171) [NoAI] -Fix: call GameLoop() of the instance directly
/* $Id$ */

/** @file squirrel.hpp declarations of the class for squirrel loader */

#ifndef SQUIRREL_HPP
#define SQUIRREL_HPP

#include "../core/ai_controller.hpp"
#include "../core/ai_base.hpp"
#include <squirrel.h>

class Squirrel: public AIController {
private:
	HSQUIRRELVM vm;  ///< The Virtual Machine for squirrel
	HSQOBJECT SQ_instance; ///< The internal instance of squirrel

	/**
	 * Add a single method to a class (in creation) in Squirrel.
	 */
	void SQAddMethod(const char *name, SQFUNCTION proc, uint nparam, const char *params);

	/**
	 * Registers all our classes, so it can be used from Squirrel.
	 */
	void RegisterClasses();

	/**
	 * Constructor for Squirrel AIController. We assign the real 'this' value to
	 *  the instance pointer, so we can easy look up this->.
	 */
	static SQInteger SQConstructor(HSQUIRRELVM vm);

	/**
	 * Destructor for Squirrel AIController. This is called if the class is
	 *  destroyed inside the script.
	 */
	static SQInteger SQDestructor(SQUserPointer p, SQInteger size);

	/**
	 * A wrapper around the AIController class, as that can't be automated.
	 */
	static SQInteger SQGetTick(HSQUIRRELVM vm);

public:
	Squirrel(const char *script_dir);
	~Squirrel();

	/* virtual */ void GameLoop();
};

#endif /* SQUIRREL_HPP */