Now Entities can store their spawner's ObjectID.

This commit is contained in:
Relintai 2025-04-14 09:25:34 +02:00
parent 5c105a15fb
commit b88b25409b
2 changed files with 20 additions and 0 deletions

View File

@ -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<Entity>(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");

View File

@ -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;