From 6c7f8625b5f8685cbf308c86b3d85a93a185049a Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 5 Aug 2021 21:55:33 +0200 Subject: [PATCH] Added interaction range check. --- game/scripts/entities/EntityDataGD.gd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/game/scripts/entities/EntityDataGD.gd b/game/scripts/entities/EntityDataGD.gd index b24e7b6c..3d63cf68 100644 --- a/game/scripts/entities/EntityDataGD.gd +++ b/game/scripts/entities/EntityDataGD.gd @@ -24,12 +24,17 @@ class_name EntityDataGD # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +const INTERACT_RANGE_SQUARED : int = 4 * 4 + func _sinteract(entity: Entity) -> void: var target : Entity = entity.gets_target() if target == null or not is_instance_valid(target): return + if (entity.get_body_3d().translation - target.get_body_3d().translation).length_squared() > INTERACT_RANGE_SQUARED: + return + if target.sentity_interaction_type == EntityEnums.ENITIY_INTERACTION_TYPE_LOOT: if target.gets_entity_data().loot_db != null and target.sbag == null: var ldb : LootDataBase = target.gets_entity_data().loot_db