Added interaction range check.

This commit is contained in:
Relintai 2021-08-05 21:55:33 +02:00
parent fd42c5e8e6
commit 6c7f8625b5

View File

@ -24,12 +24,17 @@ class_name EntityDataGD
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
const INTERACT_RANGE_SQUARED : int = 4 * 4
func _sinteract(entity: Entity) -> void: func _sinteract(entity: Entity) -> void:
var target : Entity = entity.gets_target() var target : Entity = entity.gets_target()
if target == null or not is_instance_valid(target): if target == null or not is_instance_valid(target):
return 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.sentity_interaction_type == EntityEnums.ENITIY_INTERACTION_TYPE_LOOT:
if target.gets_entity_data().loot_db != null and target.sbag == null: if target.gets_entity_data().loot_db != null and target.sbag == null:
var ldb : LootDataBase = target.gets_entity_data().loot_db var ldb : LootDataBase = target.gets_entity_data().loot_db