summaryrefslogtreecommitdiff
path: root/Units
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-19 15:24:50 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-19 15:24:50 +0100
commit72863ffa31e27f4c6be862d80472cfb897fccaea (patch)
treece04be8d77b10c797c8ff854c8ff1a219eb1af46 /Units
parent63d2a59042fb9d90a586ad85d8364de7c38aea8e (diff)
next commitHEADmain
Diffstat (limited to 'Units')
-rw-r--r--Units/Unit.gd20
-rw-r--r--Units/unit_resource.gd7
2 files changed, 26 insertions, 1 deletions
diff --git a/Units/Unit.gd b/Units/Unit.gd
index b575e01..11115d3 100644
--- a/Units/Unit.gd
+++ b/Units/Unit.gd
@@ -53,6 +53,10 @@ var stuck_position_accumulator = 0.0
var roaming_mode = false
+var additional_data: Dictionary
+
+var unit_resource: UnitResource
+
# rpc owner id
@export var owner_id = 1
@@ -75,6 +79,11 @@ func _init():
func _ready():
+ if unit_resource:
+ $AnimatedSprite2D.sprite_frames = unit_resource.sprite_frames
+ base_speed = unit_resource.speed
+ hp = unit_resource.hp
+
base_speed *= scale.x
speed = base_speed
@@ -232,7 +241,7 @@ func get_effects():
func add_effect(effect: Effect):
var node = get_node_or_null(NodePath(effect.name)) as Effect
- if node:
+ if node and not node.is_stackable:
node.set_duration(node.duration)
else:
add_child(effect)
@@ -323,6 +332,9 @@ class NetworkData extends Resource:
var sprite_self_modulate: Color
var sprite_animation: StringName
var sprite_frame: int
+
+ var additional_data: Dictionary
+ var unit_resource: UnitResource
func to_network_data() -> NetworkData:
var data = NetworkData.new()
@@ -346,6 +358,9 @@ func to_network_data() -> NetworkData:
#data.sprite_animation = sprite.animation
#data.sprite_frame = sprite.frame
+ data.additional_data = additional_data
+ data.unit_resource = unit_resource
+
return data
@@ -382,4 +397,7 @@ static func from_network_data(data: NetworkData) -> Unit:
unit.sprite.sprite_frames = load(data.sprite_frames_path)
#unit.sprite.modulate = data.sprite_modulate
+ unit.additional_data = data.additional_data
+ unit.unit_resource = data.unit_resource
+
return unit
diff --git a/Units/unit_resource.gd b/Units/unit_resource.gd
new file mode 100644
index 0000000..f363d6f
--- /dev/null
+++ b/Units/unit_resource.gd
@@ -0,0 +1,7 @@
+class_name UnitResource
+extends Resource
+
+
+@export var sprite_frames: SpriteFrames
+@export var hp: int
+@export var speed: float