mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
-Added rage, and energy stat.
-Added class resource support. -Fixed bugs related to auras.
This commit is contained in:
parent
29b3ccb3b3
commit
f1194ab218
1
SCsub
1
SCsub
@ -49,6 +49,7 @@ module_env.add_source_files(env.modules_sources,"entities/auras/aura_data.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/entity.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/player.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/mob.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/entity_resource.cpp")
|
||||
|
||||
module_env.add_source_files(env.modules_sources,"ui/unit_frame.cpp")
|
||||
|
||||
|
@ -49,6 +49,13 @@ void Aura::set_aura_name(String name) {
|
||||
_aura_name = name;
|
||||
}
|
||||
|
||||
bool Aura::get_hide() {
|
||||
return _hide;
|
||||
}
|
||||
void Aura::set_hide(bool value) {
|
||||
_hide = value;
|
||||
}
|
||||
|
||||
String Aura::get_aura_description() {
|
||||
return _aura_description;
|
||||
}
|
||||
@ -278,6 +285,7 @@ Aura::Aura() {
|
||||
_aura_type = SpellEnums::AURA_TYPE_NONE;
|
||||
_is_debuff = false;
|
||||
aura_group = 0;
|
||||
_hide = false;
|
||||
|
||||
_damage_enabled = false;
|
||||
_damage_type = 0;
|
||||
@ -633,8 +641,16 @@ void Aura::_setup_aura_data(Ref<AuraData> data, Ref<AuraApplyInfo> info) {
|
||||
ERR_FAIL_COND(info->get_caster() == NULL);
|
||||
|
||||
data->set_aura(Ref<Aura>(this));
|
||||
data->set_aura_id(get_id());
|
||||
data->set_caster(info->get_caster());
|
||||
data->set_remaining_time(get_time());
|
||||
|
||||
if (get_time() > 0.2) {
|
||||
data->set_is_timed(true);
|
||||
data->set_remaining_time(get_time());
|
||||
|
||||
} else {
|
||||
data->set_is_timed(false);
|
||||
}
|
||||
|
||||
if (is_damage_enabled()) {
|
||||
calculate_initial_damage(data, info);
|
||||
@ -743,6 +759,7 @@ void Aura::_sapply(Ref<AuraApplyInfo> info) {
|
||||
Ref<AuraData> ad(memnew(AuraData()));
|
||||
setup_aura_data(ad, info);
|
||||
|
||||
info->get_target()->sremove_aura(ad);
|
||||
info->get_target()->sadd_aura(ad);
|
||||
}
|
||||
|
||||
@ -766,7 +783,10 @@ void Aura::_sremove_dispell(Ref<AuraData> aura) {
|
||||
|
||||
void Aura::_supdate(Ref<AuraData> aura, float delta) {
|
||||
|
||||
bool remove = aura->update_remaining_time(delta);
|
||||
bool remove = false;
|
||||
|
||||
if (aura->get_is_timed())
|
||||
remove = aura->update_remaining_time(delta);
|
||||
|
||||
//ontick
|
||||
if (aura->get_unhandled_ticks() != 0) {
|
||||
@ -963,6 +983,10 @@ void Aura::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_aura_group", "value"), &Aura::set_aura_group);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "aura_group"), "set_aura_group", "get_aura_group");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_hide"), &Aura::get_hide);
|
||||
ClassDB::bind_method(D_METHOD("set_hide", "value"), &Aura::set_hide);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide"), "set_hide", "get_hide");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_ability_scale_data_id"), &Aura::get_ability_scale_data_id);
|
||||
ClassDB::bind_method(D_METHOD("set_ability_scale_data_id", "value"), &Aura::set_ability_scale_data_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "ability_scale_data_id"), "set_ability_scale_data_id", "get_ability_scale_data_id");
|
||||
|
@ -50,6 +50,9 @@ public:
|
||||
String get_aura_name();
|
||||
void set_aura_name(String name);
|
||||
|
||||
bool get_hide();
|
||||
void set_hide(bool value);
|
||||
|
||||
String get_aura_description();
|
||||
void set_aura_description(String description);
|
||||
|
||||
@ -337,6 +340,7 @@ private:
|
||||
Ref<Texture> _icon;
|
||||
SpellEnums::AuraType _aura_type;
|
||||
bool _is_debuff;
|
||||
bool _hide;
|
||||
|
||||
String _aura_name;
|
||||
String _aura_description;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "character.h"
|
||||
|
||||
#include "../data/spell.h"
|
||||
#include "../data/aura.h"
|
||||
#include "../entities/entity.h"
|
||||
|
||||
int CharacterClass::get_id() {
|
||||
@ -68,6 +69,8 @@ Ref<Spell> CharacterClass::get_spell(int id) {
|
||||
}
|
||||
|
||||
void CharacterClass::set_spell(int index, Ref<Spell> spell) {
|
||||
ERR_FAIL_INDEX(index, MAX_AURAS);
|
||||
|
||||
_spells[index] = Ref<Spell>(spell);
|
||||
}
|
||||
|
||||
@ -80,13 +83,28 @@ void CharacterClass::set_num_specs(int value) {
|
||||
}
|
||||
|
||||
Ref<CharacterSpec> CharacterClass::get_spec(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_SPECS, Ref<CharacterSpec>());
|
||||
|
||||
return _specs[index];
|
||||
}
|
||||
|
||||
void CharacterClass::set_spec(int index, Ref<CharacterSpec> spec) {
|
||||
ERR_FAIL_INDEX(index, MAX_SPECS);
|
||||
|
||||
_specs[index] = Ref<CharacterSpec>(spec);
|
||||
}
|
||||
|
||||
Ref<Aura> CharacterClass::get_aura(int index) {
|
||||
ERR_FAIL_INDEX_V(index, MAX_AURAS, Ref<Aura>());
|
||||
|
||||
return _auras[index];
|
||||
}
|
||||
void CharacterClass::set_aura(int index, Ref<Aura> aura) {
|
||||
ERR_FAIL_INDEX(index, MAX_AURAS);
|
||||
|
||||
_auras[index] = aura;
|
||||
}
|
||||
|
||||
/*
|
||||
Vector<int> CharacterClass::get_mob_party_ids() {
|
||||
return _mob_party_ids;
|
||||
@ -219,6 +237,16 @@ void CharacterClass::_bind_methods() {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Spec_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "CharacterSpec", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_spec", "get_spec", i);
|
||||
}
|
||||
|
||||
//// AURAS ////
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_aura", "index"), &CharacterClass::get_aura);
|
||||
ClassDB::bind_method(D_METHOD("set_aura", "index", "aura"), &CharacterClass::set_aura);
|
||||
|
||||
ADD_GROUP("Auras", "Aura");
|
||||
for (int i = 0; i < MAX_AURAS; ++i) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Aura_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Aura", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_aura", "get_aura", i);
|
||||
}
|
||||
|
||||
//// Spell ////
|
||||
ClassDB::bind_method(D_METHOD("get_num_spells"), &CharacterClass::get_num_spells);
|
||||
ClassDB::bind_method(D_METHOD("set_num_spells", "value"), &CharacterClass::set_num_spells);
|
||||
@ -237,6 +265,7 @@ void CharacterClass::_bind_methods() {
|
||||
|
||||
BIND_CONSTANT(MAX_SPELLS);
|
||||
BIND_CONSTANT(MAX_SPECS);
|
||||
BIND_CONSTANT(MAX_AURAS);
|
||||
}
|
||||
|
||||
CharacterClass::CharacterClass() {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "../entity_enums.h"
|
||||
#include "character_spec.h"
|
||||
|
||||
class Aura;
|
||||
class Spell;
|
||||
class Entity;
|
||||
class CharacterSpec;
|
||||
@ -55,6 +56,9 @@ public:
|
||||
Ref<CharacterSpec> get_spec(int index) const;
|
||||
void set_spec(int index, Ref<CharacterSpec> spec);
|
||||
|
||||
Ref<Aura> get_aura(int index);
|
||||
void set_aura(int index, Ref<Aura> aura);
|
||||
|
||||
/*
|
||||
Vector<int> get_talent_ids();
|
||||
void set_talent_ids(Vector<int> ids);
|
||||
@ -96,13 +100,15 @@ protected:
|
||||
static void _bind_methods();
|
||||
void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
private:
|
||||
public:
|
||||
enum {
|
||||
MAX_SPELLS = 100,
|
||||
MAX_SPECS = 5,
|
||||
MAX_AURAS = 5,
|
||||
ITEMS_PER_PAGE = 10,
|
||||
};
|
||||
|
||||
private:
|
||||
int _id;
|
||||
String _character_class_name;
|
||||
Ref<Texture> _icon;
|
||||
@ -118,6 +124,8 @@ private:
|
||||
int _num_specs;
|
||||
Ref<CharacterSpec> _specs[MAX_SPECS];
|
||||
|
||||
Ref<Aura> _auras[MAX_AURAS];
|
||||
|
||||
//Vector<int> _mob_party_ids;
|
||||
//Vector<int> _mob_dislike_ids;
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
#include "PlayerResource.h"
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
public:
|
||||
virtual int getCurrent() = 0;
|
||||
public:
|
||||
virtual void setCurrent(int value) = 0;
|
||||
public:
|
||||
virtual int getMax() = 0;
|
||||
public:
|
||||
virtual void setMax(int value) = 0;
|
||||
bool PlayerResource::getDirty(){
|
||||
return this->dirty;
|
||||
}
|
||||
void PlayerResource::setDirty(bool value)
|
||||
{
|
||||
this->dirty = value;
|
||||
}
|
||||
PlayerResource::PlayerResource()
|
||||
{
|
||||
Current_var = (int)(0);
|
||||
Max_var = (int)(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
|
||||
using namespace System;
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
class PlayerResource : public abstract virtual Object
|
||||
{
|
||||
private:
|
||||
bool dirty;
|
||||
public:
|
||||
int getCurrent();
|
||||
public:
|
||||
void setCurrent(int value);
|
||||
public:
|
||||
int getMax();
|
||||
public:
|
||||
void setMax(int value);
|
||||
public:
|
||||
bool getDirty();
|
||||
public:
|
||||
void setDirty(bool value);
|
||||
public:
|
||||
virtual int Current_var;
|
||||
public:
|
||||
virtual int Max_var;
|
||||
public:
|
||||
PlayerResource();
|
||||
};
|
||||
}
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
#include "PlayerResourceComponent.h"
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
//Delegate declaration moved to header file
|
||||
void PlayerResourceComponent::addCOnResourcesChanged(PlayerResourceComponent::COnResourcesChangedAction* value){
|
||||
PlayerResourceComponent::COnResourcesChangedAction* cOnResourcesChangedAction = this->COnResourcesChanged;
|
||||
PlayerResourceComponent::COnResourcesChangedAction* cOnResourcesChangedAction2;
|
||||
do{
|
||||
cOnResourcesChangedAction2 = cOnResourcesChangedAction;
|
||||
PlayerResourceComponent::COnResourcesChangedAction* value2 = (PlayerResourceComponent::COnResourcesChangedAction*)(Delegate::Combine(cOnResourcesChangedAction2, value));
|
||||
cOnResourcesChangedAction = Interlocked::CompareExchange<PlayerResourceComponent::COnResourcesChangedAction*>(this->COnResourcesChanged, value2, cOnResourcesChangedAction2);
|
||||
}
|
||||
while (*cOnResourcesChangedAction != *cOnResourcesChangedAction2);
|
||||
}
|
||||
void PlayerResourceComponent::removeCOnResourcesChanged(PlayerResourceComponent::COnResourcesChangedAction* value)
|
||||
{
|
||||
PlayerResourceComponent::COnResourcesChangedAction* cOnResourcesChangedAction = this->COnResourcesChanged;
|
||||
PlayerResourceComponent::COnResourcesChangedAction* cOnResourcesChangedAction2;
|
||||
do {
|
||||
cOnResourcesChangedAction2 = cOnResourcesChangedAction;
|
||||
PlayerResourceComponent::COnResourcesChangedAction* value2 = (PlayerResourceComponent::COnResourcesChangedAction*)(Delegate::Remove(cOnResourcesChangedAction2, value));
|
||||
cOnResourcesChangedAction = Interlocked::CompareExchange<PlayerResourceComponent::COnResourcesChangedAction*>(this->COnResourcesChanged, value2, cOnResourcesChangedAction2);
|
||||
}
|
||||
while (*cOnResourcesChangedAction != *cOnResourcesChangedAction2);
|
||||
}
|
||||
|
||||
List_T<PlayerResource>* PlayerResourceComponent::getSResources()
|
||||
{
|
||||
return this->sResources;
|
||||
}
|
||||
List_T<PlayerResource>* PlayerResourceComponent::getCResources()
|
||||
{
|
||||
return this->cResources;
|
||||
}
|
||||
bool PlayerResourceComponent::getFinished()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool PlayerResourceComponent::getLoaded()
|
||||
{
|
||||
return this->loaded;
|
||||
}
|
||||
void PlayerResourceComponent::setLoaded(bool value)
|
||||
{
|
||||
this->loaded = value;
|
||||
}
|
||||
PlayerResourceComponent::PlayerResourceComponent(WorldEntity* owner)
|
||||
{
|
||||
cResources = new List_T<PlayerResource>();
|
||||
sResources = new List_T<PlayerResource>();
|
||||
this->owner = owner;
|
||||
}
|
||||
void PlayerResourceComponent::Init()
|
||||
{
|
||||
PlayerData* playerData = this->owner->PlayerData;
|
||||
this->characterResourceData = playerData->getCharacter()->ResourceData;
|
||||
if (!this->init && this->characterResourceData->Rage) {
|
||||
if (this->owner->isServer) {
|
||||
this->sResources->Add(new RageResource());
|
||||
}
|
||||
if (this->owner->isClient) {
|
||||
this->cResources->Add(new RageResource());
|
||||
if (this->COnResourcesChanged != null) {
|
||||
DELEGATE_INVOKE(this->COnResourcesChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::LateUpdate()
|
||||
{
|
||||
if (!this->owner->isServer) {
|
||||
return;
|
||||
}
|
||||
if (this->getLoaded()) {
|
||||
this->setLoaded(false);
|
||||
this->SSendClear();
|
||||
for (int i = 0; i < this->sResources->Count; i += 1) {
|
||||
if (is_inst_of<RageResource*>(this->sResources->GetData(i))) {
|
||||
this->SSendAddResource(PlayerResourceTypes::Rage);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < this->sResources->Count; j += 1) {
|
||||
PlayerResource* playerResource = this->sResources->GetData(j);
|
||||
if (playerResource->getDirty() && is_inst_of<RageResource*>(playerResource)) {
|
||||
this->SSendRage(as_cast<RageResource*>(playerResource)->Current);
|
||||
playerResource->setDirty(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::SClear()
|
||||
{
|
||||
this->init = true;
|
||||
this->sResources->Clear();
|
||||
if (!this->getLoaded()) {
|
||||
this->SSendClear();
|
||||
}
|
||||
}
|
||||
PlayerResource* PlayerResourceComponent::SAddResource(PlayerResourceTypes type)
|
||||
{
|
||||
PlayerResource* playerResource = null;
|
||||
if (type == PlayerResourceTypes::Rage) {
|
||||
playerResource = this->SGetPlayerResource<RageResource>();
|
||||
if (playerResource != null) {
|
||||
return playerResource;
|
||||
}
|
||||
playerResource = new RageResource();
|
||||
this->sResources->Add(playerResource);
|
||||
}
|
||||
if (!this->getLoaded()) {
|
||||
this->SSendAddResource(type);
|
||||
}
|
||||
return playerResource;
|
||||
}
|
||||
void PlayerResourceComponent::SSendRage(int current)
|
||||
{
|
||||
if (CxNet::IsServer) {
|
||||
SSendRageMsg sSendRageMsg = SSendRageMsg();
|
||||
sSendRageMsg.Guid = this->owner->PlayerData->GUID;
|
||||
sSendRageMsg.Current = current;
|
||||
sSendRageMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToAllClients(0);
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::SSendAddResource(PlayerResourceTypes type)
|
||||
{
|
||||
if (CxNet::IsServer) {
|
||||
SSendAddResourceMsg sSendAddResourceMsg = SSendAddResourceMsg();
|
||||
sSendAddResourceMsg.Guid = this->owner->PlayerData->GUID;
|
||||
sSendAddResourceMsg.Type = (int)(type);
|
||||
sSendAddResourceMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToAllClients(0);
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::SSendClear()
|
||||
{
|
||||
if (CxNet::IsServer) {
|
||||
SSendClearMsg sSendClearMsg = SSendClearMsg();
|
||||
sSendClearMsg.Guid = this->owner->PlayerData->GUID;
|
||||
sSendClearMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToAllClients(0);
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::CReceiveRageSend(int current)
|
||||
{
|
||||
for (int i = 0; i < this->cResources->Count; i += 1) {
|
||||
PlayerResource* playerResource = this->cResources->GetData(i);
|
||||
if (is_inst_of<RageResource*>(playerResource)) {
|
||||
as_cast<RageResource*>(playerResource)->Current = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::CReceiveAddResource(PlayerResourceTypes type)
|
||||
{
|
||||
if ((type == PlayerResourceTypes::Rage) && !this->CHasPlayerResource<RageResource>()) {
|
||||
this->cResources->Add(new RageResource());
|
||||
if (this->COnResourcesChanged != null) {
|
||||
DELEGATE_INVOKE(this->COnResourcesChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
void PlayerResourceComponent::CReceiveClear()
|
||||
{
|
||||
this->init = true;
|
||||
bool flag = false;
|
||||
if (this->cResources->Count > 0) {
|
||||
flag = true;
|
||||
}
|
||||
this->cResources->Clear();
|
||||
if (flag && (this->COnResourcesChanged != null)) {
|
||||
DELEGATE_INVOKE(this->COnResourcesChanged);
|
||||
}
|
||||
}
|
||||
PlayerResource* PlayerResourceComponent::SGetPlayerResource(PlayerResourceTypes type)
|
||||
{
|
||||
for (int i = 0; i < this->sResources->Count; i += 1) {
|
||||
PlayerResource* playerResource = this->sResources->GetData(i);
|
||||
if ((type == PlayerResourceTypes::Rage) && is_inst_of<RageResource*>(playerResource)) {
|
||||
return playerResource;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PlayerResource* PlayerResourceComponent::CGetPlayerResource(PlayerResourceTypes type)
|
||||
{
|
||||
for (int i = 0; i < this->cResources->Count; i += 1) {
|
||||
PlayerResource* playerResource = this->cResources->GetData(i);
|
||||
if ((type == PlayerResourceTypes::Rage) && is_inst_of<RageResource*>(playerResource)) {
|
||||
return playerResource;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
T* PlayerResourceComponent::SGetPlayerResource<T>()
|
||||
{
|
||||
for (int i = 0; i < this->sResources->Count; i += 1) {
|
||||
PlayerResource* playerResource = this->sResources->GetData(i);
|
||||
if (is_inst_of<T*>(playerResource)) {
|
||||
return UNBOX<T*>(as_cast<T*>(playerResource));
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
T* PlayerResourceComponent::CGetPlayerResource<T>()
|
||||
{
|
||||
for (int i = 0; i < this->cResources->Count; i += 1) {
|
||||
PlayerResource* playerResource = this->cResources->GetData(i);
|
||||
if (is_inst_of<T*>(playerResource)) {
|
||||
return UNBOX<T*>(as_cast<T*>(playerResource));
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
bool PlayerResourceComponent::SHasPlayerResource<T>()
|
||||
{
|
||||
for (int i = 0; i < this->sResources->Count; i += 1) {
|
||||
if (is_inst_of<T*>(this->sResources->GetData(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool PlayerResourceComponent::CHasPlayerResource<T>()
|
||||
{
|
||||
for (int i = 0; i < this->cResources->Count; i += 1) {
|
||||
if (is_inst_of<T*>(this->cResources->GetData(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void PlayerResourceComponent::ToJSON(JsonWriter* w)
|
||||
{
|
||||
w->WritePropertyName(new String("PlayerResourceComponent"));
|
||||
w->WriteStartObject();
|
||||
List_T<PlayerResource>* list = this->getSResources();
|
||||
for (int i = 0; i < list->Count; i += 1) {
|
||||
PlayerResource* playerResource = list->GetData(i);
|
||||
if (is_inst_of<RageResource*>(playerResource)) {
|
||||
RageResource::ToJSON(as_cast<RageResource*>(playerResource), w);
|
||||
}
|
||||
}
|
||||
w->WriteEndObject();
|
||||
}
|
||||
void PlayerResourceComponent::FromJSON(JsonReader* r)
|
||||
{
|
||||
while (r->Read()) {
|
||||
if (r->TokenType == JsonToken::PropertyName) {
|
||||
String* a = (String*)(r->Value);
|
||||
if (*a == *(new String("RageResource"))) {
|
||||
RageResource::FromJSON((RageResource*)(this->SAddResource(PlayerResourceTypes::Rage)), r);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r->TokenType == JsonToken::EndObject) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include <System/Delegate.h>
|
||||
#include "WorldEntity.h"
|
||||
#include "PlayerResource.h"
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include "CharacterResourceData.h"
|
||||
#include "Interlocked.h"
|
||||
#include "PlayerData.h"
|
||||
#include "RageResource.h"
|
||||
#include "PlayerResourceTypes.h"
|
||||
#include "CxNet.h"
|
||||
#include "SSendRageMsg.h"
|
||||
#include "SSendAddResourceMsg.h"
|
||||
#include "SSendClearMsg.h"
|
||||
#include "JsonWriter.h"
|
||||
#include "JsonReader.h"
|
||||
#include "JsonToken.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace UnityEngine;
|
||||
using namespace System::Threading;
|
||||
using namespace CxNetworking;
|
||||
using namespace BS::Networking;
|
||||
using namespace Newtonsoft::Json;
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
//Forward Declaration
|
||||
class WorldEntity;
|
||||
|
||||
//Attribute: Serializable*
|
||||
class PlayerResourceComponent : public virtual Object{
|
||||
public:
|
||||
DELEGATE(void) COnResourcesChangedAction;
|
||||
private:
|
||||
WorldEntity* owner;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
List_T<PlayerResource>* sResources;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
List_T<PlayerResource>* cResources;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
CharacterResourceData* characterResourceData;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
bool init;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
bool loaded;
|
||||
public:
|
||||
void addCOnResourcesChanged(PlayerResourceComponent::COnResourcesChangedAction* value);
|
||||
public:
|
||||
void removeCOnResourcesChanged(PlayerResourceComponent::COnResourcesChangedAction* value);
|
||||
public:
|
||||
List_T<PlayerResource>* getSResources();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
List_T<PlayerResource>* getCResources();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
bool getFinished();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
bool getLoaded();
|
||||
public:
|
||||
void setLoaded(bool value);
|
||||
public:
|
||||
PlayerResourceComponent(WorldEntity* owner);
|
||||
public:
|
||||
void Init();
|
||||
public:
|
||||
void LateUpdate();
|
||||
public:
|
||||
void SClear();
|
||||
public:
|
||||
PlayerResource* SAddResource(PlayerResourceTypes type);
|
||||
public:
|
||||
void SSendRage(int current);
|
||||
public:
|
||||
void SSendAddResource(PlayerResourceTypes type);
|
||||
public:
|
||||
void SSendClear();
|
||||
public:
|
||||
void CReceiveRageSend(int current);
|
||||
public:
|
||||
void CReceiveAddResource(PlayerResourceTypes type);
|
||||
public:
|
||||
void CReceiveClear();
|
||||
public:
|
||||
PlayerResource* SGetPlayerResource(PlayerResourceTypes type);
|
||||
public:
|
||||
PlayerResource* CGetPlayerResource(PlayerResourceTypes type);
|
||||
public:
|
||||
T* SGetPlayerResource<T>();
|
||||
public:
|
||||
T* CGetPlayerResource<T>();
|
||||
public:
|
||||
bool SHasPlayerResource<T>();
|
||||
public:
|
||||
bool CHasPlayerResource<T>();
|
||||
public:
|
||||
void ToJSON(JsonWriter* w);
|
||||
public:
|
||||
void FromJSON(JsonReader* r);
|
||||
};
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
#include "RageResource.h"
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
int RageResource::getCurrent(){
|
||||
return this->current;
|
||||
}
|
||||
void RageResource::setCurrent(int value)
|
||||
{
|
||||
if (value > this->max) {
|
||||
value = this->max;
|
||||
}
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
PlayerResource::setDirty(true);
|
||||
this->current = value;
|
||||
}
|
||||
int RageResource::getMax()
|
||||
{
|
||||
return this->max;
|
||||
}
|
||||
void RageResource::setMax(int value)
|
||||
{
|
||||
PlayerResource::setDirty(true);
|
||||
this->max = value;
|
||||
}
|
||||
RageResource::RageResource()
|
||||
{
|
||||
this->current = 0;
|
||||
this->max = 100;
|
||||
}
|
||||
void RageResource::ToJSON(RageResource* rr, JsonWriter* w)
|
||||
{
|
||||
w->WritePropertyName(new String("RageResource"));
|
||||
w->WriteStartObject();
|
||||
w->WritePropertyName(new String("Current"));
|
||||
w->WriteValue(rr->getCurrent());
|
||||
w->WritePropertyName(new String("Max"));
|
||||
w->WriteValue(rr->getMax());
|
||||
w->WriteEndObject();
|
||||
}
|
||||
void RageResource::FromJSON(RageResource* rr, JsonReader* r)
|
||||
{
|
||||
while (r->Read()) {
|
||||
if (r->TokenType == JsonToken::PropertyName) {
|
||||
String* a = (String*)(r->Value);
|
||||
if (!*a == *(new String("Current"))) {
|
||||
if (*a == *(new String("Max"))) {
|
||||
rr->setMax(r->ReadAsInt32()->Value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rr->setCurrent(r->ReadAsInt32()->Value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r->TokenType == JsonToken::EndObject) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include "PlayerResource.h"
|
||||
#include "JsonWriter.h"
|
||||
#include "JsonReader.h"
|
||||
#include "JsonToken.h"
|
||||
|
||||
using namespace Newtonsoft::Json;
|
||||
using namespace System;
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
class RageResource : public virtual PlayerResource, public virtual Object
|
||||
{
|
||||
private:
|
||||
int current;
|
||||
private:
|
||||
int max;
|
||||
public:
|
||||
virtual int getCurrent();
|
||||
public:
|
||||
virtual void setCurrent(int value);
|
||||
public:
|
||||
virtual int getMax();
|
||||
public:
|
||||
virtual void setMax(int value);
|
||||
public:
|
||||
RageResource();
|
||||
public:
|
||||
static void ToJSON(RageResource* rr, JsonWriter* w);
|
||||
public:
|
||||
static void FromJSON(RageResource* rr, JsonReader* r);
|
||||
};
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#include "SimpleCharacterEffectPointGetter.h"
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
Transform* SimpleCharacterEffectPointGetter::GetEffectPoint(EffectPoints bodyPartEffectPoint){
|
||||
return MonoBehaviour::transform;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include "MonoBehaviour.h"
|
||||
#include "IEffectPointGetter.h"
|
||||
#include "EffectPoints.h"
|
||||
#include "Transform.h"
|
||||
|
||||
using namespace UnityEngine;
|
||||
using namespace System;
|
||||
namespace BS {
|
||||
namespace Player {
|
||||
class SimpleCharacterEffectPointGetter : public virtual MonoBehaviour, public virtual IEffectPointGetter, public virtual Object
|
||||
{
|
||||
public:
|
||||
Transform* GetEffectPoint(EffectPoints bodyPartEffectPoint);
|
||||
};
|
||||
}
|
||||
}
|
@ -1,221 +0,0 @@
|
||||
#include "SpellMgrComponent.h"
|
||||
SpellMgrComponent::SpellMgrComponent(WorldEntity* owner){
|
||||
this->owner = owner;
|
||||
}
|
||||
void SpellMgrComponent::Init()
|
||||
{
|
||||
if (this->init) {
|
||||
return;
|
||||
}
|
||||
this->init = true;
|
||||
Character* character = this->owner->PlayerData->Character;
|
||||
if (this->owner->PlayerData->Type != 3) {
|
||||
this->spellIds = character->Spells;
|
||||
}
|
||||
this->dataPresent = true;
|
||||
this->itemDataLoader = ItemDataLoader::Instance;
|
||||
}
|
||||
void SpellMgrComponent::OnLevelLoaded()
|
||||
{
|
||||
}
|
||||
void SpellMgrComponent::CSendCastSpellRequest(int spellId)
|
||||
{
|
||||
if (!this->owner->isLocalPlayer) {
|
||||
return;
|
||||
}
|
||||
if (Spells::Instance->GetData(spellId)->GetComponent<Spell>()->IsLocalSpell) {
|
||||
SpellMgr::CastSpell(this->owner, spellId, (float)1);
|
||||
return;
|
||||
}
|
||||
if (this->owner->PlayerData->State != PlayerStates::STATE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
if (this->owner->Stats->CIsDead) {
|
||||
return;
|
||||
}
|
||||
if (!this->dataPresent) {
|
||||
this->CSendCastSpell(spellId);
|
||||
return;
|
||||
}
|
||||
if (!this->PlayerKnowsSpell(spellId)) {
|
||||
return;
|
||||
}
|
||||
this->CSendCastSpell(spellId);
|
||||
}
|
||||
void SpellMgrComponent::CSendCastItemSpellRequest(ItemData* itemData)
|
||||
{
|
||||
if (!this->owner->isLocalPlayer) {
|
||||
return;
|
||||
}
|
||||
int spellId = itemData->SpellId;
|
||||
if (Spells::Instance->GetData(spellId)->GetComponent<Spell>()->IsLocalSpell) {
|
||||
SpellMgr::CastSpell(this->owner, spellId, (float)1);
|
||||
return;
|
||||
}
|
||||
if (this->owner->PlayerData->State != PlayerStates::STATE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
if (this->owner->Stats->CIsDead) {
|
||||
return;
|
||||
}
|
||||
if (!this->dataPresent) {
|
||||
this->CSendCastItemSpell(itemData->Id);
|
||||
return;
|
||||
}
|
||||
if (!this->owner->Inventory->CHasItem(itemData->Id, 1)) {
|
||||
return;
|
||||
}
|
||||
this->CSendCastItemSpell(itemData->Id);
|
||||
}
|
||||
void SpellMgrComponent::CSendCastSpell(int spellId)
|
||||
{
|
||||
if (CxNet::IsClient) {
|
||||
SSpellCastRequestMsg sSpellCastRequestMsg = SSpellCastRequestMsg();
|
||||
sSpellCastRequestMsg.SpellId = spellId;
|
||||
sSpellCastRequestMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToServer(0);
|
||||
}
|
||||
}
|
||||
void SpellMgrComponent::CSendCastItemSpell(int itemId)
|
||||
{
|
||||
if (CxNet::IsClient) {
|
||||
SItemSpellCastRequestMsg sItemSpellCastRequestMsg = SItemSpellCastRequestMsg();
|
||||
sItemSpellCastRequestMsg.ItemId = itemId;
|
||||
sItemSpellCastRequestMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToServer(0);
|
||||
}
|
||||
}
|
||||
void SpellMgrComponent::SSendSpellCastSuccess(int spellId)
|
||||
{
|
||||
if (CxNet::IsServer) {
|
||||
CSpellCastEventSuccessMsg cSpellCastEventSuccessMsg = CSpellCastEventSuccessMsg();
|
||||
cSpellCastEventSuccessMsg.Guid = this->owner->PlayerData->GUID;
|
||||
cSpellCastEventSuccessMsg.SpellId = spellId;
|
||||
cSpellCastEventSuccessMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToAllClients(0);
|
||||
}
|
||||
}
|
||||
void SpellMgrComponent::SSendSpellCastFailed(int spellId)
|
||||
{
|
||||
if (CxNet::IsServer) {
|
||||
CSpellCastEventFailedMsg cSpellCastEventFailedMsg = CSpellCastEventFailedMsg();
|
||||
cSpellCastEventFailedMsg.Guid = this->owner->PlayerData->GUID;
|
||||
cSpellCastEventFailedMsg.SpellId = spellId;
|
||||
cSpellCastEventFailedMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToAllClients(0);
|
||||
}
|
||||
}
|
||||
void SpellMgrComponent::CReceiveSpellCastSuccess(int spellId)
|
||||
{
|
||||
if (!Spells::Instance->SpellsDict->ContainsKey(spellId)) {
|
||||
return;
|
||||
}
|
||||
SpellMgr::COnSpellCastSuccess(this->owner, spellId);
|
||||
}
|
||||
void SpellMgrComponent::CReceiveSpellSpellCastFailed(int spellId)
|
||||
{
|
||||
if (!Spells::Instance->SpellsDict->ContainsKey(spellId)) {
|
||||
return;
|
||||
}
|
||||
DELEGATE_INVOKE(SpellMgr::COnCastFailed, this->owner, spellId);
|
||||
}
|
||||
void SpellMgrComponent::SReceiveCastSpellRequest(int spellId)
|
||||
{
|
||||
if (this->owner->PlayerData->State != PlayerStates::STATE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
if (!this->owner->isServer || this->owner->Stats->sIsDead) {
|
||||
return;
|
||||
}
|
||||
if (!this->PlayerKnowsSpell(spellId)) {
|
||||
return;
|
||||
}
|
||||
if (this->owner->isLocalPlayer) {
|
||||
if (this->lastLevel != this->owner->PlayerData->Level) {
|
||||
this->lastLevel = this->owner->PlayerData->Level;
|
||||
BrokenSeals::BSDebugSettings->SpellScale = this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level));
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, BrokenSeals::BSDebugSettings->SpellScale);
|
||||
return;
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level)));
|
||||
}
|
||||
void SpellMgrComponent::SReceiveCastItemSpellRequest(int itemId)
|
||||
{
|
||||
if (this->owner->PlayerData->State != PlayerStates::STATE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
if (!this->owner->isServer || this->owner->Stats->sIsDead) {
|
||||
return;
|
||||
}
|
||||
if (!this->itemDataLoader->data->ContainsKey(itemId)) {
|
||||
return;
|
||||
}
|
||||
ItemData* component = this->itemDataLoader->data->GetData(itemId)->GetComponent<ItemData>();
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
int spellId = component->SpellId;
|
||||
if (spellId == 0) {
|
||||
return;
|
||||
}
|
||||
if (!this->owner->Inventory->SHasItem(itemId, 1)) {
|
||||
return;
|
||||
}
|
||||
if (this->owner->isLocalPlayer) {
|
||||
if (this->lastLevel != this->owner->PlayerData->Level) {
|
||||
this->lastLevel = this->owner->PlayerData->Level;
|
||||
BrokenSeals::BSDebugSettings->SpellScale = this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level));
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, BrokenSeals::BSDebugSettings->SpellScale);
|
||||
return;
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level)));
|
||||
}
|
||||
void SpellMgrComponent::SCastSpell(int spellId)
|
||||
{
|
||||
if (this->owner->PlayerData->State != PlayerStates::STATE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
if (!this->owner->isServer || this->owner->Stats->sIsDead) {
|
||||
return;
|
||||
}
|
||||
if (!this->PlayerKnowsSpell(spellId)) {
|
||||
return;
|
||||
}
|
||||
if (this->owner->isLocalPlayer) {
|
||||
if (this->lastLevel != this->owner->PlayerData->Level) {
|
||||
this->lastLevel = this->owner->PlayerData->Level;
|
||||
BrokenSeals::BSDebugSettings->SpellScale = this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level));
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, BrokenSeals::BSDebugSettings->SpellScale);
|
||||
return;
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level)));
|
||||
}
|
||||
void SpellMgrComponent::AICastSpell(int spellId)
|
||||
{
|
||||
if (this->owner->PlayerData->State != PlayerStates::STATE_NORMAL) {
|
||||
return;
|
||||
}
|
||||
if (!this->owner->isServer || this->owner->Stats->sIsDead) {
|
||||
return;
|
||||
}
|
||||
SpellMgr::CastSpell(this->owner, spellId, this->owner->PlayerData->Character->Stats->SpellScaling->Evaluate((float)(this->owner->PlayerData->Level)));
|
||||
}
|
||||
bool SpellMgrComponent::PlayerKnowsSpell(int spellID)
|
||||
{
|
||||
bool flag = false;
|
||||
for (int i = 0; i < this->spellIds->SpellIds->Count; i += 1) {
|
||||
if (this->spellIds->SpellIds->GetData(i) == spellID) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool flag2 = true;
|
||||
if ((flag && (this->owner->PlayerData != null)) && (Spells::Instance->GetData(spellID)->gameObject->GetComponent<Spell>()->Level > this->owner->PlayerData->Level)) {
|
||||
flag2 = false;
|
||||
}
|
||||
return flag & flag2;
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include "CharacterSpells.h"
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include "ItemDataLoader.h"
|
||||
#include "WorldEntity.h"
|
||||
#include "Character.h"
|
||||
#include "Spells.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "PlayerStates.h"
|
||||
#include "ItemData.h"
|
||||
#include "CxNet.h"
|
||||
#include "SSpellCastRequestMsg.h"
|
||||
#include "SItemSpellCastRequestMsg.h"
|
||||
#include "CSpellCastEventSuccessMsg.h"
|
||||
#include "CSpellCastEventFailedMsg.h"
|
||||
#include "BrokenSeals.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace UnityEngine;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace BS::Data::Items;
|
||||
using namespace BS::Player;
|
||||
using namespace CxNetworking;
|
||||
using namespace BS::Networking;
|
||||
//Forward Declaration
|
||||
class WorldEntity;
|
||||
|
||||
//Attribute: Serializable*
|
||||
class SpellMgrComponent : public virtual Object{
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
CharacterSpells* spellIds;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
List_T<int>* mobSpellIds;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
ItemDataLoader* itemDataLoader;
|
||||
private:
|
||||
bool init;
|
||||
private:
|
||||
bool eventAdded;
|
||||
private:
|
||||
int lastLevel;
|
||||
private:
|
||||
bool dataPresent;
|
||||
private:
|
||||
WorldEntity* owner;
|
||||
public:
|
||||
SpellMgrComponent(WorldEntity* owner);
|
||||
public:
|
||||
void Init();
|
||||
private:
|
||||
void OnLevelLoaded();
|
||||
public:
|
||||
void CSendCastSpellRequest(int spellId);
|
||||
public:
|
||||
void CSendCastItemSpellRequest(ItemData* itemData);
|
||||
private:
|
||||
void CSendCastSpell(int spellId);
|
||||
private:
|
||||
void CSendCastItemSpell(int itemId);
|
||||
public:
|
||||
void SSendSpellCastSuccess(int spellId);
|
||||
public:
|
||||
void SSendSpellCastFailed(int spellId);
|
||||
public:
|
||||
void CReceiveSpellCastSuccess(int spellId);
|
||||
public:
|
||||
void CReceiveSpellSpellCastFailed(int spellId);
|
||||
public:
|
||||
void SReceiveCastSpellRequest(int spellId);
|
||||
public:
|
||||
void SReceiveCastItemSpellRequest(int itemId);
|
||||
public:
|
||||
void SCastSpell(int spellId);
|
||||
public:
|
||||
void AICastSpell(int spellId);
|
||||
public:
|
||||
bool PlayerKnowsSpell(int spellID);
|
||||
};
|
@ -1,236 +0,0 @@
|
||||
#include "StateComponent.h"
|
||||
//Delegate declaration moved to header file
|
||||
//Delegate declaration moved to header file
|
||||
void StateComponent::addsOnStateChanged(StateComponent::SOnStateChangedAction* value){
|
||||
StateComponent::SOnStateChangedAction* sOnStateChangedAction = this->sOnStateChanged;
|
||||
StateComponent::SOnStateChangedAction* sOnStateChangedAction2;
|
||||
do{
|
||||
sOnStateChangedAction2 = sOnStateChangedAction;
|
||||
StateComponent::SOnStateChangedAction* value2 = (StateComponent::SOnStateChangedAction*)(Delegate::Combine(sOnStateChangedAction2, value));
|
||||
sOnStateChangedAction = Interlocked::CompareExchange<StateComponent::SOnStateChangedAction*>(this->sOnStateChanged, value2, sOnStateChangedAction2);
|
||||
}
|
||||
while (*sOnStateChangedAction != *sOnStateChangedAction2);
|
||||
}
|
||||
void StateComponent::removesOnStateChanged(StateComponent::SOnStateChangedAction* value)
|
||||
{
|
||||
StateComponent::SOnStateChangedAction* sOnStateChangedAction = this->sOnStateChanged;
|
||||
StateComponent::SOnStateChangedAction* sOnStateChangedAction2;
|
||||
do {
|
||||
sOnStateChangedAction2 = sOnStateChangedAction;
|
||||
StateComponent::SOnStateChangedAction* value2 = (StateComponent::SOnStateChangedAction*)(Delegate::Remove(sOnStateChangedAction2, value));
|
||||
sOnStateChangedAction = Interlocked::CompareExchange<StateComponent::SOnStateChangedAction*>(this->sOnStateChanged, value2, sOnStateChangedAction2);
|
||||
}
|
||||
while (*sOnStateChangedAction != *sOnStateChangedAction2);
|
||||
}
|
||||
|
||||
void StateComponent::addCOnStateChanged(StateComponent::COnStateChangedAction* value)
|
||||
{
|
||||
StateComponent::COnStateChangedAction* cOnStateChangedAction = this->COnStateChanged;
|
||||
StateComponent::COnStateChangedAction* cOnStateChangedAction2;
|
||||
do {
|
||||
cOnStateChangedAction2 = cOnStateChangedAction;
|
||||
StateComponent::COnStateChangedAction* value2 = (StateComponent::COnStateChangedAction*)(Delegate::Combine(cOnStateChangedAction2, value));
|
||||
cOnStateChangedAction = Interlocked::CompareExchange<StateComponent::COnStateChangedAction*>(this->COnStateChanged, value2, cOnStateChangedAction2);
|
||||
}
|
||||
while (*cOnStateChangedAction != *cOnStateChangedAction2);
|
||||
}
|
||||
void StateComponent::removeCOnStateChanged(StateComponent::COnStateChangedAction* value)
|
||||
{
|
||||
StateComponent::COnStateChangedAction* cOnStateChangedAction = this->COnStateChanged;
|
||||
StateComponent::COnStateChangedAction* cOnStateChangedAction2;
|
||||
do {
|
||||
cOnStateChangedAction2 = cOnStateChangedAction;
|
||||
StateComponent::COnStateChangedAction* value2 = (StateComponent::COnStateChangedAction*)(Delegate::Remove(cOnStateChangedAction2, value));
|
||||
cOnStateChangedAction = Interlocked::CompareExchange<StateComponent::COnStateChangedAction*>(this->COnStateChanged, value2, cOnStateChangedAction2);
|
||||
}
|
||||
while (*cOnStateChangedAction != *cOnStateChangedAction2);
|
||||
}
|
||||
|
||||
bool StateComponent::getSend()
|
||||
{
|
||||
return this->send;
|
||||
}
|
||||
void StateComponent::setSend(bool value)
|
||||
{
|
||||
this->send = value;
|
||||
}
|
||||
List_T<StateData>* StateComponent::getActiveStates()
|
||||
{
|
||||
return this->activeStates;
|
||||
}
|
||||
int StateComponent::getSStateFlags()
|
||||
{
|
||||
return this->sStateFlags;
|
||||
}
|
||||
void StateComponent::setSStateFlags(int value)
|
||||
{
|
||||
this->sStateFlags = value;
|
||||
}
|
||||
int StateComponent::getCStateFlags()
|
||||
{
|
||||
return this->cStateFlags;
|
||||
}
|
||||
StateComponent::StateComponent(WorldEntity* owner)
|
||||
{
|
||||
activeStates = new List_T<StateData>();
|
||||
this->owner = owner;
|
||||
}
|
||||
void StateComponent::Update()
|
||||
{
|
||||
if (this->send) {
|
||||
this->send = false;
|
||||
this->SSendSendFlags(this->sStateFlags);
|
||||
}
|
||||
}
|
||||
void StateComponent::AddState(int auraId, StateData::StateType type)
|
||||
{
|
||||
if (!CxNet::IsServer) {
|
||||
return;
|
||||
}
|
||||
StateData* state = new StateData(type, auraId);
|
||||
this->AddState(state);
|
||||
int arg_29_0 = this->sStateFlags;
|
||||
this->RecalculateFlags();
|
||||
if (arg_29_0 != this->sStateFlags) {
|
||||
if (this->sOnStateChanged != null) {
|
||||
DELEGATE_INVOKE(this->sOnStateChanged);
|
||||
}
|
||||
this->SSendSendFlags(this->sStateFlags);
|
||||
}
|
||||
}
|
||||
bool StateComponent::SHasState(StateData::StateType state)
|
||||
{
|
||||
return (this->sStateFlags & (int)(state)) == (int)(state);
|
||||
}
|
||||
bool StateComponent::CHasState(StateData::StateType state)
|
||||
{
|
||||
return (this->cStateFlags & (int)(state)) == (int)(state);
|
||||
}
|
||||
void StateComponent::AddState(StateData* state)
|
||||
{
|
||||
if (!CxNet::IsServer) {
|
||||
return;
|
||||
}
|
||||
this->activeStates->Add(state);
|
||||
int arg_26_0 = this->sStateFlags;
|
||||
this->RecalculateFlags();
|
||||
if (arg_26_0 != this->sStateFlags) {
|
||||
if (this->sOnStateChanged != null) {
|
||||
DELEGATE_INVOKE(this->sOnStateChanged);
|
||||
}
|
||||
this->SSendSendFlags(this->sStateFlags);
|
||||
}
|
||||
}
|
||||
void StateComponent::RemoveStateWithAuraId(int auraId)
|
||||
{
|
||||
for (int i = 0; i < this->activeStates->Count; i += 1) {
|
||||
if (this->activeStates->GetData(i)->AuraId == auraId) {
|
||||
this->activeStates->RemoveAt(i);
|
||||
int arg_36_0 = this->sStateFlags;
|
||||
this->RecalculateFlags();
|
||||
if (arg_36_0 != this->sStateFlags) {
|
||||
if (this->sOnStateChanged != null) {
|
||||
DELEGATE_INVOKE(this->sOnStateChanged);
|
||||
}
|
||||
this->SSendSendFlags(this->sStateFlags);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void StateComponent::RemoveStateWithAuraId(int auraId, StateData::StateType type)
|
||||
{
|
||||
for (int i = 0; i < this->activeStates->Count; i += 1) {
|
||||
if ((this->activeStates->GetData(i)->AuraId == auraId) && (this->activeStates->GetData(i)->Type == type)) {
|
||||
this->activeStates->RemoveAt(i);
|
||||
int arg_4A_0 = this->sStateFlags;
|
||||
this->RecalculateFlags();
|
||||
if (arg_4A_0 != this->sStateFlags) {
|
||||
if (this->sOnStateChanged != null) {
|
||||
DELEGATE_INVOKE(this->sOnStateChanged);
|
||||
}
|
||||
this->SSendSendFlags(this->sStateFlags);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void StateComponent::RecalculateFlags()
|
||||
{
|
||||
this->sStateFlags = 0;
|
||||
for (int i = 0; i < this->activeStates->Count; i += 1) {
|
||||
this->sStateFlags = this->sStateFlags | (int)(this->activeStates->GetData(i)->Type);
|
||||
}
|
||||
}
|
||||
void StateComponent::SSendSendFlags(int flags)
|
||||
{
|
||||
if (CxNet::IsServer) {
|
||||
SSendStateFlagsMsg sSendStateFlagsMsg = SSendStateFlagsMsg();
|
||||
sSendStateFlagsMsg.Guid = this->owner->PlayerData->GUID;
|
||||
sSendStateFlagsMsg.Flags = flags;
|
||||
sSendStateFlagsMsg.Serialize(CxNet::NetBuffer);
|
||||
CxNet::SendBufferToAllClients(0);
|
||||
}
|
||||
}
|
||||
void StateComponent::CReceiveSendFlags(int flags)
|
||||
{
|
||||
this->cStateFlags = flags;
|
||||
if (this->COnStateChanged != null) {
|
||||
DELEGATE_INVOKE(this->COnStateChanged);
|
||||
}
|
||||
}
|
||||
void StateComponent::ToJSON(JsonWriter* w)
|
||||
{
|
||||
w->WritePropertyName(new String("StateComponent"));
|
||||
w->WriteStartObject();
|
||||
w->WritePropertyName(new String("SStateFlags"));
|
||||
w->WriteValue(this->getSStateFlags());
|
||||
w->WritePropertyName(new String("States"));
|
||||
w->WriteStartObject();
|
||||
for (int i = 0; i < this->getActiveStates()->Count; i += 1) {
|
||||
StateData::ToJSON(this->getActiveStates()->GetData(i), w);
|
||||
}
|
||||
w->WriteEndObject();
|
||||
w->WriteEndObject();
|
||||
}
|
||||
void StateComponent::FromJSON(JsonReader* r)
|
||||
{
|
||||
while (r->Read()) {
|
||||
if (r->TokenType == JsonToken::PropertyName) {
|
||||
String* a = (String*)(r->Value);
|
||||
if (!*a == *(new String("SStateFlags"))) {
|
||||
if (*a == *(new String("States"))) {
|
||||
this->StatesFromJSON(r);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this->setSStateFlags(r->ReadAsInt32()->Value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r->TokenType == JsonToken::EndObject) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void StateComponent::StatesFromJSON(JsonReader* r)
|
||||
{
|
||||
while (r->Read()) {
|
||||
if (r->TokenType == JsonToken::PropertyName) {
|
||||
String* a = (String*)(r->Value);
|
||||
if (*a == *(new String("StateData"))) {
|
||||
StateData* stateData = new StateData();
|
||||
StateData::FromJSON(stateData, r);
|
||||
this->getActiveStates()->Add(stateData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r->TokenType == JsonToken::EndObject) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this->setSend(true);
|
||||
}
|
||||
|
@ -1,95 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include <System/Delegate.h>
|
||||
#include "StateData.h"
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include "WorldEntity.h"
|
||||
#include "Interlocked.h"
|
||||
#include "CxNet.h"
|
||||
#include "SSendStateFlagsMsg.h"
|
||||
#include "JsonWriter.h"
|
||||
#include "JsonReader.h"
|
||||
#include "JsonToken.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace UnityEngine;
|
||||
using namespace BS::Player;
|
||||
using namespace System::Threading;
|
||||
using namespace CxNetworking;
|
||||
using namespace BS::Networking;
|
||||
using namespace Newtonsoft::Json;
|
||||
//Forward Declaration
|
||||
class WorldEntity;
|
||||
|
||||
//Attribute: Serializable*
|
||||
class StateComponent : public virtual Object{
|
||||
public:
|
||||
DELEGATE(void) SOnStateChangedAction;
|
||||
public:
|
||||
DELEGATE(void) COnStateChangedAction;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
List_T<StateData>* activeStates;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
int sStateFlags;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
int cStateFlags;
|
||||
//Attribute: SerializeField*
|
||||
private:
|
||||
bool send;
|
||||
private:
|
||||
WorldEntity* owner;
|
||||
public:
|
||||
void addsOnStateChanged(StateComponent::SOnStateChangedAction* value);
|
||||
public:
|
||||
void removesOnStateChanged(StateComponent::SOnStateChangedAction* value);
|
||||
public:
|
||||
void addCOnStateChanged(StateComponent::COnStateChangedAction* value);
|
||||
public:
|
||||
void removeCOnStateChanged(StateComponent::COnStateChangedAction* value);
|
||||
public:
|
||||
bool getSend();
|
||||
public:
|
||||
void setSend(bool value);
|
||||
public:
|
||||
List_T<StateData>* getActiveStates();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
int getSStateFlags();
|
||||
public:
|
||||
void setSStateFlags(int value);
|
||||
public:
|
||||
int getCStateFlags();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
StateComponent(WorldEntity* owner);
|
||||
public:
|
||||
void Update();
|
||||
public:
|
||||
void AddState(int auraId, StateData::StateType type);
|
||||
public:
|
||||
bool SHasState(StateData::StateType state);
|
||||
public:
|
||||
bool CHasState(StateData::StateType state);
|
||||
public:
|
||||
void AddState(StateData* state);
|
||||
public:
|
||||
void RemoveStateWithAuraId(int auraId);
|
||||
public:
|
||||
void RemoveStateWithAuraId(int auraId, StateData::StateType type);
|
||||
public:
|
||||
void RecalculateFlags();
|
||||
public:
|
||||
void SSendSendFlags(int flags);
|
||||
public:
|
||||
void CReceiveSendFlags(int flags);
|
||||
public:
|
||||
void ToJSON(JsonWriter* w);
|
||||
public:
|
||||
void FromJSON(JsonReader* r);
|
||||
public:
|
||||
void StatesFromJSON(JsonReader* r);
|
||||
};
|
@ -1,48 +0,0 @@
|
||||
#include "StateData.h"
|
||||
StateData::StateType StateData::getType(){
|
||||
return this->type;
|
||||
}
|
||||
int StateData::getAuraId()
|
||||
{
|
||||
return this->auraId;
|
||||
}
|
||||
StateData::StateData()
|
||||
{
|
||||
}
|
||||
StateData::StateData(StateData::StateType type, int auraId)
|
||||
{
|
||||
this->auraId = auraId;
|
||||
this->type = type;
|
||||
}
|
||||
void StateData::ToJSON(StateData* sd, JsonWriter* w)
|
||||
{
|
||||
w->WritePropertyName(new String("StateData"));
|
||||
w->WriteStartObject();
|
||||
w->WritePropertyName(new String("Type"));
|
||||
w->WriteValue((int)(sd->getType()));
|
||||
w->WritePropertyName(new String("AuraId"));
|
||||
w->WriteValue(sd->getAuraId());
|
||||
w->WriteEndObject();
|
||||
}
|
||||
void StateData::FromJSON(StateData* sd, JsonReader* r)
|
||||
{
|
||||
while (r->Read()) {
|
||||
if (r->TokenType == JsonToken::PropertyName) {
|
||||
String* a = (String*)(r->Value);
|
||||
if (!*a == *(new String("Type"))) {
|
||||
if (*a == *(new String("AuraId"))) {
|
||||
sd->auraId = r->ReadAsInt32()->Value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sd->type = (StateData::StateType)(r->ReadAsInt32()->Value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r->TokenType == JsonToken::EndObject) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
#include <System/System.h>
|
||||
#include "JsonWriter.h"
|
||||
#include "JsonReader.h"
|
||||
#include "JsonToken.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace Newtonsoft::Json;
|
||||
class StateData : public virtual Object
|
||||
{
|
||||
public:
|
||||
enum class StateType
|
||||
{
|
||||
TYPE_NONE,
|
||||
TYPE_STUN,
|
||||
TYPE_ROOT,
|
||||
TYPE_FROZEN = 4
|
||||
};
|
||||
private:
|
||||
StateData::StateType type;
|
||||
private:
|
||||
int auraId;
|
||||
public:
|
||||
StateData::StateType getType();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
int getAuraId();
|
||||
//Ignored empty method declaration
|
||||
public:
|
||||
StateData();
|
||||
public:
|
||||
StateData(StateData::StateType type, int auraId);
|
||||
public:
|
||||
static void ToJSON(StateData* sd, JsonWriter* w);
|
||||
public:
|
||||
static void FromJSON(StateData* sd, JsonReader* r);
|
||||
};
|
@ -37,6 +37,13 @@ void AuraData::set_aura_id(int value) {
|
||||
_aura_id = value;
|
||||
}
|
||||
|
||||
bool AuraData::get_is_timed() {
|
||||
return _is_timed;
|
||||
}
|
||||
void AuraData::set_is_timed(bool value) {
|
||||
_is_timed = value;
|
||||
}
|
||||
|
||||
float AuraData::get_remaining_time() {
|
||||
return _remaining_time;
|
||||
}
|
||||
@ -224,6 +231,10 @@ void AuraData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_aura_id", "value"), &AuraData::set_aura_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "aura_id"), "set_aura_id", "get_aura_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_timed"), &AuraData::get_is_timed);
|
||||
ClassDB::bind_method(D_METHOD("set_is_timed", "value"), &AuraData::set_is_timed);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_timed"), "set_is_timed", "get_is_timed");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_remaining_time"), &AuraData::get_remaining_time);
|
||||
ClassDB::bind_method(D_METHOD("set_remaining_time", "value"), &AuraData::set_remaining_time);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "remaining_time"), "set_remaining_time", "get_remaining_time");
|
||||
|
@ -14,6 +14,9 @@ public:
|
||||
int get_aura_id();
|
||||
void set_aura_id(int value);
|
||||
|
||||
bool get_is_timed();
|
||||
void set_is_timed(bool value);
|
||||
|
||||
float get_remaining_time();
|
||||
void set_remaining_time(float value);
|
||||
bool update_remaining_time(float delta);
|
||||
@ -77,6 +80,7 @@ private:
|
||||
int _aura_group;
|
||||
Ref<Aura> _aura;
|
||||
|
||||
bool _is_timed;
|
||||
int _damage;
|
||||
int _heal;
|
||||
float _slow;
|
||||
|
@ -260,6 +260,8 @@ Entity::Entity() {
|
||||
|
||||
get_stat_enum(Stat::STAT_ID_HEALTH)->set_base(10000);
|
||||
get_stat_enum(Stat::STAT_ID_MANA)->set_base(100);
|
||||
get_stat_enum(Stat::STAT_ID_RAGE)->set_base(100);
|
||||
get_stat_enum(Stat::STAT_ID_ENERGY)->set_base(100);
|
||||
get_stat_enum(Stat::STAT_ID_SPEED)->set_base(4.2);
|
||||
get_stat_enum(Stat::STAT_ID_GLOBAL_COOLDOWN)->set_base(1.5);
|
||||
get_stat_enum(Stat::STAT_ID_MELEE_CRIT)->set_base(5);
|
||||
@ -272,6 +274,8 @@ Entity::Entity() {
|
||||
|
||||
_health = Ref<Stat>(get_stat_enum(Stat::STAT_ID_HEALTH));
|
||||
_mana = Ref<Stat>(get_stat_enum(Stat::STAT_ID_MANA));
|
||||
_rage = Ref<Stat>(get_stat_enum(Stat::STAT_ID_RAGE));
|
||||
_energy = Ref<Stat>(get_stat_enum(Stat::STAT_ID_ENERGY));
|
||||
_speed = Ref<Stat>(get_stat_enum(Stat::STAT_ID_SPEED));
|
||||
_gcd = Ref<Stat>(get_stat_enum(Stat::STAT_ID_GLOBAL_COOLDOWN));
|
||||
|
||||
@ -418,22 +422,37 @@ void Entity::sinitialize_stats() {
|
||||
//gets_character_class()->get_stat_data()->get_stats_for_stat(_health);
|
||||
//Ref<StatDataEntry> e = gets_character_class()->get_stat_data()->get_stat_data_enum(Stat::STAT_ID_HEALTH);
|
||||
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_health());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_mana());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_speed());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_gcd());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_melee_crit());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_melee_crit_bonus());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_spell_crit());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_spell_crit_bonus());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_block());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_parry());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_melee_damage_reduction());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_spell_damage_reduction());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_damage_taken());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_heal_taken());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_melee_damage());
|
||||
gets_character_class()->get_stat_data()->get_stat_for_stat(get_spell_damage());
|
||||
Ref<CharacterClass> cc = gets_character_class();
|
||||
|
||||
ERR_FAIL_COND(!cc.is_valid());
|
||||
|
||||
cc->get_stat_data()->get_stat_for_stat(get_health());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_mana());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_rage());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_energy());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_speed());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_gcd());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_melee_crit());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_melee_crit_bonus());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_spell_crit());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_spell_crit_bonus());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_block());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_parry());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_melee_damage_reduction());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_spell_damage_reduction());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_damage_taken());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_heal_taken());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_melee_damage());
|
||||
cc->get_stat_data()->get_stat_for_stat(get_spell_damage());
|
||||
|
||||
|
||||
for (int i = 0; i < CharacterClass::MAX_AURAS; ++i) {
|
||||
Ref<Aura> a = cc->get_aura(i);
|
||||
|
||||
if (a.is_valid()) {
|
||||
a->sapply_simple(this, this, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////// Stat System //////
|
||||
@ -543,6 +562,46 @@ void Entity::set_stat_enum(Stat::StatId stat_id, Ref<Stat> entry) {
|
||||
_stats[stat_id] = Ref<Stat>(entry);
|
||||
}
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Ref<EntityResource> Entity::gets_resource(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _s_resources.size(), Ref<EntityResource>());
|
||||
|
||||
return _s_resources.get(index);
|
||||
}
|
||||
void Entity::adds_resource(Ref<EntityResource> resource) {
|
||||
ERR_FAIL_COND(!resource.is_valid());
|
||||
|
||||
_s_resources.push_back(resource);
|
||||
}
|
||||
int Entity::gets_resource_count() {
|
||||
return _s_resources.size();
|
||||
}
|
||||
void Entity::removes_resource(int index) {
|
||||
ERR_FAIL_INDEX(index, _s_resources.size());
|
||||
|
||||
_s_resources.remove(index);
|
||||
}
|
||||
|
||||
Ref<EntityResource> Entity::getc_resource(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _c_resources.size(), Ref<EntityResource>());
|
||||
|
||||
return _c_resources.get(index);
|
||||
}
|
||||
void Entity::addc_resource(Ref<EntityResource> resource) {
|
||||
ERR_FAIL_COND(!resource.is_valid());
|
||||
|
||||
_c_resources.push_back(resource);
|
||||
}
|
||||
int Entity::getc_resource_count() {
|
||||
return _c_resources.size();
|
||||
}
|
||||
void Entity::removec_resource(int index) {
|
||||
ERR_FAIL_INDEX(index, _c_resources.size());
|
||||
|
||||
_c_resources.remove(index);
|
||||
}
|
||||
|
||||
void Entity::stake_damage(Ref<SpellDamageInfo> data) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
|
||||
@ -979,12 +1038,39 @@ void Entity::sadd_aura(Ref<AuraData> aura) {
|
||||
|
||||
emit_signal("saura_added", aura);
|
||||
|
||||
SEND_RPC(rpc("cadd_aura", aura), cadd_aura(aura));
|
||||
if (!aura->get_aura()->get_hide())
|
||||
SEND_RPC(rpc("cadd_aura", aura), cadd_aura(aura));
|
||||
}
|
||||
|
||||
void Entity::sremove_aura(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
int aid = aura->get_aura_id();
|
||||
Entity *caster = aura->get_caster();
|
||||
|
||||
Ref<AuraData> a;
|
||||
bool removed = false;
|
||||
for (int i = 0; i < _s_auras.size(); i++) {
|
||||
a = _s_auras.get(i);
|
||||
|
||||
if (a->get_aura_id() == aid && a->get_caster() == caster) {
|
||||
_s_auras.remove(i);
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed) {
|
||||
emit_signal("saura_removed", a);
|
||||
|
||||
if (!aura->get_aura()->get_hide())
|
||||
SEND_RPC(rpc("cremove_aura", a), cremove_aura(a));
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::sremove_aura_exact(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
for (int i = 0; i < _s_auras.size(); i++) {
|
||||
Ref<AuraData> ad = _s_auras.get(i);
|
||||
|
||||
@ -999,7 +1085,8 @@ void Entity::sremove_aura(Ref<AuraData> aura) {
|
||||
|
||||
emit_signal("saura_removed", aura);
|
||||
|
||||
SEND_RPC(rpc("cremove_aura", aura), cremove_aura(aura));
|
||||
if (!aura->get_aura()->get_hide())
|
||||
SEND_RPC(rpc("cremove_aura", aura), cremove_aura(aura));
|
||||
}
|
||||
|
||||
void Entity::sremove_aura_expired(Ref<AuraData> aura) {
|
||||
@ -1019,7 +1106,8 @@ void Entity::sremove_aura_expired(Ref<AuraData> aura) {
|
||||
|
||||
emit_signal("saura_removed_expired", aura);
|
||||
|
||||
SEND_RPC(rpc("cremove_aura", aura), cremove_aura(aura));
|
||||
if (!aura->get_aura()->get_hide())
|
||||
SEND_RPC(rpc("cremove_aura", aura), cremove_aura(aura));
|
||||
}
|
||||
|
||||
void Entity::sremove_aura_dispelled(Ref<AuraData> aura) {
|
||||
@ -1039,7 +1127,20 @@ void Entity::sremove_aura_dispelled(Ref<AuraData> aura) {
|
||||
|
||||
emit_signal("saura_removed_dispelled", aura);
|
||||
|
||||
SEND_RPC(rpc("cremove_aura", aura), cremove_aura(aura));
|
||||
if (!aura->get_aura()->get_hide())
|
||||
SEND_RPC(rpc("cremove_aura", aura), cremove_aura(aura));
|
||||
}
|
||||
|
||||
void Entity::saura_refreshed(Ref<AuraData> aura) {
|
||||
ERR_EXPLAIN("NYI");
|
||||
ERR_FAIL();
|
||||
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
emit_signal("caura_refreshed", aura);
|
||||
|
||||
if (!aura->get_aura()->get_hide())
|
||||
SEND_RPC(rpc("caura_refreshed", aura), caura_refreshed(aura));
|
||||
}
|
||||
|
||||
void Entity::cadd_aura(Ref<AuraData> data) {
|
||||
@ -1052,6 +1153,28 @@ void Entity::cadd_aura(Ref<AuraData> data) {
|
||||
void Entity::cremove_aura(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
int aid = aura->get_aura_id();
|
||||
Entity *caster = aura->get_caster();
|
||||
|
||||
Ref<AuraData> a;
|
||||
bool removed = false;
|
||||
for (int i = 0; i < _c_auras.size(); i++) {
|
||||
a = _c_auras.get(i);
|
||||
|
||||
if (a->get_aura_id() == aid && a->get_caster() == caster) {
|
||||
_c_auras.remove(i);
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed)
|
||||
emit_signal("caura_removed", a);
|
||||
}
|
||||
|
||||
void Entity::cremove_aura_exact(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
for (int i = 0; i < _c_auras.size(); i++) {
|
||||
if (_c_auras.get(i) == aura) {
|
||||
_c_auras.remove(i);
|
||||
@ -1075,6 +1198,16 @@ void Entity::cremove_aura_dispelled(Ref<AuraData> aura) {
|
||||
emit_signal("caura_removed_dispelled", aura);
|
||||
}
|
||||
|
||||
void Entity::caura_refreshed(Ref<AuraData> aura) {
|
||||
ERR_EXPLAIN("NYI");
|
||||
ERR_FAIL();
|
||||
|
||||
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
emit_signal("caura_refreshed", aura);
|
||||
}
|
||||
|
||||
void Entity::cremove_aura_expired(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
@ -1092,20 +1225,20 @@ int Entity::sget_aura_count() {
|
||||
return _s_auras.size();
|
||||
}
|
||||
|
||||
Ref<Aura> Entity::sget_aura(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _s_auras.size(), Ref<Aura>(NULL));
|
||||
Ref<AuraData> Entity::sget_aura(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _s_auras.size(), Ref<AuraData>(NULL));
|
||||
|
||||
return Ref<Aura>(_s_auras.get(index));
|
||||
return Ref<AuraData>(_s_auras.get(index));
|
||||
}
|
||||
|
||||
int Entity::cget_aura_count() {
|
||||
return _s_auras.size();
|
||||
}
|
||||
|
||||
Ref<Aura> Entity::cget_aura(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _c_auras.size(), Ref<Aura>(NULL));
|
||||
Ref<AuraData> Entity::cget_aura(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _c_auras.size(), Ref<AuraData>(NULL));
|
||||
|
||||
return Ref<Aura>(_c_auras.get(index));
|
||||
return Ref<AuraData>(_c_auras.get(index));
|
||||
}
|
||||
|
||||
void Entity::moved() {
|
||||
@ -2044,11 +2177,13 @@ void Entity::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("saura_removed", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
ADD_SIGNAL(MethodInfo("saura_removed_expired", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
ADD_SIGNAL(MethodInfo("saura_removed_dispelled", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
//ADD_SIGNAL(MethodInfo("saura_refreshed", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("caura_added", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
ADD_SIGNAL(MethodInfo("caura_removed", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
ADD_SIGNAL(MethodInfo("caura_removed_dispelled", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
ADD_SIGNAL(MethodInfo("caura_removed_expired", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
//ADD_SIGNAL(MethodInfo("caura_refreshed", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData")));
|
||||
|
||||
//EventHandlers
|
||||
ClassDB::bind_method(D_METHOD("son_before_aura_applied", "data"), &Entity::son_before_aura_applied);
|
||||
@ -2094,13 +2229,17 @@ void Entity::_bind_methods() {
|
||||
//Aura Manipulation
|
||||
ClassDB::bind_method(D_METHOD("sadd_aura", "aura"), &Entity::sadd_aura);
|
||||
ClassDB::bind_method(D_METHOD("sremove_aura", "aura"), &Entity::sremove_aura);
|
||||
ClassDB::bind_method(D_METHOD("sremove_aura_exact", "aura"), &Entity::sremove_aura_exact);
|
||||
ClassDB::bind_method(D_METHOD("sremove_aura_expired", "aura"), &Entity::sremove_aura_expired);
|
||||
ClassDB::bind_method(D_METHOD("sremove_aura_dispelled", "aura"), &Entity::sremove_aura_dispelled);
|
||||
//ClassDB::bind_method(D_METHOD("saura_refreshed", "aura"), &Entity::saura_refreshed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("cadd_aura", "aura"), &Entity::cadd_aura);
|
||||
ClassDB::bind_method(D_METHOD("cremove_aura", "aura"), &Entity::cremove_aura);
|
||||
ClassDB::bind_method(D_METHOD("cremove_aura_exact", "aura"), &Entity::cremove_aura_exact);
|
||||
ClassDB::bind_method(D_METHOD("cremove_aura_expired", "aura"), &Entity::cremove_aura_expired);
|
||||
ClassDB::bind_method(D_METHOD("cremove_aura_dispelled", "aura"), &Entity::cremove_aura_dispelled);
|
||||
//ClassDB::bind_method(D_METHOD("caura_refreshed", "aura"), &Entity::caura_refreshed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("sremove_auras_with_group", "aura_group"), &Entity::sremove_auras_with_group);
|
||||
|
||||
@ -2176,6 +2315,8 @@ void Entity::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_health"), &Entity::get_health);
|
||||
ClassDB::bind_method(D_METHOD("get_mana"), &Entity::get_mana);
|
||||
ClassDB::bind_method(D_METHOD("get_rage"), &Entity::get_rage);
|
||||
ClassDB::bind_method(D_METHOD("get_energy"), &Entity::get_energy);
|
||||
ClassDB::bind_method(D_METHOD("get_speed"), &Entity::get_speed);
|
||||
ClassDB::bind_method(D_METHOD("get_gcd"), &Entity::get_gcd);
|
||||
ClassDB::bind_method(D_METHOD("get_melee_crit"), &Entity::get_melee_crit);
|
||||
@ -2197,6 +2338,18 @@ void Entity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stat_enum", "index"), &Entity::get_stat_enum);
|
||||
ClassDB::bind_method(D_METHOD("set_stat_enum", "stat_id", "entry"), &Entity::set_stat_enum);
|
||||
|
||||
//Resources
|
||||
|
||||
ClassDB::bind_method(D_METHOD("gets_resource", "index"), &Entity::gets_resource);
|
||||
ClassDB::bind_method(D_METHOD("adds_resource", "palyer_resource"), &Entity::adds_resource);
|
||||
ClassDB::bind_method(D_METHOD("gets_resource_count"), &Entity::gets_resource_count);
|
||||
ClassDB::bind_method(D_METHOD("removes_resource", "index"), &Entity::removes_resource);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("getc_resource", "index"), &Entity::getc_resource);
|
||||
ClassDB::bind_method(D_METHOD("addc_resource", "palyer_resource"), &Entity::addc_resource);
|
||||
ClassDB::bind_method(D_METHOD("getc_resource_count"), &Entity::getc_resource_count);
|
||||
ClassDB::bind_method(D_METHOD("removec_resource", "index"), &Entity::removec_resource);
|
||||
|
||||
//GCD
|
||||
ADD_SIGNAL(MethodInfo("sgcd_started", PropertyInfo(Variant::REAL, "value")));
|
||||
ADD_SIGNAL(MethodInfo("sgcd_finished", PropertyInfo(Variant::REAL, "value")));
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "../data/item_instance.h"
|
||||
#include "player_talent.h"
|
||||
|
||||
#include "entity_resource.h"
|
||||
|
||||
#include "../data/spell.h"
|
||||
#include "stats/stat.h"
|
||||
@ -236,6 +237,8 @@ public:
|
||||
|
||||
_FORCE_INLINE_ Ref<Stat> get_health() { return _health; }
|
||||
_FORCE_INLINE_ Ref<Stat> get_mana() { return _mana; }
|
||||
_FORCE_INLINE_ Ref<Stat> get_energy() { return _energy; }
|
||||
_FORCE_INLINE_ Ref<Stat> get_rage() { return _rage; }
|
||||
_FORCE_INLINE_ Ref<Stat> get_speed() { return _speed; }
|
||||
_FORCE_INLINE_ Ref<Stat> get_gcd() { return _gcd; }
|
||||
_FORCE_INLINE_ Ref<Stat> get_melee_crit() { return _melee_crit; }
|
||||
@ -258,6 +261,18 @@ public:
|
||||
Ref<Stat> get_stat_enum(Stat::StatId stat_id);
|
||||
void set_stat_enum(Stat::StatId stat_id, Ref<Stat> entry);
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Ref<EntityResource> gets_resource(int index);
|
||||
void adds_resource(Ref<EntityResource> resource);
|
||||
int gets_resource_count();
|
||||
void removes_resource(int index);
|
||||
|
||||
Ref<EntityResource> getc_resource(int index);
|
||||
void addc_resource(Ref<EntityResource> resource);
|
||||
int getc_resource_count();
|
||||
void removec_resource(int index);
|
||||
|
||||
//GCD
|
||||
bool getc_has_global_cooldown();
|
||||
bool gets_has_global_cooldown();
|
||||
@ -329,21 +344,25 @@ public:
|
||||
//Aura Manipulation
|
||||
void sadd_aura(Ref<AuraData> aura);
|
||||
void sremove_aura(Ref<AuraData> aura);
|
||||
void sremove_aura_exact(Ref<AuraData> aura);
|
||||
void sremove_aura_expired(Ref<AuraData> aura);
|
||||
void sremove_aura_dispelled(Ref<AuraData> aura);
|
||||
void saura_refreshed(Ref<AuraData> aura);
|
||||
|
||||
void cadd_aura(Ref<AuraData> aura);
|
||||
void cremove_aura(Ref<AuraData> aura);
|
||||
void cremove_aura_exact(Ref<AuraData> aura);
|
||||
void cremove_aura_expired(Ref<AuraData> aura);
|
||||
void cremove_aura_dispelled(Ref<AuraData> aura);
|
||||
void caura_refreshed(Ref<AuraData> aura);
|
||||
|
||||
void sremove_auras_with_group(int aura_group);
|
||||
|
||||
int sget_aura_count();
|
||||
Ref<Aura> sget_aura(int index);
|
||||
Ref<AuraData> sget_aura(int index);
|
||||
|
||||
int cget_aura_count();
|
||||
Ref<Aura> cget_aura(int index);
|
||||
Ref<AuraData> cget_aura(int index);
|
||||
|
||||
//Hooks
|
||||
void moved();
|
||||
@ -540,6 +559,8 @@ private:
|
||||
|
||||
Ref<Stat> _health;
|
||||
Ref<Stat> _mana;
|
||||
Ref<Stat> _rage;
|
||||
Ref<Stat> _energy;
|
||||
Ref<Stat> _speed;
|
||||
Ref<Stat> _gcd;
|
||||
|
||||
@ -559,6 +580,11 @@ private:
|
||||
|
||||
Ref<Stat> _stats[Stat::STAT_ID_TOTAL_STATS];
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Vector<Ref<EntityResource> > _s_resources;
|
||||
Vector<Ref<EntityResource> > _c_resources;
|
||||
|
||||
//old
|
||||
bool sIsDead;
|
||||
bool cIsDead;
|
||||
|
44
entities/entity_resource.cpp
Normal file
44
entities/entity_resource.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "entity_resource.h"
|
||||
|
||||
bool EntityResource::get_dirty() {
|
||||
return _dirty;
|
||||
}
|
||||
void EntityResource::set_dirty(bool value) {
|
||||
_dirty = value;
|
||||
}
|
||||
|
||||
bool EntityResource::get_should_process() {
|
||||
return _should_process;
|
||||
}
|
||||
void EntityResource::set_should_process(bool value) {
|
||||
_should_process = value;
|
||||
}
|
||||
|
||||
void EntityResource::process(float delta) {
|
||||
ERR_FAIL_COND(!has_method("_process"));
|
||||
|
||||
call("_process");
|
||||
}
|
||||
|
||||
EntityResource::EntityResource() {
|
||||
_dirty = false;
|
||||
|
||||
_should_process = has_method("_process");
|
||||
}
|
||||
|
||||
void EntityResource::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("starget_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity")));
|
||||
ADD_SIGNAL(MethodInfo("ctarget_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("process", "delta"), &EntityResource::process);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_dirty"), &EntityResource::get_dirty);
|
||||
ClassDB::bind_method(D_METHOD("set_dirty", "value"), &EntityResource::set_dirty);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dirty"), "set_dirty", "get_dirty");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_should_process"), &EntityResource::get_should_process);
|
||||
ClassDB::bind_method(D_METHOD("set_should_process", "value"), &EntityResource::set_should_process);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "should_process"), "set_should_process", "get_should_process");
|
||||
}
|
28
entities/entity_resource.h
Normal file
28
entities/entity_resource.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef ENTITY_RESOURCE_H
|
||||
#define ENTITY_RESOURCE_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class EntityResource : public Reference {
|
||||
GDCLASS(EntityResource, Reference);
|
||||
|
||||
public:
|
||||
bool get_dirty();
|
||||
void set_dirty(bool value);
|
||||
|
||||
bool get_should_process();
|
||||
void set_should_process(bool value);
|
||||
|
||||
void process(float delta);
|
||||
|
||||
EntityResource();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
bool _dirty;
|
||||
bool _should_process;
|
||||
};
|
||||
|
||||
#endif
|
@ -97,8 +97,12 @@ public:
|
||||
STAT_ID_CHAOS_RESIST = 34,
|
||||
STAT_ID_SILENCE_RESIST = 35,
|
||||
STAT_ID_FEAR_RESIST = 36,
|
||||
STAT_ID_STUN_RESIST = 37,
|
||||
|
||||
STAT_ID_TOTAL_STATS = 37,
|
||||
STAT_ID_ENERGY = 38,
|
||||
STAT_ID_RAGE = 39,
|
||||
|
||||
STAT_ID_TOTAL_STATS = 40,
|
||||
STAT_ID_NONE = STAT_ID_TOTAL_STATS,
|
||||
};
|
||||
|
||||
|
@ -36,10 +36,12 @@
|
||||
#include "pipelines/spell_damage_info.h"
|
||||
#include "pipelines/spell_heal_info.h"
|
||||
|
||||
#include "entities/entity_resource.h"
|
||||
#include "entities/auras/aura_data.h"
|
||||
#include "entities/entity.h"
|
||||
#include "entities/player.h"
|
||||
#include "entities/mob.h"
|
||||
|
||||
#include "data/aura_trigger_data.h"
|
||||
#include "data/aura_stat_attribute.h"
|
||||
|
||||
@ -97,6 +99,8 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<SpellHealInfo>();
|
||||
ClassDB::register_class<AuraData>();
|
||||
|
||||
ClassDB::register_class<EntityResource>();
|
||||
|
||||
ClassDB::register_class<AuraTriggerData>();
|
||||
|
||||
//entities
|
||||
|
Loading…
Reference in New Issue
Block a user