1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

WIP loot distribution prototyping.

This commit is contained in:
Sandu Liviu Catalin 2021-04-01 21:58:42 +03:00
parent 0ec506f8e8
commit 8dfeba7719
4 changed files with 246 additions and 0 deletions

View File

@ -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

19
module/Core/Loot.cpp Normal file
View File

@ -0,0 +1,19 @@
// ------------------------------------------------------------------------------------------------
#include "Core/Loot.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstring>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
// ================================================================================================
void Register_Loot(HSQUIRRELVM vm)
{
}
} // Namespace:: SqMod

224
module/Core/Loot.hpp Normal file
View File

@ -0,0 +1,224 @@
#pragma once
// ------------------------------------------------------------------------------------------------
#include "Core/Utility.hpp"
#include "Base/Vector3.hpp"
#include "Base/Quaternion.hpp"
// ------------------------------------------------------------------------------------------------
#include <array>
#include <vector>
#include <random>
#include <chrono>
// ------------------------------------------------------------------------------------------------
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

View File

@ -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);