From b88b25409b0b03f5f7f8a03a47f3b1bf81202b9f Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 14 Apr 2025 09:25:34 +0200 Subject: [PATCH] Now Entities can store their spawner's ObjectID. --- modules/entity_spell_system/entities/entity.cpp | 14 ++++++++++++++ modules/entity_spell_system/entities/entity.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/modules/entity_spell_system/entities/entity.cpp b/modules/entity_spell_system/entities/entity.cpp index 3f31cd440..768374aac 100644 --- a/modules/entity_spell_system/entities/entity.cpp +++ b/modules/entity_spell_system/entities/entity.cpp @@ -351,6 +351,14 @@ void Entity::setc_entity_type(int value) { _c_entity_type = value; } +// Owner Spawner information +ObjectID Entity::gets_spawner_object_id() const { + return _spawner_object_id; +} +void Entity::sets_spawner_object_id(const ObjectID p_object_id) { + _spawner_object_id = p_object_id; +} + //Relations EntityEnums::EntityRelationType Entity::gets_relation_to_bind(Node *to) { Entity *e = Object::cast_to(to); @@ -5866,6 +5874,8 @@ Entity::Entity() { _s_entity_type = 0; _c_entity_type = 0; + _spawner_object_id = ObjectID(); + _s_immunity_flags = 0; _s_entity_flags = 0; @@ -7177,6 +7187,10 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("setc_entity_type", "value"), &Entity::sets_entity_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "centity_type", PROPERTY_HINT_ENUM, "", 0), "setc_entity_type", "getc_entity_type"); + ClassDB::bind_method(D_METHOD("gets_spawner_object_id"), &Entity::gets_spawner_object_id); + ClassDB::bind_method(D_METHOD("sets_spawner_object_id", "object_id"), &Entity::sets_spawner_object_id); + ADD_PROPERTY(PropertyInfo(Variant::INT, "spawner_object_id", PROPERTY_HINT_OBJECT_ID, "", 0), "sets_spawner_object_id", "gets_spawner_object_id"); + ClassDB::bind_method(D_METHOD("ai_state_gets"), &Entity::ai_state_gets); ClassDB::bind_method(D_METHOD("ai_state_sets", "value"), &Entity::ai_state_sets); ADD_PROPERTY(PropertyInfo(Variant::INT, "ai_state", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_AI_STATES, PROPERTY_USAGE_ENTITY_HIDDEN), "ai_state_sets", "ai_state_gets"); diff --git a/modules/entity_spell_system/entities/entity.h b/modules/entity_spell_system/entities/entity.h index 0e88a70a4..32d450cce 100644 --- a/modules/entity_spell_system/entities/entity.h +++ b/modules/entity_spell_system/entities/entity.h @@ -278,6 +278,10 @@ public: int getc_entity_type(); void setc_entity_type(int value); + // Owner Spawner information + ObjectID gets_spawner_object_id() const; + void sets_spawner_object_id(const ObjectID p_object_id); + //Relations EntityEnums::EntityRelationType gets_relation_to_bind(Node *to); EntityEnums::EntityRelationType gets_relation_to(Entity *to); @@ -1209,6 +1213,8 @@ private: int _s_entity_type; int _c_entity_type; + ObjectID _spawner_object_id; + int _s_immunity_flags; int _s_entity_flags;