Skip to content

Commit

Permalink
fix: uses as instead of direct casting
Browse files Browse the repository at this point in the history
fixes issue with "Trying to assign value of type 'Node' to a variable of type 'GameplayAttributeMap.gd'."
  • Loading branch information
OctoD authored Jun 16, 2022
1 parent ff92321 commit 348d2a2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func connect_child_signals() -> void:


func get_attribute(attribute_name: String) -> GameplayAttribute:
var found: GameplayAttribute = find_node(attribute_name)
var found = find_node(attribute_name) as GameplayAttribute
return found


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func get_consume_per_second() -> float:


func apply_effect() -> void:
var parent: GameplayAttributeMap = get_parent_attribute_map()
var parent = get_parent_attribute_map() as GameplayAttributeMap

if parent:
var attribute: GameplayAttribute = parent.get_attribute(attribute_name)
var attribute = parent.get_attribute(attribute_name) as GameplayAttribute
if attribute and attribute.name == attribute_name:
attribute.current_value = clamp(attribute.current_value - abs(consume_per_second), 0, attribute.max_value)
emit_signal("effect_applied", self)
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ func _ready():


func apply_effect() -> void:
var parent: GameplayAttributeMap = get_parent_attribute_map()
var parent = get_parent_attribute_map() as GameplayAttributeMap

if parent:
var attribute: GameplayAttribute = parent.get_attribute(attribute_name)
var attribute = parent.get_attribute(attribute_name) as GameplayAttribute
if attribute and attribute.current_value < attribute.max_value and attribute.name == attribute_name:
attribute.current_value = clamp(attribute.current_value + increment_per_second, 0, attribute.max_value)
emit_signal("effect_applied", self)
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func should_deactivate() -> bool:
return true

func apply_effect() -> void:
var parent: GameplayAttributeMap = get_parent_attribute_map()
var parent = get_parent_attribute_map() as GameplayAttributeMap

if parent:
var attribute: GameplayAttribute = parent.get_attribute(attribute_name)
var attribute = parent.get_attribute(attribute_name) as GameplayAttribute
if attribute and attribute.name == attribute_name:
attribute.current_value = clamp(attribute.current_value - _get_damage(), 0, attribute.max_value)
emit_signal("effect_applied", self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func should_deactivate() -> bool:
return true

func apply_effect() -> void:
var parent: GameplayAttributeMap = get_parent_attribute_map()
var parent = get_parent_attribute_map() as GameplayAttributeMap

if parent:
var attribute: GameplayAttribute = parent.get_attribute(attribute_name)
var attribute = parent.get_attribute(attribute_name) as GameplayAttribute
if attribute and attribute.name == attribute_name:
attribute.current_value = clamp(attribute.current_value + value, 0, attribute.max_value)
emit_signal("effect_applied", self)

0 comments on commit 348d2a2

Please sign in to comment.