-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from OctoD/feat/previous-values-on-attribute-ch…
…anged Feat/previous values on attribute changed
- Loading branch information
Showing
35 changed files
with
990 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.import | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
extends DamageGameplayEffect | ||
class_name TestDamage | ||
|
||
func setup_effect() -> void: | ||
.setup_effect() | ||
attribute_name = "Health" | ||
damage_min = 5 | ||
damage_max = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends RestoreGameplayEffect | ||
class_name RestoreHealthEffect | ||
|
||
func setup_effect() -> void: | ||
.setup_effect() | ||
attribute_name = "Health" | ||
value = 10 |
Binary file added
BIN
+11.2 KB
example/addons/godot-gameplay-attributes/assets/GameplayAttributes.sketch
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
example/addons/godot-gameplay-attributes/assets/attribute_icon.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/attribute_icon.png-b2f25314d318c523571e1561cd1646ad.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-gameplay-attributes/assets/attribute_icon.png" | ||
dest_files=[ "res://.import/attribute_icon.png-b2f25314d318c523571e1561cd1646ad.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
Binary file added
BIN
+328 Bytes
example/addons/godot-gameplay-attributes/assets/damage_gameplay_effect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
example/addons/godot-gameplay-attributes/assets/damage_gameplay_effect.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/damage_gameplay_effect.png-fac0dcc8f7cb5414b375513d1f0685a2.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-gameplay-attributes/assets/damage_gameplay_effect.png" | ||
dest_files=[ "res://.import/damage_gameplay_effect.png-fac0dcc8f7cb5414b375513d1f0685a2.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
Binary file added
BIN
+416 Bytes
example/addons/godot-gameplay-attributes/assets/fall_gameplay_effect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
example/addons/godot-gameplay-attributes/assets/fall_gameplay_effect.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/fall_gameplay_effect.png-b7a50b15a461293cda46c20921a046aa.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-gameplay-attributes/assets/fall_gameplay_effect.png" | ||
dest_files=[ "res://.import/fall_gameplay_effect.png-b7a50b15a461293cda46c20921a046aa.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
Binary file added
BIN
+295 Bytes
example/addons/godot-gameplay-attributes/assets/restore_attribute_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
example/addons/godot-gameplay-attributes/assets/restore_attribute_icon.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/restore_attribute_icon.png-9af1ea74225417cfc555be54f7f9f70a.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-gameplay-attributes/assets/restore_attribute_icon.png" | ||
dest_files=[ "res://.import/restore_attribute_icon.png-9af1ea74225417cfc555be54f7f9f70a.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
example/addons/godot-gameplay-attributes/assets/timed_icon.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/timed_icon.png-c6a1a1379fcb51e63e380efcd0482704.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-gameplay-attributes/assets/timed_icon.png" | ||
dest_files=[ "res://.import/timed_icon.png-c6a1a1379fcb51e63e380efcd0482704.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
36 changes: 36 additions & 0 deletions
36
example/addons/godot-gameplay-attributes/gameplay_attributes.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
tool | ||
extends EditorPlugin | ||
|
||
|
||
func _enter_tree(): | ||
var attribute_node_icon = load("res://addons/godot-gameplay-attributes/assets/attribute_icon.png"); | ||
var gameplay_effect_icon = load("res://addons/godot-gameplay-attributes/assets/timed_icon.png") | ||
var damage_effect_icon = load("res://addons/godot-gameplay-attributes/assets/damage_gameplay_effect.png") | ||
var restore_effect_icon = load("res://addons/godot-gameplay-attributes/assets/restore_attribute_icon.png") | ||
|
||
# basenodes | ||
add_custom_type("GameplayAttributeMap", "Node", load("res://addons/godot-gameplay-attributes/nodes/GameplayAttributeMap.gd"), attribute_node_icon); | ||
add_custom_type("GameplayAttribute", "Node", load("res://addons/godot-gameplay-attributes/nodes/GameplayAttribute.gd"), attribute_node_icon); | ||
add_custom_type("GameplayEffect", "Node", load("res://addons/godot-gameplay-attributes/nodes/GameplayEffect.gd"), gameplay_effect_icon); | ||
add_custom_type("TimedGameplayEffect", "GameplayEffect", load("res://addons/godot-gameplay-attributes/nodes/TimedGameplayEffect.gd"), gameplay_effect_icon); | ||
|
||
# premade gameplay effects | ||
add_custom_type("AttributeConsumeGameplayEffect", "TimedGameplayEffect", load("res://addons/godot-gameplay-attributes/premade_gameplay_effects/AttributeConsumeGameplayEffect.gd"), gameplay_effect_icon); | ||
add_custom_type("AttributeRegenGameplayEffect", "TimedGameplayEffect", load("res://addons/godot-gameplay-attributes/premade_gameplay_effects/AttributeRegenGameplayEffect.gd"), gameplay_effect_icon); | ||
add_custom_type("DamageGameplayEffect", "GameplayEffect", load("res://addons/godot-gameplay-attributes/premade_gameplay_effects/DamageGameplayEffect.gd"), damage_effect_icon); | ||
add_custom_type("RestoreGameplayEffect", "GameplayEffect", load("res://addons/godot-gameplay-attributes/premade_gameplay_effects/RestoreGameplayEffect.gd"), restore_effect_icon); | ||
|
||
|
||
func _exit_tree(): | ||
# basenodes | ||
|
||
remove_custom_type("GameplayAttribute") | ||
remove_custom_type("GameplayAttributeMap") | ||
remove_custom_type("GameplayEffect") | ||
remove_custom_type("TimedGameplayEffect") | ||
|
||
# premade gameplay effects | ||
remove_custom_type("AttributeConsumeGameplayEffect") | ||
remove_custom_type("AttributeRegenGameplayEffect") | ||
remove_custom_type("DamageGameplayEffect") | ||
remove_custom_type("RestoreGameplayEffect") |
52 changes: 52 additions & 0 deletions
52
example/addons/godot-gameplay-attributes/nodes/GameplayAttribute.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
tool | ||
extends Node | ||
class_name GameplayAttribute | ||
|
||
|
||
export(float) var max_value = 0.0 setget set_max_value, get_max_value | ||
export(float) var current_value = 0.0 setget set_current_value, get_current_value | ||
|
||
|
||
signal attribute_changed | ||
|
||
|
||
func get_current_value() -> float: | ||
return current_value | ||
|
||
|
||
func get_max_value() -> float: | ||
return max_value | ||
|
||
|
||
func set_current_value(value: float) -> void: | ||
var prev_max = max_value | ||
var prev_value = current_value | ||
current_value = clamp(value, 0, max_value) | ||
emit_signal("attribute_changed", { | ||
"prev_max": prev_max, | ||
"prev_value": prev_value, | ||
"current_max": max_value, | ||
"current_value": current_value, | ||
"name": self.name | ||
}) | ||
|
||
|
||
func set_max_value(value: float) -> void: | ||
if value >= 0: | ||
var prev_value = current_value | ||
var prev_max = max_value | ||
max_value = value | ||
emit_signal("attribute_changed", { | ||
"prev_max": prev_max, | ||
"prev_value": prev_value, | ||
"current_max": max_value, | ||
"current_value": current_value, | ||
"name": self.name | ||
}) | ||
|
||
|
||
func _get_configuration_warning(): | ||
if get_parent().has_signal("attribute_changed"): | ||
return "" | ||
|
||
return "GameplayAttribute must be a direct child of a GameplayAttributeMap node." |
Oops, something went wrong.