From 8dfeba7719f52b1648408ee424295ff7560f8c1f Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 1 Apr 2021 21:58:42 +0300 Subject: [PATCH] WIP loot distribution prototyping. --- module/CMakeLists.txt | 1 + module/Core/Loot.cpp | 19 ++++ module/Core/Loot.hpp | 224 ++++++++++++++++++++++++++++++++++++++++++ module/Register.cpp | 2 + 4 files changed, 246 insertions(+) create mode 100644 module/Core/Loot.cpp create mode 100644 module/Core/Loot.hpp diff --git a/module/CMakeLists.txt b/module/CMakeLists.txt index 47040fc9..51bc9258 100644 --- a/module/CMakeLists.txt +++ b/module/CMakeLists.txt @@ -38,6 +38,7 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp Core/Command.cpp Core/Command.hpp Core/Common.cpp Core/Common.hpp Core/Entity.cpp Core/Entity.hpp + Core/Loot.cpp Core/Loot.hpp Core/Privilege.cpp Core/Privilege.hpp Core/Privilege/Base.cpp Core/Privilege/Base.hpp Core/Privilege/Class.cpp Core/Privilege/Class.hpp diff --git a/module/Core/Loot.cpp b/module/Core/Loot.cpp new file mode 100644 index 00000000..7f3b1c9d --- /dev/null +++ b/module/Core/Loot.cpp @@ -0,0 +1,19 @@ +// ------------------------------------------------------------------------------------------------ +#include "Core/Loot.hpp" + +// ------------------------------------------------------------------------------------------------ +#include + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +// ------------------------------------------------------------------------------------------------ + + +// ================================================================================================ +void Register_Loot(HSQUIRRELVM vm) +{ + +} + +} // Namespace:: SqMod diff --git a/module/Core/Loot.hpp b/module/Core/Loot.hpp new file mode 100644 index 00000000..f352ebf4 --- /dev/null +++ b/module/Core/Loot.hpp @@ -0,0 +1,224 @@ +#pragma once + +// ------------------------------------------------------------------------------------------------ +#include "Core/Utility.hpp" +#include "Base/Vector3.hpp" +#include "Base/Quaternion.hpp" + +// ------------------------------------------------------------------------------------------------ +#include +#include +#include +#include + +// ------------------------------------------------------------------------------------------------ +namespace SqMod { + +/* ------------------------------------------------------------------------------------------------ + * Defines the type of loot and is responsible for creating and destroying the associated item. +*/ +struct LootFactory +{ + // -------------------------------------------------------------------------------------------- + SQInteger mID{-1}; // User defined item identifier. + SQInteger mType{-1}; // User defined item type. + SQInteger mClass{-1}; // User defined item class. + + // -------------------------------------------------------------------------------------------- + String mTag; // User tag associated with this instance. + LightObj mData; // User data associated with this instance. + + // -------------------------------------------------------------------------------------------- + Function mCreate{}; // Callback to create the loot item. + Function mDelete{}; // Callback to delete the loot item. + + /* -------------------------------------------------------------------------------------------- + * Default constructor. + */ + LootFactory() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy constructor. (disabled) + */ + LootFactory(const LootFactory & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Move constructor. (disabled) + */ + LootFactory(LootFactory && o) noexcept = default; + + /* -------------------------------------------------------------------------------------------- + * Destructor. + */ + ~LootFactory() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootFactory & operator = (const LootFactory & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootFactory & operator = (LootFactory && o) noexcept = default; +}; + +/* ------------------------------------------------------------------------------------------------ + * Defines an entry inside a loot cluster where a single loot item can be spawned. +*/ +struct LootSpawn +{ + Vector3 mPos; // Spawn position + + /* -------------------------------------------------------------------------------------------- + * Default constructor. + */ + LootSpawn() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy constructor. (disabled) + */ + LootSpawn(const LootSpawn & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Move constructor. (disabled) + */ + LootSpawn(LootSpawn && o) noexcept = default; + + /* -------------------------------------------------------------------------------------------- + * Destructor. + */ + ~LootSpawn() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootSpawn & operator = (const LootSpawn & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootSpawn & operator = (LootSpawn && o) noexcept = default; +}; + +/* ------------------------------------------------------------------------------------------------ + * Defines a cluster of loot spawns with little space in between where associated items can be spawned. +*/ +class LootCluster +{ + // -------------------------------------------------------------------------------------------- + LightObj mData; // User data associated with this instance. + + /* -------------------------------------------------------------------------------------------- + * Default constructor. + */ + LootCluster() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy constructor. (disabled) + */ + LootCluster(const LootCluster & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Move constructor. (disabled) + */ + LootCluster(LootCluster && o) noexcept = default; + + /* -------------------------------------------------------------------------------------------- + * Destructor. + */ + ~LootCluster() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootCluster & operator = (const LootCluster & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootCluster & operator = (LootCluster && o) noexcept = default; +}; + +/* ------------------------------------------------------------------------------------------------ + * Defines a region of loot clusters where various attributes can be influenced globally. +*/ +class LootRegion +{ + // -------------------------------------------------------------------------------------------- + String mTag; // User tag associated with this instance. + LightObj mData; // User data associated with this instance. + + /* -------------------------------------------------------------------------------------------- + * Default constructor. + */ + LootRegion() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy constructor. (disabled) + */ + LootRegion(const LootRegion & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Move constructor. (disabled) + */ + LootRegion(LootRegion && o) noexcept = default; + + /* -------------------------------------------------------------------------------------------- + * Destructor. + */ + ~LootRegion() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootRegion & operator = (const LootRegion & o) = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootRegion & operator = (LootRegion && o) noexcept = default; +}; + +/* ------------------------------------------------------------------------------------------------ + * Loot distribution utility. +*/ +class LootManager +{ +public: + + /* -------------------------------------------------------------------------------------------- + * Default constructor. + */ + LootManager() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy constructor. (disabled) + */ + LootManager(const LootManager & o) = delete; + + /* -------------------------------------------------------------------------------------------- + * Move constructor. (disabled) + */ + LootManager(LootManager && o) = delete; + + /* -------------------------------------------------------------------------------------------- + * Destructor. + */ + ~LootManager() = default; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootManager & operator = (const LootManager & o) = delete; + + /* -------------------------------------------------------------------------------------------- + * Copy assignment operator. (disabled) + */ + LootManager & operator = (LootManager && o) = delete; + +private: + +}; + +} // Namespace:: SqMod diff --git a/module/Register.cpp b/module/Register.cpp index 0d37b566..878f4fea 100644 --- a/module/Register.cpp +++ b/module/Register.cpp @@ -50,6 +50,7 @@ extern void Register_Constants(HSQUIRRELVM vm); extern void Register_Log(HSQUIRRELVM vm); extern void Register_Core(HSQUIRRELVM vm); extern void Register_Command(HSQUIRRELVM vm); +extern void Register_Loot(HSQUIRRELVM vm); extern void Register_Privilege(HSQUIRRELVM vm); extern void Register_Routine(HSQUIRRELVM vm); extern void Register_Tasks(HSQUIRRELVM vm); @@ -103,6 +104,7 @@ bool RegisterAPI(HSQUIRRELVM vm) Register_Log(vm); Register_Core(vm); Register_Command(vm); + Register_Loot(vm); Register_Privilege(vm); Register_Routine(vm); Register_Tasks(vm);