Skip to content

Commit

Permalink
chore: deprecates get_kinematic_owner
Browse files Browse the repository at this point in the history
in favour of get_effect_owner
  • Loading branch information
OctoD committed Apr 19, 2022
1 parent c119147 commit cb26821
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Gameplay attributes are a set of nodes used to describe some
characters attributes for both 2D and 3D games made with Godot.

- [Gameplay Attributes](#gameplay-attributes)
- [⚔️ Gameplay Attributes ⚔️](#️-gameplay-attributes-️)
- [Install](#install)
- [How it works](#how-it-works)
- [Example: creating your first Attributes map](#example-creating-your-first-attributes-map)
Expand Down Expand Up @@ -259,10 +259,9 @@ If you need to notify the owning character, emit the signal `effect_applied`
This is where you setup your effect. It is called during the `_ready` function but only when in game.


**get_kinematic_owner**

Returns the `KinematicBody` or `KinematicBody3D` owner of the `GameplayAttributeMap` which contains the effect.
**get_effect_owner**

Returns the owner of the `GameplayAttributeMap` which contains the effect.


**`get_parent_attribute_map`**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ func _get_configuration_warning():
var parent = get_parent()
var is_editing = Engine.editor_hint

if parent != null and not (parent is KinematicBody or parent is KinematicBody2D) and is_editing:
_is_valid = false
return "GameplayAttributeMap must be direct child of a KinematicBody or KinematicBody2D"

if children.size() == 0:
_is_valid = false
return message
Expand Down
8 changes: 8 additions & 0 deletions addons/godot-gameplay-attributes/nodes/GameplayEffect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func _connect_to_parent_signal() -> void:
parent.connect("attribute_changed", self, "_on_attribute_changed")


func get_effect_owner():
var parent = get_parent_attribute_map()

if parent:
return parent.get_parent()


# deprecated, use get_effect_owner and cast properly instead
func get_kinematic_owner():
var parent = get_parent_attribute_map()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ func _get_configuration_warning():
var parent = get_parent()
var is_editing = Engine.editor_hint

if parent != null and not (parent is KinematicBody or parent is KinematicBody2D) and is_editing:
_is_valid = false
return "GameplayAttributeMap must be direct child of a KinematicBody or KinematicBody2D"

if children.size() == 0:
_is_valid = false
return message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func _connect_to_parent_signal() -> void:
parent.connect("attribute_changed", self, "_on_attribute_changed")


func get_effect_owner():
var parent = get_parent_attribute_map()

if parent:
return parent.get_parent()


# deprecated, use get_effect_owner and cast properly instead
func get_kinematic_owner():
var parent = get_parent_attribute_map()

Expand Down
9 changes: 2 additions & 7 deletions example/test.tscn
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-gameplay-attributes/nodes/GameplayAttributeMap.gd" type="Script" id=3]
[ext_resource path="res://addons/godot-gameplay-attributes/nodes/GameplayAttribute.gd" type="Script" id=5]
[ext_resource path="res://addons/godot-gameplay-attributes/premade_gameplay_effects/AttributeRegenGameplayEffect.gd" type="Script" id=6]

[sub_resource type="RectangleShape2D" id=1]

[node name="test" type="Node2D"]
script = ExtResource( 2 )

[node name="KinematicBody2D" type="KinematicBody2D" parent="."]
[node name="KinematicBody2D" type="Node2D" parent="."]

[node name="Camera2D" type="Camera2D" parent="KinematicBody2D"]
current = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
shape = SubResource( 1 )

[node name="Control" type="Control" parent="KinematicBody2D"]
anchor_left = 0.5
anchor_top = 0.5
Expand Down

0 comments on commit cb26821

Please sign in to comment.