feat: implement Tekton NPC with movement, combat, and interaction mechanics, and add initial portal system components.

This commit is contained in:
2026-02-27 04:29:02 +08:00
parent 38a7c06311
commit 1c5c3d47f6
3 changed files with 77 additions and 10 deletions
+11 -7
View File
@@ -196,7 +196,7 @@ var original_scales: Array[Vector3] = []
func _ready():
# Cache meshes and their initial scales
_cache_meshes(self)
_cache_meshes(self )
func _cache_meshes(node: Node):
if node is MeshInstance3D:
@@ -257,7 +257,7 @@ func on_thrown_landing(attacker: Node = null, intensity: float = 1.0):
# Spawn tiles (as requested "tekton will spawn a tiles around that floor also")
if is_multiplayer_authority():
spawn_tiles_around(int(8 * intensity))
spawn_tiles_around(int(8 * intensity))
# Floor Freeze (Visual/Instant - Run on all clients locally)
temporarily_change_floor(current_position, 1, 6, 3.0)
@@ -281,7 +281,6 @@ func on_thrown_landing(attacker: Node = null, intensity: float = 1.0):
controller._start_timer()
func temporarily_change_floor(center: Vector2i, radius: int, new_id: int, duration: float):
if not enhanced_gridmap: return
@@ -372,6 +371,11 @@ func spawn_tiles_around(count: int = 4):
continue
if enhanced_gridmap.is_position_valid(pos):
# EXTRA CHECK: Do not spawn tiles on walls (ID 4) or empty void (ID -1) on Floor 0
var floor_0_item = enhanced_gridmap.get_cell_item(Vector3i(pos.x, 0, pos.y))
if floor_0_item == 4 or floor_0_item == -1:
continue
# 50% chance to spawn something
if rng.randf() > 0.5: continue
@@ -403,14 +407,14 @@ func play_animation_rpc(anim_name: String):
func spawn_projectile_rpc(target_pos: Vector3, duration: float):
var projectile = MeshInstance3D.new()
var box = BoxMesh.new()
box.size = Vector3(0.4, 0.1, 0.4)
box.size = Vector3(0.4, 0.1, 0.4)
projectile.mesh = box
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(1, 0.5, 0) # Orange
projectile.material_override = mat
get_parent().add_child(projectile)
projectile.global_position = global_position + Vector3(0, 2.0, 0)
projectile.global_position = global_position + Vector3(0, 2.0, 0)
var tween = create_tween()
tween.set_parallel(true)
@@ -419,8 +423,8 @@ func spawn_projectile_rpc(target_pos: Vector3, duration: float):
var mid_y = max(global_position.y, target_pos.y) + 3.0
var tween_y = create_tween()
tween_y.tween_property(projectile, "global_position:y", mid_y, duration/2).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT)
tween_y.tween_property(projectile, "global_position:y", target_pos.y, duration/2).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN).set_delay(duration/2)
tween_y.tween_property(projectile, "global_position:y", mid_y, duration / 2).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT)
tween_y.tween_property(projectile, "global_position:y", target_pos.y, duration / 2).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN).set_delay(duration / 2)
tween.chain().tween_callback(projectile.queue_free)