mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Resources should work in multiplayer now, also work on bindings.
This commit is contained in:
parent
b3cb5b2def
commit
abb564acdc
@ -1,5 +1,7 @@
|
||||
#include "aura.h"
|
||||
|
||||
#include "../entities/resources/entity_resource_cost_data.h"
|
||||
|
||||
int Aura::get_id() {
|
||||
return id;
|
||||
}
|
||||
@ -250,6 +252,20 @@ void Aura::set_heal(int min, int max, bool can_crit) {
|
||||
set_heal_can_crit(can_crit);
|
||||
}
|
||||
|
||||
Ref<EntityResourceCostData> Aura::get_resource_cost() {
|
||||
return _resource_cost;
|
||||
}
|
||||
void Aura::set_resource_cost(Ref<EntityResourceCostData> value) {
|
||||
_resource_cost = value;
|
||||
}
|
||||
|
||||
Ref<EntityResourceCostData> Aura::get_resource_give() {
|
||||
return _resource_give;
|
||||
}
|
||||
void Aura::set_resource_give(Ref<EntityResourceCostData> value) {
|
||||
_resource_give = value;
|
||||
}
|
||||
|
||||
Aura::Aura() {
|
||||
ability_scale_data_id = 1;
|
||||
id = 0;
|
||||
@ -1479,6 +1495,16 @@ void Aura::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_heal_scaling_curve", "curve"), &Aura::set_heal_scaling_curve);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "heal_scaling_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_heal_scaling_curve", "get_heal_scaling_curve");
|
||||
|
||||
//Resources
|
||||
ADD_GROUP("Resources", "resource");
|
||||
ClassDB::bind_method(D_METHOD("get_resource_cost"), &Aura::get_resource_cost);
|
||||
ClassDB::bind_method(D_METHOD("set_resource_cost", "value"), &Aura::set_resource_cost);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource_cost", PROPERTY_HINT_RESOURCE_TYPE, "EntityResourceCostData"), "set_resource_cost", "get_resource_cost");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_resource_give"), &Aura::get_resource_give);
|
||||
ClassDB::bind_method(D_METHOD("set_resource_give", "value"), &Aura::set_resource_give);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource_give", PROPERTY_HINT_RESOURCE_TYPE, "EntityResourceCostData"), "set_resource_give", "get_resource_give");
|
||||
|
||||
ADD_GROUP("States", "states");
|
||||
ClassDB::bind_method(D_METHOD("get_add_states"), &Aura::get_add_states);
|
||||
ClassDB::bind_method(D_METHOD("set_add_states", "value"), &Aura::set_add_states);
|
||||
|
66
data/aura.h
66
data/aura.h
@ -33,6 +33,7 @@ class AuraApplyInfo;
|
||||
class AuraScript;
|
||||
class Entity;
|
||||
class SpellCastInfo;
|
||||
class EntityResourceCostData;
|
||||
|
||||
class Aura : public Resource {
|
||||
GDCLASS(Aura, Resource);
|
||||
@ -139,6 +140,13 @@ public:
|
||||
|
||||
void set_heal(int min, int max, bool can_crit);
|
||||
|
||||
//Resources
|
||||
Ref<EntityResourceCostData> get_resource_cost();
|
||||
void set_resource_cost(Ref<EntityResourceCostData> value);
|
||||
|
||||
Ref<EntityResourceCostData> get_resource_give();
|
||||
void set_resource_give(Ref<EntityResourceCostData> value);
|
||||
|
||||
Ref<Curve> get_damage_scaling_curve() { return _damage_scaling_curve; }
|
||||
void set_damage_scaling_curve(Ref<Curve> curve) { _damage_scaling_curve = curve; }
|
||||
|
||||
@ -335,61 +343,6 @@ public:
|
||||
Aura();
|
||||
~Aura();
|
||||
|
||||
/*
|
||||
void RemoveAura(WorldEntity *caster);
|
||||
bool ShouldApplyModifiers(WorldEntity *target);
|
||||
bool BasicAuraUpdate(WorldEntity *target, AuraData *data);
|
||||
bool ShouldApplyModifiers(WorldEntity *target, float refreshTo);
|
||||
bool ShouldApplyModifiers(WorldEntity *target, float refreshTo, WorldEntity *caster, float spellScale);
|
||||
bool ShouldRemoveModifiers(WorldEntity *target);
|
||||
void RefreshDamageCountAuraDiminished(WorldEntity *target, float refreshTo, WorldEntity *caster, DiminishingReturnAuraData::DiminishingReturnCategory diminsihingType, DamageCountAuraData *aura);
|
||||
void AddAuraDataToTarget(WorldEntity *target, AuraData *data);
|
||||
void AddAuraDataToTarget(WorldEntity *target, WorldEntity *caster, float duration, float spellScale);
|
||||
void AddOrRefreshDamageAuraDataToTarget(WorldEntity *target, WorldEntity *caster, float spellScale, float duration, float tick, int damage);
|
||||
void AddOrRefreshHealAuraDataToTarget(WorldEntity *target, WorldEntity *caster, float spellScale, float duration, float tick, int heal);
|
||||
void AddOrRefreshShieldAuraDataToTarget(WorldEntity *target, WorldEntity *caster, float spellScale, float duration, int absorb);
|
||||
void AddOrRefreshDiminishingReturnAura(WorldEntity *target, DiminishingReturnAuraData::DiminishingReturnCategory diminishingCategory);
|
||||
void AddStatModifier(WorldEntity *target, int stat, float maxMod, float percentMod);
|
||||
void RemoveStatModifier(WorldEntity *target, int stat);
|
||||
void AddState(WorldEntity *target, StateData::StateType state);
|
||||
void RemoveState(WorldEntity *target, StateData::StateType state);
|
||||
void RemovethisAura(WorldEntity *target);
|
||||
AuraData *TargetHasCastersAura(WorldEntity *target, WorldEntity *caster);
|
||||
AuraData *TargetHasAura(WorldEntity *target);
|
||||
int CalculateDamage(WorldEntity *caster, WorldEntity *target, float spellScale);
|
||||
int CalculateHeal(WorldEntity *caster, WorldEntity *target, float spellScale);
|
||||
int CalculateAbsorb(WorldEntity *caster, WorldEntity *target, float spellScale);
|
||||
void UpdateDamageCountAura(WorldEntity *target, AuraData *aura, int damage, float breakHealthPercent);
|
||||
bool UpdateDamageAura(WorldEntity *target, AuraData *data);
|
||||
bool UpdateDamageAuraTickBool(WorldEntity *target, AuraData *data);
|
||||
bool UpdateHealAura(WorldEntity *target, AuraData *data);
|
||||
void AbsorbPOnBeforeDamage(SpellDamageInfo *data, AuraData *aura);
|
||||
void DealDamage(WorldEntity *target, DamageAuraData *data);
|
||||
void DealDamage(WorldEntity *target, DamageAuraData *data, int damage);
|
||||
void DealDamage(WorldEntity *target, WorldEntity *caster, int damage);
|
||||
void DealDamageWithoutOnHit(WorldEntity *target, WorldEntity *caster, int damage);
|
||||
void Heal(WorldEntity *target, HealAuraData *data);
|
||||
void Heal(WorldEntity *target, HealAuraData *data, int heal);
|
||||
void Heal(WorldEntity *target, AuraData *data, int heal);
|
||||
DiminishingReturnAuraData *GetDiminishingReturnAuraDataFor(WorldEntity *target, DiminishingReturnAuraData::DiminishingReturnCategory type);
|
||||
float GetDiminishedTime(WorldEntity *target, DiminishingReturnAuraData::DiminishingReturnCategory diminsihingType, float time);
|
||||
void AddEffect(WorldEntity *player, EffectPoints bodyPart, Quaternion *rotation =);
|
||||
void AddEffect(WorldEntity *player, GameObject *effectPrefab, EffectPoints bodyPart, Quaternion *rotation =);
|
||||
void RemoveEffect(WorldEntity *player, EffectPoints bodyPart);
|
||||
void RemoveActiveGroupAuras(WorldEntity *target);
|
||||
float GetDiminishedTime(WorldEntity *target, DiminishingReturnAuraData *aura, float time);
|
||||
int GetAuraIdForDiminishingReturn(DiminishingReturnAuraData::DiminishingReturnCategory type);
|
||||
AuraData *getAuraData(WorldEntity *target, int pAuraId);
|
||||
void ApplyAura(int auraId, WorldEntity *caster, WorldEntity *target, float spellScale);
|
||||
bool IsZero(float x);*/
|
||||
|
||||
//generic
|
||||
// void ApplyEffect(Entity* target);
|
||||
// void RemoveEffect(Entity* target);
|
||||
// void ApplyModifiers(Entity* target);
|
||||
// void RemoveModifiers(Entity* target);
|
||||
// bool hasModifiers;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _validate_property(PropertyInfo &property) const;
|
||||
@ -437,6 +390,9 @@ private:
|
||||
bool _heal_can_crit;
|
||||
Ref<Curve> _heal_scaling_curve;
|
||||
|
||||
Ref<EntityResourceCostData> _resource_cost;
|
||||
Ref<EntityResourceCostData> _resource_give;
|
||||
|
||||
int _add_states;
|
||||
int _remove_effects_with_states;
|
||||
int _supress_states;
|
||||
|
141
data/spell.cpp
141
data/spell.cpp
@ -2,6 +2,7 @@
|
||||
|
||||
#include "aura.h"
|
||||
#include "craft_recipe.h"
|
||||
#include "../entities/resources/entity_resource_cost_data.h"
|
||||
|
||||
int Spell::get_id() {
|
||||
return _id;
|
||||
@ -87,32 +88,18 @@ void Spell::set_required_item(int value) {
|
||||
_required_item = value;
|
||||
}
|
||||
|
||||
int Spell::get_cost_type() {
|
||||
return _cost_type;
|
||||
Ref<EntityResourceCostData> Spell::get_resource_cost() {
|
||||
return _resource_cost;
|
||||
}
|
||||
void Spell::set_cost_type(int value) {
|
||||
_cost_type = value;
|
||||
void Spell::set_resource_cost(Ref<EntityResourceCostData> value) {
|
||||
_resource_cost = value;
|
||||
}
|
||||
|
||||
int Spell::get_cost_resource() {
|
||||
return _cost_resource;
|
||||
Ref<EntityResourceCostData> Spell::get_resource_give() {
|
||||
return _resource_give;
|
||||
}
|
||||
void Spell::set_cost_resource(int value) {
|
||||
_cost_resource = value;
|
||||
}
|
||||
|
||||
int Spell::get_give_resource_type() {
|
||||
return _give_resource_type;
|
||||
}
|
||||
void Spell::set_give_resource_type(int value) {
|
||||
_give_resource_type = value;
|
||||
}
|
||||
|
||||
int Spell::get_give_resource() {
|
||||
return _give_resource;
|
||||
}
|
||||
void Spell::set_give_resource(int value) {
|
||||
_give_resource = value;
|
||||
void Spell::set_resource_give(Ref<EntityResourceCostData> value) {
|
||||
_resource_give = value;
|
||||
}
|
||||
|
||||
bool Spell::has_global_cooldown() {
|
||||
@ -757,10 +744,7 @@ Spell::Spell() {
|
||||
_item_cost = 0;
|
||||
_craft_material_cost = 0;
|
||||
_required_item = 0;
|
||||
_cost_type = 0;
|
||||
_cost_resource = 0;
|
||||
_give_resource_type = 0;
|
||||
_give_resource = 0;
|
||||
|
||||
_has_global_cooldown = true;
|
||||
_is_local_spell = false;
|
||||
|
||||
@ -808,6 +792,21 @@ Spell::~Spell() {
|
||||
_caster_aura_applys.clear();
|
||||
_target_aura_applys.clear();
|
||||
_on_learn_auras.clear();
|
||||
|
||||
_resource_cost.unref();
|
||||
_resource_give.unref();
|
||||
|
||||
_icon.unref();
|
||||
|
||||
_visual_spell_effects.unref();
|
||||
_spell_projectile_data.unref();
|
||||
_world_effect_data.unref();
|
||||
_teaches_craft_recipe.unref();
|
||||
_damage_scaling_curve.unref();
|
||||
_heal_scaling_curve.unref();
|
||||
_projectile.unref();
|
||||
_training_required_spell.unref();
|
||||
_training_required_skill.unref();
|
||||
}
|
||||
|
||||
void Spell::_bind_methods() {
|
||||
@ -921,6 +920,39 @@ void Spell::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_heal_scale_for_level"), &Spell::get_heal_scale_for_level);
|
||||
ClassDB::bind_method(D_METHOD("get_absorb_scale_for_level"), &Spell::get_absorb_scale_for_level);
|
||||
|
||||
//ADD_GROUP("Caster Aura Applys", "caster_aura_applys");
|
||||
ClassDB::bind_method(D_METHOD("get_num_caster_aura_applys"), &Spell::get_num_caster_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_num_caster_aura_applys", "value"), &Spell::set_num_caster_aura_applys);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_caster_aura_apply", "index"), &Spell::get_caster_aura_apply);
|
||||
ClassDB::bind_method(D_METHOD("set_caster_aura_apply", "index", "aura"), &Spell::set_caster_aura_apply);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_caster_aura_applys"), &Spell::get_caster_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_caster_aura_applys", "caster_aura_applys"), &Spell::set_caster_aura_applys);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "caster_aura_applys", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_caster_aura_applys", "get_caster_aura_applys");
|
||||
|
||||
//ADD_GROUP("Target Aura Apply", "target_aura_applys");
|
||||
ClassDB::bind_method(D_METHOD("get_num_target_aura_applys"), &Spell::get_num_target_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_num_target_aura_applys", "value"), &Spell::set_num_target_aura_applys);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_aura_apply", "index"), &Spell::get_target_aura_apply);
|
||||
ClassDB::bind_method(D_METHOD("set_target_aura_apply", "index", "aura"), &Spell::set_target_aura_apply);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_aura_applys"), &Spell::get_target_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_target_aura_applys", "target_aura_applys"), &Spell::set_target_aura_applys);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "target_aura_applys", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_target_aura_applys", "get_target_aura_applys");
|
||||
|
||||
//ADD_GROUP("Apply Auras On Learn", "on_learn_auras");
|
||||
ClassDB::bind_method(D_METHOD("get_num_on_learn_auras"), &Spell::get_num_on_learn_auras);
|
||||
ClassDB::bind_method(D_METHOD("set_num_on_learn_auras", "value"), &Spell::set_num_on_learn_auras);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_on_learn_aura", "index"), &Spell::get_on_learn_aura);
|
||||
ClassDB::bind_method(D_METHOD("set_on_learn_aura", "index", "aura"), &Spell::set_on_learn_aura);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_on_learn_auras"), &Spell::get_on_learn_auras);
|
||||
ClassDB::bind_method(D_METHOD("set_on_learn_auras", "spells"), &Spell::set_on_learn_auras);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "on_learn_auras", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_on_learn_auras", "get_on_learn_auras");
|
||||
|
||||
ADD_GROUP("Texts", "text");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_name", "get_name");
|
||||
|
||||
@ -937,39 +969,6 @@ void Spell::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_has_global_cooldown", "value"), &Spell::set_has_global_cooldown);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cooldown_global_cooldown"), "set_has_global_cooldown", "has_global_cooldown");
|
||||
|
||||
ADD_GROUP("Caster Aura Applys", "caster_aura_applys");
|
||||
ClassDB::bind_method(D_METHOD("get_num_caster_aura_applys"), &Spell::get_num_caster_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_num_caster_aura_applys", "value"), &Spell::set_num_caster_aura_applys);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_caster_aura_apply", "index"), &Spell::get_caster_aura_apply);
|
||||
ClassDB::bind_method(D_METHOD("set_caster_aura_apply", "index", "aura"), &Spell::set_caster_aura_apply);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_caster_aura_applys"), &Spell::get_caster_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_caster_aura_applys", "caster_aura_applys"), &Spell::set_caster_aura_applys);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "caster_aura_applys", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_caster_aura_applys", "get_caster_aura_applys");
|
||||
|
||||
ADD_GROUP("Target Aura Apply", "target_aura_applys");
|
||||
ClassDB::bind_method(D_METHOD("get_num_target_aura_applys"), &Spell::get_num_target_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_num_target_aura_applys", "value"), &Spell::set_num_target_aura_applys);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_aura_apply", "index"), &Spell::get_target_aura_apply);
|
||||
ClassDB::bind_method(D_METHOD("set_target_aura_apply", "index", "aura"), &Spell::set_target_aura_apply);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_aura_applys"), &Spell::get_target_aura_applys);
|
||||
ClassDB::bind_method(D_METHOD("set_target_aura_applys", "target_aura_applys"), &Spell::set_target_aura_applys);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "target_aura_applys", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_target_aura_applys", "get_target_aura_applys");
|
||||
|
||||
ADD_GROUP("Apply Auras On Learn", "on_learn_auras");
|
||||
ClassDB::bind_method(D_METHOD("get_num_on_learn_auras"), &Spell::get_num_on_learn_auras);
|
||||
ClassDB::bind_method(D_METHOD("set_num_on_learn_auras", "value"), &Spell::set_num_on_learn_auras);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_on_learn_aura", "index"), &Spell::get_on_learn_aura);
|
||||
ClassDB::bind_method(D_METHOD("set_on_learn_aura", "index", "aura"), &Spell::set_on_learn_aura);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_on_learn_auras"), &Spell::get_on_learn_auras);
|
||||
ClassDB::bind_method(D_METHOD("set_on_learn_auras", "spells"), &Spell::set_on_learn_auras);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "on_learn_auras", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_on_learn_auras", "get_on_learn_auras");
|
||||
|
||||
ADD_GROUP("Range", "range");
|
||||
ClassDB::bind_method(D_METHOD("get_has_range"), &Spell::get_has_range);
|
||||
ClassDB::bind_method(D_METHOD("set_has_range", "value"), &Spell::set_has_range);
|
||||
@ -1052,22 +1051,14 @@ void Spell::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_required_item", "value"), &Spell::set_required_item);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "cost_required_item"), "set_required_item", "get_required_item");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_cost_type"), &Spell::get_cost_type);
|
||||
ClassDB::bind_method(D_METHOD("set_cost_type", "value"), &Spell::set_cost_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "cost_type"), "set_cost_type", "get_cost_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_cost_resource"), &Spell::get_cost_resource);
|
||||
ClassDB::bind_method(D_METHOD("set_cost_resource", "value"), &Spell::set_cost_resource);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "cost_resource"), "set_cost_resource", "get_cost_resource");
|
||||
|
||||
ADD_GROUP("Gives", "give");
|
||||
ClassDB::bind_method(D_METHOD("get_give_resource_type"), &Spell::get_give_resource_type);
|
||||
ClassDB::bind_method(D_METHOD("set_give_resource_type", "value"), &Spell::set_give_resource_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "give_resource_type"), "set_give_resource_type", "get_give_resource_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_give_resource"), &Spell::get_give_resource);
|
||||
ClassDB::bind_method(D_METHOD("set_give_resource", "value"), &Spell::set_give_resource);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "give_resource"), "set_give_resource", "get_give_resource");
|
||||
ADD_GROUP("Resources", "resource");
|
||||
ClassDB::bind_method(D_METHOD("get_resource_cost"), &Spell::get_resource_cost);
|
||||
ClassDB::bind_method(D_METHOD("set_resource_cost", "value"), &Spell::set_resource_cost);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource_cost", PROPERTY_HINT_RESOURCE_TYPE, "EntityResourceCostData"), "set_resource_cost", "get_resource_cost");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_resource_give"), &Spell::get_resource_give);
|
||||
ClassDB::bind_method(D_METHOD("set_resource_give", "value"), &Spell::set_resource_give);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource_give", PROPERTY_HINT_RESOURCE_TYPE, "EntityResourceCostData"), "set_resource_give", "get_resource_give");
|
||||
|
||||
ADD_GROUP("AOE", "aoe");
|
||||
ClassDB::bind_method(D_METHOD("get_is_aoe"), &Spell::get_is_aoe);
|
||||
|
23
data/spell.h
23
data/spell.h
@ -24,6 +24,7 @@ class Aura;
|
||||
class SpellCastInfo;
|
||||
class Spell;
|
||||
class CraftRecipe;
|
||||
class EntityResourceCostData;
|
||||
|
||||
enum TargetRelationType {
|
||||
TARGET_SELF = 1 << 0,
|
||||
@ -119,17 +120,11 @@ public:
|
||||
int get_required_item();
|
||||
void set_required_item(int value);
|
||||
|
||||
int get_cost_type();
|
||||
void set_cost_type(int value);
|
||||
Ref<EntityResourceCostData> get_resource_cost();
|
||||
void set_resource_cost(Ref<EntityResourceCostData> value);
|
||||
|
||||
int get_cost_resource();
|
||||
void set_cost_resource(int value);
|
||||
|
||||
int get_give_resource_type();
|
||||
void set_give_resource_type(int value);
|
||||
|
||||
int get_give_resource();
|
||||
void set_give_resource(int value);
|
||||
Ref<EntityResourceCostData> get_resource_give();
|
||||
void set_resource_give(Ref<EntityResourceCostData> value);
|
||||
|
||||
bool has_global_cooldown();
|
||||
void set_has_global_cooldown(bool value);
|
||||
@ -356,10 +351,10 @@ private:
|
||||
int _item_cost;
|
||||
int _craft_material_cost;
|
||||
int _required_item;
|
||||
int _cost_type;
|
||||
int _cost_resource;
|
||||
int _give_resource_type;
|
||||
int _give_resource;
|
||||
|
||||
Ref<EntityResourceCostData> _resource_cost;
|
||||
Ref<EntityResourceCostData> _resource_give;
|
||||
|
||||
bool _has_global_cooldown;
|
||||
bool _is_local_spell;
|
||||
Ref<Texture> _icon;
|
||||
|
@ -289,6 +289,16 @@ void Entity::_setup() {
|
||||
VRPCOBJ(cadd_aura_rpc, JSON::print(ad->to_dict()), cadd_aura, ad);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _s_resources.size(); ++i) {
|
||||
Ref<EntityResource> res = _s_resources.get(i);
|
||||
|
||||
ERR_CONTINUE(!res.is_valid());
|
||||
|
||||
res->resolve_references();
|
||||
|
||||
//SEND
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -357,6 +367,14 @@ void Entity::_setup() {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _s_resources.size(); ++i) {
|
||||
Ref<EntityResource> res = _s_resources.get(i);
|
||||
|
||||
ERR_CONTINUE(!res.is_valid());
|
||||
|
||||
res->resolve_references();
|
||||
}
|
||||
|
||||
sets_ai(_s_entity_data->get_ai_instance());
|
||||
|
||||
if (!Engine::get_singleton()->is_editor_hint())
|
||||
@ -1548,12 +1566,12 @@ void Entity::_cdeapply_item(Ref<ItemInstance> item) {
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Ref<EntityResource> Entity::gets_resource(int index) {
|
||||
Ref<EntityResource> Entity::gets_resource_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _s_resources.size(), Ref<EntityResource>());
|
||||
|
||||
return _s_resources.get(index);
|
||||
}
|
||||
Ref<EntityResource> Entity::gets_resource_type(int id) {
|
||||
Ref<EntityResource> Entity::gets_resource_id(int id) {
|
||||
for (int i = 0; i < _s_resources.size(); ++i) {
|
||||
Ref<EntityResource> r = _s_resources.get(i);
|
||||
|
||||
@ -1567,11 +1585,11 @@ Ref<EntityResource> Entity::gets_resource_type(int id) {
|
||||
void Entity::adds_resource(Ref<EntityResource> resource) {
|
||||
ERR_FAIL_COND(!resource.is_valid());
|
||||
|
||||
resource->ons_added(this);
|
||||
_s_resources.push_back(resource);
|
||||
|
||||
//temporary
|
||||
addc_resource(resource);
|
||||
resource->ons_added(this);
|
||||
|
||||
VRPCOBJP(addc_resource_rpc, _s_resources.size() - 1, JSON::print(resource->to_dict()), addc_resource, _s_resources.size() - 1, resource);
|
||||
}
|
||||
int Entity::gets_resource_count() {
|
||||
return _s_resources.size();
|
||||
@ -1580,34 +1598,50 @@ void Entity::removes_resource(int index) {
|
||||
ERR_FAIL_INDEX(index, _s_resources.size());
|
||||
|
||||
_s_resources.remove(index);
|
||||
}
|
||||
|
||||
VRPC(removec_resource, index);
|
||||
}
|
||||
void Entity::clears_resource() {
|
||||
_s_resources.clear();
|
||||
|
||||
VRPC(clearc_resource);
|
||||
}
|
||||
|
||||
Ref<EntityResource> Entity::getc_resource(int index) {
|
||||
void Entity::addc_resource_rpc(int index, String data) {
|
||||
Ref<EntityResource> res;
|
||||
res.instance();
|
||||
res->from_dict(data_as_dict(data));
|
||||
res->resolve_references();
|
||||
|
||||
addc_resource(index, res);
|
||||
}
|
||||
|
||||
Ref<EntityResource> Entity::getc_resource_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _c_resources.size(), Ref<EntityResource>());
|
||||
|
||||
return _c_resources.get(index);
|
||||
}
|
||||
Ref<EntityResource> Entity::getc_resource_type(int type) {
|
||||
Ref<EntityResource> Entity::getc_resource_id(int id) {
|
||||
for (int i = 0; i < _c_resources.size(); ++i) {
|
||||
Ref<EntityResource> r = _c_resources.get(i);
|
||||
|
||||
if (r->get_data_id() == type) {
|
||||
if (r->get_data_id() == id) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return Ref<EntityResource>(NULL);
|
||||
}
|
||||
void Entity::addc_resource(Ref<EntityResource> resource) {
|
||||
void Entity::addc_resource(int index, Ref<EntityResource> resource) {
|
||||
ERR_FAIL_COND(!resource.is_valid());
|
||||
|
||||
resource->onc_added(this);
|
||||
if (_c_resources.size() <= index) {
|
||||
_c_resources.resize(index + 1);
|
||||
}
|
||||
|
||||
_c_resources.push_back(resource);
|
||||
_c_resources.set(index, resource);
|
||||
|
||||
resource->onc_added(this);
|
||||
}
|
||||
int Entity::getc_resource_count() {
|
||||
return _c_resources.size();
|
||||
@ -1621,6 +1655,44 @@ void Entity::clearc_resource() {
|
||||
_s_resources.clear();
|
||||
}
|
||||
|
||||
void Entity::sends_resource_current(int index, int current) {
|
||||
VRPC(creceive_resource_current, index, current);
|
||||
}
|
||||
void Entity::sends_resource_curr_max(int index, int current, int max) {
|
||||
VRPC(creceive_resource_curr_max, index, current, max);
|
||||
}
|
||||
void Entity::sends_resource_data(int index, String data) {
|
||||
VRPC(creceive_resource_data, index, data);
|
||||
}
|
||||
|
||||
void Entity::creceive_resource_current(int index, int current) {
|
||||
ERR_FAIL_INDEX(index, _c_resources.size());
|
||||
|
||||
Ref<EntityResource> res = _c_resources.get(index);
|
||||
|
||||
ERR_FAIL_COND(!res.is_valid());
|
||||
|
||||
res->receivec_update(current);
|
||||
}
|
||||
void Entity::creceive_resource_curr_max(int index, int current, int max) {
|
||||
ERR_FAIL_INDEX(index, _c_resources.size());
|
||||
|
||||
Ref<EntityResource> res = _c_resources.get(index);
|
||||
|
||||
ERR_FAIL_COND(!res.is_valid());
|
||||
|
||||
res->receivec_update_full(current, max);
|
||||
}
|
||||
void Entity::creceive_resource_data(int index, String data) {
|
||||
ERR_FAIL_INDEX(index, _c_resources.size());
|
||||
|
||||
Ref<EntityResource> res = _c_resources.get(index);
|
||||
|
||||
ERR_FAIL_COND(!res.is_valid());
|
||||
|
||||
res->receivec_update_string(data);
|
||||
}
|
||||
|
||||
void Entity::stake_damage(Ref<SpellDamageInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
|
||||
@ -4645,29 +4717,13 @@ void Entity::update(float delta) {
|
||||
|
||||
update_auras(delta);
|
||||
|
||||
for (int i = 0; i < _s_resources.size(); ++i) {
|
||||
Ref<EntityResource> er = _s_resources.get(i);
|
||||
|
||||
if (er->get_should_process()) {
|
||||
er->process(delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (ISSERVER()) {
|
||||
if (_s_spell_cast_info.is_valid() && _s_spell_cast_info->get_is_casting()) {
|
||||
if (_s_spell_cast_info->update_cast_time(delta)) {
|
||||
sfinish_cast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ISCLIENT()) {
|
||||
if (_c_spell_cast_info.is_valid() && _c_spell_cast_info->get_is_casting()) {
|
||||
_c_spell_cast_info->update_cast_time(delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (ISSERVER()) {
|
||||
for (int i = 0; i < Stat::STAT_ID_TOTAL_STATS; ++i) {
|
||||
Ref<Stat> s = _stats[i];
|
||||
|
||||
@ -4680,15 +4736,35 @@ void Entity::update(float delta) {
|
||||
s->set_dirty(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ISSERVER()) {
|
||||
if (_s_entity_controller == EntityEnums::ENITIY_CONTROLLER_AI && _s_ai->get_enabled()) {
|
||||
if (_s_is_pet)
|
||||
_s_ai->pet_update(delta);
|
||||
else
|
||||
_s_ai->update(delta);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _s_resources.size(); ++i) {
|
||||
Ref<EntityResource> res = _s_resources.get(i);
|
||||
|
||||
ERR_CONTINUE(!res.is_valid());
|
||||
|
||||
res->process_server(delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (ISCLIENT()) {
|
||||
if (_c_spell_cast_info.is_valid() && _c_spell_cast_info->get_is_casting()) {
|
||||
_c_spell_cast_info->update_cast_time(delta);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _c_resources.size(); ++i) {
|
||||
Ref<EntityResource> res = _c_resources.get(i);
|
||||
|
||||
ERR_CONTINUE(!res.is_valid());
|
||||
|
||||
res->process_client(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4999,7 +5075,13 @@ Entity::Entity() {
|
||||
|
||||
//// Resources ////
|
||||
|
||||
//SendResource
|
||||
SET_RPC_REMOTE("addc_resource_rpc");
|
||||
SET_RPC_REMOTE("removec_resource");
|
||||
SET_RPC_REMOTE("clearc_resource");
|
||||
|
||||
SET_RPC_REMOTE("creceive_resource_current");
|
||||
SET_RPC_REMOTE("creceive_resource_curr_max");
|
||||
SET_RPC_REMOTE("creceive_resource_data");
|
||||
|
||||
//// Global Cooldown ////
|
||||
|
||||
@ -5791,20 +5873,30 @@ void Entity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_cdeapply_item", "item"), &Entity::_cdeapply_item);
|
||||
|
||||
//Resources
|
||||
ClassDB::bind_method(D_METHOD("gets_resource", "index"), &Entity::gets_resource);
|
||||
ClassDB::bind_method(D_METHOD("gets_resource_type", "type"), &Entity::gets_resource_type);
|
||||
ClassDB::bind_method(D_METHOD("gets_resource_index", "index"), &Entity::gets_resource_index);
|
||||
ClassDB::bind_method(D_METHOD("gets_resource_id", "type"), &Entity::gets_resource_id);
|
||||
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("clears_resource"), &Entity::clears_resource);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("getc_resource", "index"), &Entity::getc_resource);
|
||||
ClassDB::bind_method(D_METHOD("getc_resource_type", "type"), &Entity::getc_resource_type);
|
||||
ClassDB::bind_method(D_METHOD("addc_resource_rpc", "index", "data"), &Entity::addc_resource_rpc);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("getc_resource_index", "index"), &Entity::getc_resource_index);
|
||||
ClassDB::bind_method(D_METHOD("getc_resource_id", "type"), &Entity::getc_resource_id);
|
||||
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);
|
||||
ClassDB::bind_method(D_METHOD("clearc_resource"), &Entity::clearc_resource);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("sends_resource_current", "index", "current"), &Entity::sends_resource_current);
|
||||
ClassDB::bind_method(D_METHOD("sends_resource_curr_max", "index", "current", "max"), &Entity::sends_resource_curr_max);
|
||||
ClassDB::bind_method(D_METHOD("sends_resource_data", "index", "data"), &Entity::sends_resource_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("creceive_resource_current", "index", "current"), &Entity::creceive_resource_current);
|
||||
ClassDB::bind_method(D_METHOD("creceive_resource_curr_max", "index", "current", "max"), &Entity::creceive_resource_curr_max);
|
||||
ClassDB::bind_method(D_METHOD("creceive_resource_data", "index", "data"), &Entity::creceive_resource_data);
|
||||
|
||||
//GCD
|
||||
ADD_SIGNAL(MethodInfo("sgcd_started", PropertyInfo(Variant::REAL, "value")));
|
||||
ADD_SIGNAL(MethodInfo("sgcd_finished"));
|
||||
|
@ -132,6 +132,12 @@ enum PlayerSendFlags {
|
||||
} \
|
||||
normalfunc(normal_var);
|
||||
|
||||
#define VRPCOBJP(rpcfunc, rpc_var1, rpc_var2, normalfunc, normal_var1, normal_var2) \
|
||||
if (is_inside_tree() && get_tree()->has_network_peer()) { \
|
||||
vrpc(#rpcfunc, rpc_var1, rpc_var2); \
|
||||
} \
|
||||
normalfunc(normal_var1, normal_var2);
|
||||
|
||||
#define ORPCOBJ(rpcfunc, rpc_var, normalfunc, normal_var) \
|
||||
if (is_inside_tree() && get_tree()->has_network_peer()) { \
|
||||
if (get_tree()->is_network_server() && get_network_master() != 1) \
|
||||
@ -338,20 +344,30 @@ public:
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Ref<EntityResource> gets_resource(int index);
|
||||
Ref<EntityResource> gets_resource_type(int type);
|
||||
Ref<EntityResource> gets_resource_index(int index);
|
||||
Ref<EntityResource> gets_resource_id(int id);
|
||||
void adds_resource(Ref<EntityResource> resource);
|
||||
int gets_resource_count();
|
||||
void removes_resource(int index);
|
||||
void clears_resource();
|
||||
|
||||
Ref<EntityResource> getc_resource(int index);
|
||||
Ref<EntityResource> getc_resource_type(int type);
|
||||
void addc_resource(Ref<EntityResource> resource);
|
||||
void addc_resource_rpc(int index, String data);
|
||||
|
||||
Ref<EntityResource> getc_resource_index(int index);
|
||||
Ref<EntityResource> getc_resource_id(int id);
|
||||
void addc_resource(int index, Ref<EntityResource> resource);
|
||||
int getc_resource_count();
|
||||
void removec_resource(int index);
|
||||
void clearc_resource();
|
||||
|
||||
void sends_resource_current(int index, int current);
|
||||
void sends_resource_curr_max(int index, int current, int max);
|
||||
void sends_resource_data(int index, String data);
|
||||
|
||||
void creceive_resource_current(int index, int current);
|
||||
void creceive_resource_curr_max(int index, int current, int max);
|
||||
void creceive_resource_data(int index, String data);
|
||||
|
||||
//// Global Cooldown ////
|
||||
|
||||
bool getc_has_global_cooldown();
|
||||
|
@ -108,18 +108,24 @@ void EntityResource::onc_target_changed(Entity *entity, Entity *old_target) {
|
||||
call("_ons_target_changed", entity, old_target);
|
||||
}
|
||||
|
||||
void EntityResource::process(float delta) {
|
||||
call("_process", delta);
|
||||
void EntityResource::process_server(float delta) {
|
||||
call("_process_server", delta);
|
||||
}
|
||||
void EntityResource::_process_server(float delta) {
|
||||
}
|
||||
|
||||
void EntityResource::_process(float delta) {
|
||||
void EntityResource::process_client(float delta) {
|
||||
call("_process_client", delta);
|
||||
}
|
||||
void EntityResource::_process_client(float delta) {
|
||||
}
|
||||
|
||||
String EntityResource::gets_update_string() {
|
||||
if (has_method("_gets_update_string"))
|
||||
return call("_gets_update_string");
|
||||
|
||||
return "";
|
||||
void EntityResource::receivec_update(int current) {
|
||||
_current = current;
|
||||
}
|
||||
void EntityResource::receivec_update_full(int current, int max) {
|
||||
_current = current;
|
||||
_max = max;
|
||||
}
|
||||
void EntityResource::receivec_update_string(String str) {
|
||||
if (has_method("_receivec_update_string"))
|
||||
@ -163,6 +169,7 @@ void EntityResource::_from_dict(const Dictionary &dict) {
|
||||
}
|
||||
|
||||
EntityResource::EntityResource() {
|
||||
_server_side = false;
|
||||
_dirty = false;
|
||||
|
||||
_should_process = has_method("_process");
|
||||
@ -172,6 +179,10 @@ EntityResource::EntityResource() {
|
||||
_max = 0;
|
||||
}
|
||||
|
||||
EntityResource::~EntityResource() {
|
||||
_data.unref();
|
||||
}
|
||||
|
||||
void EntityResource::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_dirty"), &EntityResource::get_dirty);
|
||||
ClassDB::bind_method(D_METHOD("set_dirty", "value"), &EntityResource::set_dirty);
|
||||
@ -210,7 +221,14 @@ void EntityResource::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_ons_added", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity")));
|
||||
BIND_VMETHOD(MethodInfo("_onc_added", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
BIND_VMETHOD(MethodInfo("_process_server", PropertyInfo(Variant::REAL, "delta")));
|
||||
BIND_VMETHOD(MethodInfo("_process_client", PropertyInfo(Variant::REAL, "delta")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("process_server", "delta"), &EntityResource::process_server);
|
||||
ClassDB::bind_method(D_METHOD("_process_server", "delta"), &EntityResource::_process_server);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("process_client", "delta"), &EntityResource::process_client);
|
||||
ClassDB::bind_method(D_METHOD("_process_client", "delta"), &EntityResource::_process_client);
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, "str"), "_gets_update_string"));
|
||||
BIND_VMETHOD(MethodInfo("_receivec_update_string", PropertyInfo(Variant::STRING, "str")));
|
||||
|
@ -42,10 +42,14 @@ public:
|
||||
void ons_target_changed(Entity *entity, Entity *old_target);
|
||||
void onc_target_changed(Entity *entity, Entity *old_target);
|
||||
|
||||
void process(float delta);
|
||||
void _process(float delta);
|
||||
void process_server(float delta);
|
||||
void _process_server(float delta);
|
||||
|
||||
String gets_update_string();
|
||||
void process_client(float delta);
|
||||
void _process_client(float delta);
|
||||
|
||||
void receivec_update(int current);
|
||||
void receivec_update_full(int current, int max);
|
||||
void receivec_update_string(String str);
|
||||
|
||||
void resolve_references();
|
||||
@ -57,11 +61,14 @@ public:
|
||||
void _from_dict(const Dictionary &dict);
|
||||
|
||||
EntityResource();
|
||||
~EntityResource();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
bool _server_side;
|
||||
|
||||
Entity *_owner;
|
||||
bool _dirty;
|
||||
bool _should_process;
|
||||
|
Loading…
Reference in New Issue
Block a user