From 3e56b51c9bc191c1a77ba4ed68c19e5fe7b226fb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 Apr 2022 08:47:28 +0200 Subject: [PATCH] :wrench: Add utility static methods to `Alliance` --- src/entities/behaviours/Alliance.gd | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/entities/behaviours/Alliance.gd b/src/entities/behaviours/Alliance.gd index b8c5c28..7f677a6 100644 --- a/src/entities/behaviours/Alliance.gd +++ b/src/entities/behaviours/Alliance.gd @@ -1,10 +1,23 @@ extends Node +class_name Alliance -enum Alliance { +enum AllianceKind { ENEMY = -1, NONE = 0, PLAYER = 1, } -export(Alliance) var alliance: int +export(AllianceKind) var alliance: int + + +static func get_value(first) -> int: + var first_node = first.get_node("Alliance") + var first_alliance = null + if first_node != null: + first_alliance = first_node.alliance + return first_alliance + + +static func compare(first, second) -> bool: + return get_value(first) == get_value(second)