aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/map/map.gd5
-rw-r--r--client/map/tiles/player_portal.gd9
-rw-r--r--client/map/tiles/portal.gd20
-rw-r--r--client/map/tiles/tile.gd6
-rw-r--r--data/maps/debug2.yaml2
5 files changed, 36 insertions, 6 deletions
diff --git a/client/map/map.gd b/client/map/map.gd
index 800cb57d..4dd76ec4 100644
--- a/client/map/map.gd
+++ b/client/map/map.gd
@@ -40,9 +40,10 @@ func get_tile_instance(pos: Vector2i) -> Tile:
else: return null
func set_tile(pos: Vector2i, tilename = null, neighbors: Array = [null,null,null,null]):
+ var inst = get_tile_instance(pos)
+ if inst and tilename: if inst.change(tilename): return # instance handled change itself
_remove_tile(pos)
- if tilename != null:
- _add_tile(pos, tilename, neighbors)
+ if tilename: _add_tile(pos, tilename, neighbors)
if autoflush: flush()
func _add_tile(pos: Vector2i, tilename: String, neighbors: Array) -> Tile:
diff --git a/client/map/tiles/player_portal.gd b/client/map/tiles/player_portal.gd
index e722a7ee..222f84ee 100644
--- a/client/map/tiles/player_portal.gd
+++ b/client/map/tiles/player_portal.gd
@@ -21,3 +21,12 @@ func _init(ctx: TileFactory.TileCC, type: bool):
super(ctx)
model.configure(0.4, type)
base.add_child(model)
+
+func change(tn: String) -> bool:
+ if tn == "white-hole":
+ model.target_type = 1.
+ return true
+ if tn == "black-hole":
+ model.target_type = -1.
+ return true
+ return false
diff --git a/client/map/tiles/portal.gd b/client/map/tiles/portal.gd
index 961a8615..75da4980 100644
--- a/client/map/tiles/portal.gd
+++ b/client/map/tiles/portal.gd
@@ -16,7 +16,21 @@
class_name PortalModel
extends Node3D
+var target_type = 0.
+var current_type = 0.
+var target_size = 0.
+var current_size = 0.
+var mat: ShaderMaterial
+
func configure(size: float, type: bool):
- var mat: ShaderMaterial = $Mesh.get_active_material(0)
- mat.set_shader_parameter("size", size)
- mat.set_shader_parameter("type", 1. if type else -1.)
+ mat = $Mesh.get_active_material(0)
+ target_type = 1. if type else -1.
+ target_size = size
+
+func _process(delta: float) -> void:
+ if abs(target_type - current_type) > 0.01:
+ current_type = G.interpolate(current_type, target_type, delta * 10.)
+ mat.set_shader_parameter("type", current_type)
+ if abs(target_size - current_size) > 0.01:
+ current_size = G.interpolate(current_size, target_size, delta * 3.)
+ mat.set_shader_parameter("size", current_size)
diff --git a/client/map/tiles/tile.gd b/client/map/tiles/tile.gd
index 27d791c3..b4928aa1 100644
--- a/client/map/tiles/tile.gd
+++ b/client/map/tiles/tile.gd
@@ -94,3 +94,9 @@ func take_item() -> Item:
func get_base_mesh():
return null
+
+# Called when about to be changed to different tile
+# returning false deletes the tile and replaces it normally
+# returning true means this function applies the change
+func change(_name: String) -> bool:
+ return false
diff --git a/data/maps/debug2.yaml b/data/maps/debug2.yaml
index fb5ca879..ea87df8b 100644
--- a/data/maps/debug2.yaml
+++ b/data/maps/debug2.yaml
@@ -19,8 +19,8 @@ map:
- "RRRHH+@@+D.............."
- "TTT+...................."
- "|||H...................."
- - "...~...................."
- "........................"
+ - "....~..................."
- "........................"
- "........................"
- "........................"