mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
implemented equipslots.
This commit is contained in:
parent
bbb92b244d
commit
26ba90a9d3
@ -1,7 +1,7 @@
|
||||
#include "item_template.h"
|
||||
|
||||
#include "item_instance.h"
|
||||
#include "aura.h"
|
||||
#include "item_instance.h"
|
||||
#include "spell.h"
|
||||
|
||||
int ItemTemplate::get_id() const {
|
||||
@ -46,6 +46,13 @@ void ItemTemplate::set_rarity(const ItemEnums::ItemRarity value) {
|
||||
_rarity = value;
|
||||
}
|
||||
|
||||
ItemEnums::EquipSlots ItemTemplate::get_equip_slot() const {
|
||||
return _equip_slot;
|
||||
}
|
||||
void ItemTemplate::set_equip_slot(const ItemEnums::EquipSlots value) {
|
||||
_equip_slot = value;
|
||||
}
|
||||
|
||||
Ref<ItemVisual> ItemTemplate::get_item_visual() const {
|
||||
return _item_visual;
|
||||
}
|
||||
@ -67,7 +74,7 @@ int ItemTemplate::get_stack_size() const {
|
||||
void ItemTemplate::set_stack_size(const int value) {
|
||||
_stack_size = value;
|
||||
}
|
||||
|
||||
|
||||
Ref<Texture> ItemTemplate::get_icon() const {
|
||||
return _icon;
|
||||
}
|
||||
@ -341,13 +348,14 @@ ItemTemplate::ItemTemplate() {
|
||||
_item_sub_type = ItemEnums::ITEM_SUB_TYPE_NONE;
|
||||
_item_sub_sub_type = ItemEnums::ITEM_SUB_SUB_TYPE_NONE;
|
||||
_rarity = ItemEnums::ITEM_RARITY_NONE;
|
||||
_equip_slot = ItemEnums::EQUIP_SLOT_NONE;
|
||||
_price = 0;
|
||||
|
||||
_scale_x = 0;
|
||||
_scale_y = 0;
|
||||
_scale_z = 0;
|
||||
_modifier_count = 0;
|
||||
|
||||
|
||||
_stack_size = 1;
|
||||
_bag_size = 0;
|
||||
|
||||
@ -374,7 +382,7 @@ void ItemTemplate::_validate_property(PropertyInfo &property) const {
|
||||
|
||||
void ItemTemplate::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_create_item_instance"));
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("create_item_instance"), &ItemTemplate::create_item_instance);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &ItemTemplate::get_id);
|
||||
@ -401,6 +409,10 @@ void ItemTemplate::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_rarity", "count"), &ItemTemplate::set_rarity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rarity", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_RARITY), "set_rarity", "get_rarity");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_equip_slot"), &ItemTemplate::get_equip_slot);
|
||||
ClassDB::bind_method(D_METHOD("set_equip_slot", "count"), &ItemTemplate::set_equip_slot);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "equip_slot", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_EQUIP_SLOTS), "set_equip_slot", "get_equip_slot");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_price"), &ItemTemplate::get_price);
|
||||
ClassDB::bind_method(D_METHOD("set_price", "count"), &ItemTemplate::set_price);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "price"), "set_price", "get_price");
|
||||
@ -412,7 +424,7 @@ void ItemTemplate::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stack_size"), &ItemTemplate::get_stack_size);
|
||||
ClassDB::bind_method(D_METHOD("set_stack_size", "value"), &ItemTemplate::set_stack_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "stack_size"), "set_stack_size", "get_stack_size");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_icon"), &ItemTemplate::get_icon);
|
||||
ClassDB::bind_method(D_METHOD("set_icon", "value"), &ItemTemplate::set_icon);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_icon", "get_icon");
|
||||
@ -433,7 +445,6 @@ void ItemTemplate::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_bag_size", "size"), &ItemTemplate::set_bag_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "bag_size"), "set_bag_size", "get_bag_size");
|
||||
|
||||
|
||||
//// Teaches ////
|
||||
ADD_GROUP("Teaches Spells", "teaches_spells");
|
||||
ClassDB::bind_method(D_METHOD("get_num_teaches_spells"), &ItemTemplate::get_num_teaches_spells);
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
ItemEnums::ItemRarity get_rarity() const;
|
||||
void set_rarity(const ItemEnums::ItemRarity value);
|
||||
|
||||
ItemEnums::EquipSlots get_equip_slot() const;
|
||||
void set_equip_slot(const ItemEnums::EquipSlots value);
|
||||
|
||||
Ref<ItemVisual> get_item_visual() const;
|
||||
void set_item_visual(const Ref<ItemVisual> value);
|
||||
|
||||
@ -142,6 +145,7 @@ private:
|
||||
ItemEnums::ItemType _item_type;
|
||||
ItemEnums::ItemSubtype _item_sub_type;
|
||||
ItemEnums::ItemSubSubtype _item_sub_sub_type;
|
||||
ItemEnums::EquipSlots _equip_slot;
|
||||
|
||||
int _price;
|
||||
|
||||
|
@ -313,6 +313,10 @@ Dictionary Entity::_to_dict() {
|
||||
|
||||
dict["stats"] = sd;
|
||||
|
||||
//// Equipment ////
|
||||
|
||||
//todo
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Dictionary rd;
|
||||
@ -443,6 +447,10 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
s->from_dict(stats.get(String::num(i), Dictionary()));
|
||||
}
|
||||
|
||||
//// Equipment ////
|
||||
|
||||
//todo
|
||||
|
||||
//// Resources ////
|
||||
|
||||
_s_resources.clear();
|
||||
@ -821,6 +829,14 @@ Entity::~Entity() {
|
||||
|
||||
_s_talents.clear();
|
||||
_c_talents.clear();
|
||||
|
||||
for (int i = 0; i < Stat::STAT_ID_TOTAL_STATS; ++i) {
|
||||
_stats[i].unref();
|
||||
}
|
||||
|
||||
for (int i = 0; i < ItemEnums::EQUIP_SLOT_EQUIP_SLOT_MAX; ++i) {
|
||||
_equipment[i].unref();
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::initialize(Ref<EntityCreateInfo> info) {
|
||||
@ -1042,6 +1058,21 @@ void Entity::onc_stat_changed(Ref<Stat> stat) {
|
||||
}
|
||||
}
|
||||
|
||||
//// Equip Slots ////
|
||||
|
||||
Ref<ItemInstance> Entity::equip(Ref<ItemInstance> item) {
|
||||
if (!has_method("_equip")) {
|
||||
return item;
|
||||
}
|
||||
|
||||
return call("_equip", item);
|
||||
}
|
||||
Ref<ItemInstance> Entity::get_equip_slot(int index) {
|
||||
ERR_FAIL_INDEX_V(index, ItemEnums::EQUIP_SLOT_EQUIP_SLOT_MAX, Ref<ItemInstance>());
|
||||
|
||||
return _equipment[index];
|
||||
}
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Ref<EntityResource> Entity::gets_resource(int index) {
|
||||
@ -4355,6 +4386,15 @@ 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);
|
||||
|
||||
//Equipment System
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"), "_equip", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("equipment_changed", PropertyInfo(Variant::INT, "slot")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("equip", "item"), &Entity::equip);
|
||||
ClassDB::bind_method(D_METHOD("get_equip_slot", "index"), &Entity::get_equip_slot);
|
||||
|
||||
//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);
|
||||
|
@ -238,6 +238,11 @@ public:
|
||||
void ons_stat_changed(Ref<Stat> stat);
|
||||
void onc_stat_changed(Ref<Stat> stat);
|
||||
|
||||
//// Equip Slots ////
|
||||
|
||||
Ref<ItemInstance> equip(Ref<ItemInstance> item);
|
||||
Ref<ItemInstance> get_equip_slot(int index);
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Ref<EntityResource> gets_resource(int index);
|
||||
@ -254,7 +259,8 @@ public:
|
||||
void removec_resource(int index);
|
||||
void clearc_resource();
|
||||
|
||||
//GCD
|
||||
//// Global Cooldown ////
|
||||
|
||||
bool getc_has_global_cooldown();
|
||||
bool gets_has_global_cooldown();
|
||||
bool getc_global_cooldown();
|
||||
@ -691,6 +697,10 @@ private:
|
||||
|
||||
Ref<Stat> _stats[Stat::STAT_ID_TOTAL_STATS];
|
||||
|
||||
//// Equipment ////
|
||||
|
||||
Ref<ItemInstance> _equipment[ItemEnums::EQUIP_SLOT_EQUIP_SLOT_MAX];
|
||||
|
||||
//// Resources ////
|
||||
|
||||
Vector<Ref<EntityResource> > _s_resources;
|
||||
@ -707,10 +717,12 @@ private:
|
||||
float cRezTimer;
|
||||
|
||||
//// GCD ////
|
||||
|
||||
float _s_gcd;
|
||||
float _c_gcd;
|
||||
|
||||
//// States ////
|
||||
|
||||
int _s_states[EntityEnums::ENTITY_STATE_TYPE_INDEX_MAX];
|
||||
|
||||
int _s_state;
|
||||
@ -777,10 +789,12 @@ private:
|
||||
Vector<Ref<Spell> > _c_spells;
|
||||
|
||||
//// Skills ////
|
||||
|
||||
Vector<Ref<EntitySkill> > _s_skills;
|
||||
Vector<Ref<EntitySkill> > _c_skills;
|
||||
|
||||
//// Stat Allocations ////
|
||||
|
||||
//int _unallocated_stats;
|
||||
//int _stat_allocations[Stat::STAT_ID_TOTAL_STATS];
|
||||
|
||||
|
@ -7,3 +7,5 @@ const String ItemEnums::BINDING_STRING_ITEM_TYPE = "None,Equipment,Weapon,Potion
|
||||
const String ItemEnums::BINDING_STRING_ITEM_TYPE_FLAGS = "Equipment,Weapon,Potion,Herb,Ore,Gemstone,Food,Alchemy,Engineering,Enchanting,Tailoring,Recipe,Currency,Bag";
|
||||
const String ItemEnums::BINDING_STRING_ITEM_SUB_TYPE = "None,Sword,Axe,Mace,Dagger,Bow,Crossbow,Gun,Quest Item";
|
||||
const String ItemEnums::BINDING_STRING_ITEM_SUB_SUB_TYPE = "None,Two Hand,One Hand,Left Hand,Right Hand";
|
||||
const String ItemEnums::BINDING_STRING_EQUIP_SLOTS = "Head,Neck,Shoulders,Chest,Gloves,Belt,Legs,Feet,Ring 1,Ring 2,Trinket 1,Trinket 2,Main Hand,Off Hand,None";
|
||||
|
||||
|
46
item_enums.h
46
item_enums.h
@ -13,6 +13,7 @@ public:
|
||||
static const String BINDING_STRING_ITEM_TYPE_FLAGS;
|
||||
static const String BINDING_STRING_ITEM_SUB_TYPE;
|
||||
static const String BINDING_STRING_ITEM_SUB_SUB_TYPE;
|
||||
static const String BINDING_STRING_EQUIP_SLOTS;
|
||||
|
||||
enum ItemRarity {
|
||||
ITEM_RARITY_NONE = 0,
|
||||
@ -72,6 +73,29 @@ public:
|
||||
ITEM_SUB_SUB_TYPE_RIGHT_HAND
|
||||
};
|
||||
|
||||
enum EquipSlots {
|
||||
EQUIP_SLOT_HEAD = 0,
|
||||
EQUIP_SLOT_NECK = 1,
|
||||
EQUIP_SLOT_SHOULDERS = 2,
|
||||
EQUIP_SLOT_CHEST = 3,
|
||||
EQUIP_SLOT_GLOVES = 4,
|
||||
EQUIP_SLOT_BELT = 5,
|
||||
EQUIP_SLOT_LEGS = 6,
|
||||
EQUIP_SLOT_FEET = 7,
|
||||
|
||||
EQUIP_SLOT_RING_1 = 8,
|
||||
EQUIP_SLOT_RING_2 = 9,
|
||||
|
||||
EQUIP_SLOT_TRINKET_1 = 10,
|
||||
EQUIP_SLOT_TRINKET_2 = 11,
|
||||
|
||||
EQUIP_SLOT_MAIN_HAND = 12,
|
||||
EQUIP_SLOT_OFF_HAND = 13,
|
||||
|
||||
EQUIP_SLOT_EQUIP_SLOT_MAX = 14,
|
||||
EQUIP_SLOT_NONE = 14
|
||||
};
|
||||
|
||||
ItemEnums() {}
|
||||
|
||||
protected:
|
||||
@ -123,6 +147,27 @@ protected:
|
||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_ONE_HAND);
|
||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_LEFT_HAND);
|
||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_RIGHT_HAND);
|
||||
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_HEAD);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_NECK);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_SHOULDERS);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_CHEST);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_GLOVES);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_BELT);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_LEGS);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_FEET);
|
||||
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_RING_1);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_RING_2);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_TRINKET_1);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_TRINKET_2);
|
||||
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_MAIN_HAND);
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_OFF_HAND);
|
||||
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_NONE);
|
||||
|
||||
BIND_ENUM_CONSTANT(EQUIP_SLOT_EQUIP_SLOT_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
@ -131,6 +176,7 @@ VARIANT_ENUM_CAST(ItemEnums::ItemRarityFlag);
|
||||
VARIANT_ENUM_CAST(ItemEnums::ItemType);
|
||||
VARIANT_ENUM_CAST(ItemEnums::ItemSubtype);
|
||||
VARIANT_ENUM_CAST(ItemEnums::ItemSubSubtype);
|
||||
VARIANT_ENUM_CAST(ItemEnums::EquipSlots);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user