Adds secondary effect parameter system.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
141b8bbc5b
commit
e89d2a9e0c
|
@ -118,6 +118,7 @@ StatementMacros:
|
|||
- QT_REQUIRE_VERSION
|
||||
- Assert
|
||||
- AssertNotNull
|
||||
- Try
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
|
|
@ -5,14 +5,24 @@ using namespace CreatureLib::Library;
|
|||
export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* name, uint8_t type,
|
||||
AttackCategory category, uint8_t power, uint8_t accuracy,
|
||||
uint8_t baseUsage, AttackTarget target, int8_t priority,
|
||||
float effectChance, const char* effectName, const char* flags[],
|
||||
size_t flagsCount) {
|
||||
Try(std::unordered_set<uint32_t> conversedFlags(flagsCount); for (size_t i = 0; i < flagsCount; i++) {
|
||||
conversedFlags.insert(ConstString::GetHash(flags[i]));
|
||||
} auto effect = SecondaryEffect(effectChance, Arbutils::CaseInsensitiveConstString(effectName));
|
||||
float effectChance, const char* effectName, void* effectParameters[],
|
||||
size_t effectParameterCount, const char* flags[], size_t flagsCount) {
|
||||
Try({
|
||||
std::unordered_set<uint32_t> conversedFlags(flagsCount);
|
||||
for (size_t i = 0; i < flagsCount; i++) {
|
||||
conversedFlags.insert(ConstString::GetHash(flags[i]));
|
||||
}
|
||||
Arbutils::Collections::List<void*> effectParameterList(effectParameterCount);
|
||||
for (size_t i = 0; i < effectParameterCount; i++) {
|
||||
effectParameterList[i] = effectParameters[i];
|
||||
}
|
||||
|
||||
auto effect =
|
||||
SecondaryEffect(effectChance, Arbutils::CaseInsensitiveConstString(effectName), effectParameterList);
|
||||
|
||||
out = new AttackData(ConstString(name), type, category, power, accuracy, baseUsage, target, priority, effect,
|
||||
conversedFlags);)
|
||||
conversedFlags);
|
||||
})
|
||||
};
|
||||
|
||||
export void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
#ifndef CREATURELIB_SECONDARYEFFECT_HPP
|
||||
#define CREATURELIB_SECONDARYEFFECT_HPP
|
||||
|
||||
#include <Arbutils/Collections/List.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <any>
|
||||
|
||||
using namespace Arbutils::Collections;
|
||||
namespace CreatureLib::Library {
|
||||
class SecondaryEffect {
|
||||
private:
|
||||
float _chance;
|
||||
Arbutils::CaseInsensitiveConstString _effectName;
|
||||
List<void*> _parameters;
|
||||
|
||||
public:
|
||||
SecondaryEffect() noexcept : _chance(0), _effectName(Arbutils::CaseInsensitiveConstString("")) {}
|
||||
SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept
|
||||
: _chance(chance), _effectName(effectName) {}
|
||||
SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName,
|
||||
const List<void*>& parameters) noexcept
|
||||
: _chance(chance), _effectName(effectName), _parameters(parameters) {}
|
||||
|
||||
constexpr float GetChance() const noexcept { return _chance; }
|
||||
constexpr const Arbutils::CaseInsensitiveConstString& GetEffectName() const noexcept { return _effectName; }
|
||||
const List<void*>& GetParameters() const noexcept { return _parameters; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue