/**
 * @file Ogre.h
 * @brief Stub Ogre.h for standalone tests.
 *
 * Provides minimal Ogre type aliases needed to compile
 * ActionDatabase, GoapBlackboard, GoapGoal, GoapAction,
 * and BehaviorTree components without the full Ogre SDK.
 *
 * Only for use in standalone tests (action_db_lua_test).
 */

#ifndef OGRE_STUB_H
#define OGRE_STUB_H

#include <string>
#include <vector>
#include <cstdint>
#include <cstdio>
#include <sstream>
#include <cassert>

namespace Ogre
{

// String is just std::string
using String = std::string;

// Minimal Vector3 for GoapBlackboard
struct Vector3 {
	float x, y, z;
	Vector3()
		: x(0)
		, y(0)
		, z(0)
	{
	}
	Vector3(float x_, float y_, float z_)
		: x(x_)
		, y(y_)
		, z(z_)
	{
	}
	static const Vector3 ZERO;

	// Member operator== defined inline inside the struct body
	// This ensures it's found by ADL for std::pair::operator==
	bool operator==(const Vector3 &other) const
	{
		return x == other.x && y == other.y && z == other.z;
	}
};

inline const Vector3 Vector3::ZERO(0, 0, 0);

// Minimal StringConverter stub for GoapBlackboard::dump()
struct StringConverter {
	static String toString(int val)
	{
		return std::to_string(val);
	}
	static String toString(float val)
	{
		return std::to_string(val);
	}
};

// Minimal LogManager stub (used by LuaActionApi and ActionDatabase)
class LogManager {
public:
	static LogManager &getSingleton()
	{
		static LogManager instance;
		return instance;
	}

	class Stream {
	public:
		template <typename T> Stream &operator<<(const T &)
		{
			return *this;
		}
	};

	Stream stream()
	{
		return Stream();
	}

	void logMessage(const String &, int = 0, bool = false)
	{
	}
};

// Minimal ResourceGroupManager stub (used by ActionDatabase save/load)
class ResourceGroupManager {
public:
	// LocationList is a vector of shared_ptr to Location
	struct Location {
		struct Archive {
			String getName() const
			{
				return "";
			}
		};
		// Use raw pointer to avoid shared_ptr dependency
		Archive *archive;
	};
	using LocationList = std::vector<Location>;

	static ResourceGroupManager &getSingleton()
	{
		static ResourceGroupManager instance;
		return instance;
	}

	const LocationList &getResourceLocationList(const String &) const
	{
		static LocationList empty;
		return empty;
	}
};

// OgreAssert macro (used by LuaEntityApi.hpp)
#ifndef OgreAssert
#define OgreAssert(expr, msg)                                            \
	do {                                                             \
		if (!(expr)) {                                           \
			fprintf(stderr, "OgreAssert failed: %s\n", msg); \
			assert(expr);                                    \
		}                                                        \
	} while (0)
#endif

} // namespace Ogre

#endif // OGRE_STUB_H
