summaryrefslogtreecommitdiff
path: root/Units
diff options
context:
space:
mode:
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