Refactor player animation and collision based entrances
This commit is contained in:
@@ -486,6 +486,6 @@ animations = [{
|
||||
|
||||
[node name="Sprite" type="AnimatedSprite2D" unique_id=1296959783]
|
||||
sprite_frames = SubResource("SpriteFrames_jqxwg")
|
||||
animation = &"opening-chest-down"
|
||||
animation = &"idle-down"
|
||||
autoplay = "idle-down"
|
||||
script = ExtResource("1_jqxwg")
|
||||
|
||||
@@ -15,7 +15,6 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
print("Walking State Entered")
|
||||
_queued_dv = _extra_parameters["dv"]
|
||||
StartedWalking.emit()
|
||||
|
||||
|
||||
@@ -1,38 +1,3 @@
|
||||
extends AnimatedSprite2D
|
||||
class_name PlayerSprite
|
||||
|
||||
# Signals
|
||||
signal DrawingBowAnimationFinished
|
||||
signal FiringArrowAnimationFinished
|
||||
signal AnimationFinished(animation_name: String)
|
||||
|
||||
# Private Variables
|
||||
var _current_animation := "idle-down"
|
||||
var _is_flipped := false
|
||||
|
||||
# Public Methods
|
||||
func OnAnimationFinished() -> void:
|
||||
if _current_animation.begins_with("drawing-bow-"):
|
||||
DrawingBowAnimationFinished.emit()
|
||||
elif _current_animation.begins_with("firing-arrow-"):
|
||||
FiringArrowAnimationFinished.emit()
|
||||
AnimationFinished.emit(_current_animation)
|
||||
|
||||
|
||||
func PlaySpecifiedAnimation(animation_name: String) -> void:
|
||||
_current_animation = animation_name
|
||||
animation = animation_name
|
||||
play()
|
||||
|
||||
|
||||
func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String:
|
||||
# e.g. "idle-down", "walking-up"
|
||||
var state_str := state.GetAnimationBaseName().replace("_", "-")
|
||||
var direction_str := _direction_to_animation_state(direction)
|
||||
return "%s-%s" % [state_str, direction_str]
|
||||
|
||||
|
||||
func _direction_to_animation_state(direction: Enums.Directions) -> String:
|
||||
if direction == Enums.Directions.LEFT or direction == Enums.Directions.RIGHT:
|
||||
return "side"
|
||||
return Enums.Directions.keys()[direction].to_lower()
|
||||
# sprite.gd
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
extends Node
|
||||
|
||||
# sprite_animation_changer.gd
|
||||
|
||||
# When the player actually changes state or direction, this component will decide
|
||||
# which sprite animation should play
|
||||
|
||||
@export var sprite: AnimatedSprite2D
|
||||
|
||||
var _cached_dv: Vector2
|
||||
var _cached_state: PlayerStateMachine.States
|
||||
|
||||
var _walking_animation_data = {
|
||||
Vector2.LEFT: ["walking-side", true],
|
||||
Vector2.RIGHT: ["walking-side", false],
|
||||
Vector2.UP: ["walking-up", false],
|
||||
Vector2.DOWN: ["walking-down", false]
|
||||
}
|
||||
|
||||
var _idle_animation_data = {
|
||||
Vector2.LEFT: ["idle-side", true],
|
||||
Vector2.RIGHT: ["idle-side", false],
|
||||
Vector2.UP: ["idle-up", false],
|
||||
Vector2.DOWN: ["idle-down", false]
|
||||
}
|
||||
|
||||
func OnStateChanged(to_state: PlayerStateMachine.States, _from_state: PlayerStateMachine.States) -> void:
|
||||
_cached_state = to_state
|
||||
if to_state == PlayerStateMachine.States.WALKING:
|
||||
_to_walking_state()
|
||||
return
|
||||
if to_state == PlayerStateMachine.States.IDLE:
|
||||
_to_idle_state()
|
||||
return
|
||||
|
||||
|
||||
func OnMovementQueued(dv: Vector2) -> void:
|
||||
_cached_dv = Vector2Utils.GetClosestDirectionVector(dv)
|
||||
|
||||
if _cached_state == PlayerStateMachine.States.WALKING:
|
||||
# Direction changed while walking, update animation, just run _to_walking_state again
|
||||
_to_walking_state()
|
||||
|
||||
|
||||
func _to_walking_state() -> void:
|
||||
if _walking_animation_data.has(_cached_dv):
|
||||
var animation_data = _walking_animation_data[_cached_dv]
|
||||
var animation_name = animation_data[0] as String
|
||||
var is_flipped = animation_data[1] as bool
|
||||
|
||||
sprite.animation = animation_name
|
||||
sprite.flip_h = is_flipped
|
||||
sprite.play()
|
||||
|
||||
|
||||
func _to_idle_state() -> void:
|
||||
if _idle_animation_data.has(_cached_dv):
|
||||
var animation_data = _idle_animation_data[_cached_dv]
|
||||
var animation_name = animation_data[0] as String
|
||||
var is_flipped = animation_data[1] as bool
|
||||
|
||||
sprite.animation = animation_name
|
||||
sprite.flip_h = is_flipped
|
||||
sprite.play()
|
||||
@@ -0,0 +1 @@
|
||||
uid://by3g7ne2b3lgi
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Node
|
||||
class_name PlayerStateMachine
|
||||
|
||||
signal StateChanged
|
||||
signal StateChanged(to_state: States, from_state: States)
|
||||
|
||||
enum States {
|
||||
UNSET, IDLE, WALKING, USING_ITEM_A, DRAWING_BOW, FIRING_ARROW,
|
||||
@@ -52,6 +52,9 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
func _swap_state() -> void:
|
||||
var from_state := current_state.GetStateEnum()
|
||||
var to_state := queued_state
|
||||
|
||||
if current_state:
|
||||
current_state.Exit()
|
||||
|
||||
@@ -60,4 +63,4 @@ func _swap_state() -> void:
|
||||
queued_state = PlayerStateMachine.States.UNSET
|
||||
queued_parameters = {}
|
||||
|
||||
StateChanged.emit()
|
||||
StateChanged.emit(to_state, from_state)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://nbkisxm2oekn" path="res://Entities/Characters/Utility/Components/movement_component.tscn" id="5_h314u"]
|
||||
[ext_resource type="Script" uid="uid://bwmmah30t3m0u" path="res://Entities/Characters/Player/Scripts/States/walking_state.gd" id="5_rg3km"]
|
||||
[ext_resource type="Script" uid="uid://ctoxjn2rvtjs6" path="res://Entities/Characters/Player/Scripts/state_event_connector.gd" id="6_18fwg"]
|
||||
[ext_resource type="Script" uid="uid://by3g7ne2b3lgi" path="res://Entities/Characters/Player/Scripts/sprite_animation_changer.gd" id="8_bm64c"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_62n52"]
|
||||
size = Vector2(13, 9)
|
||||
@@ -15,6 +16,7 @@ size = Vector2(13, 9)
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Player Body" parent="." unique_id=1502234578 instance=ExtResource("1_62n52")]
|
||||
collision_layer = 17
|
||||
|
||||
[node name="Sprite" parent="Player Body" unique_id=1169131604 instance=ExtResource("2_1uhri")]
|
||||
position = Vector2(0, 7)
|
||||
@@ -39,11 +41,17 @@ state_machine = NodePath("..")
|
||||
|
||||
[node name="Movement Component" parent="." unique_id=737644583 instance=ExtResource("5_h314u")]
|
||||
|
||||
[node name="Internal (Code Here)" type="Node" parent="." unique_id=95043416]
|
||||
[node name="Internal" type="Node" parent="." unique_id=95043416]
|
||||
|
||||
[node name="State Event Connector" type="Node" parent="Internal (Code Here)" unique_id=186266500 node_paths=PackedStringArray("state_machine")]
|
||||
[node name="State Event Connector" type="Node" parent="Internal" unique_id=186266500 node_paths=PackedStringArray("state_machine")]
|
||||
script = ExtResource("6_18fwg")
|
||||
state_machine = NodePath("../../State Machine")
|
||||
|
||||
[connection signal="MovementQueued" from="Movement Component" to="Internal (Code Here)/State Event Connector" method="OnMovementQueued"]
|
||||
[connection signal="NoMovementQueued" from="Movement Component" to="Internal (Code Here)/State Event Connector" method="OnNoMovementQueued"]
|
||||
[node name="Sprite Animation Changer" type="Node" parent="Internal" unique_id=281485983 node_paths=PackedStringArray("sprite")]
|
||||
script = ExtResource("8_bm64c")
|
||||
sprite = NodePath("../../Player Body/Sprite")
|
||||
|
||||
[connection signal="StateChanged" from="State Machine" to="Internal/Sprite Animation Changer" method="OnStateChanged"]
|
||||
[connection signal="MovementQueued" from="Movement Component" to="Internal/State Event Connector" method="OnMovementQueued"]
|
||||
[connection signal="MovementQueued" from="Movement Component" to="Internal/Sprite Animation Changer" method="OnMovementQueued"]
|
||||
[connection signal="NoMovementQueued" from="Movement Component" to="Internal/State Event Connector" method="OnNoMovementQueued"]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
extends Node
|
||||
@@ -1 +0,0 @@
|
||||
uid://ckfuj0lm6jv3i
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Node
|
||||
class_name LoadingZoneTransporter
|
||||
class_name EntranceTransporter
|
||||
|
||||
signal MapTransitionQueued(map_id: Enums.MapIds, marker_name: String)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://bqedrioybnvi5
|
||||
@@ -1,8 +1,8 @@
|
||||
extends Area2D
|
||||
class_name InteractiveLoadingZone
|
||||
class_name InteractiveEntrance
|
||||
|
||||
@export var loading_zone_transporter: LoadingZoneTransporter
|
||||
@export var entrance_transporter: EntranceTransporter
|
||||
|
||||
# Public Methods
|
||||
func Activate() -> void:
|
||||
loading_zone_transporter.Activate()
|
||||
entrance_transporter.Activate()
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
uid://bvl1vdqd5cjkc
|
||||
@@ -1,9 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://ca75b65eh7vv8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ckfuj0lm6jv3i" path="res://Entities/Map Objects/Loading Zone/Scripts/collision_loading_zone.gd" id="1_pb5hg"]
|
||||
[gd_scene format=3 uid="uid://dq6ifketavnfu"]
|
||||
|
||||
[node name="Collision Loading Zone" type="Area2D" unique_id=1043800735 groups=["Collision Loading Zone Group"]]
|
||||
collision_layer = 0
|
||||
script = ExtResource("1_pb5hg")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://bbules4o3xayc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bqedrioybnvi5" path="res://Entities/Map Objects/Loading Zone/Scripts/entrance_transporter.gd" id="1_bkamm"]
|
||||
|
||||
[node name="Entrance Transporter" type="Node" unique_id=1690817663 groups=["Loading Zone Transporter Group"]]
|
||||
script = ExtResource("1_bkamm")
|
||||
@@ -1,6 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://bbules4o3xayc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bvl1vdqd5cjkc" path="res://Entities/Map Objects/Loading Zone/Scripts/loading_zone_transporter.gd" id="1_p8o2m"]
|
||||
|
||||
[node name="Loading Zone Transporter" type="Node" unique_id=1690817663 groups=["Loading Zone Transporter Group"]]
|
||||
script = ExtResource("1_p8o2m")
|
||||
4
Entities/Map Objects/Triggers/on_collision_trigger.tscn
Normal file
4
Entities/Map Objects/Triggers/on_collision_trigger.tscn
Normal file
@@ -0,0 +1,4 @@
|
||||
[gd_scene format=3 uid="uid://vc0dkptkr1ow"]
|
||||
|
||||
[node name="On Collision Trigger" type="Area2D" unique_id=895298999]
|
||||
collision_layer = 0
|
||||
@@ -11,23 +11,23 @@ func GetAllTreasureChests() -> Array[BaseChest]:
|
||||
return arr
|
||||
|
||||
|
||||
func GetAllInteractiveLoadingZones() -> Array[InteractiveLoadingZone]:
|
||||
func GetAllInteractiveEntrances() -> Array[InteractiveEntrance]:
|
||||
var nodes := get_tree().get_nodes_in_group("Interactive Loading Zone Group")
|
||||
var arr: Array[InteractiveLoadingZone] = []
|
||||
var arr: Array[InteractiveEntrance] = []
|
||||
|
||||
for node in nodes:
|
||||
if node is InteractiveLoadingZone:
|
||||
if node is InteractiveEntrance:
|
||||
arr.append(node)
|
||||
|
||||
return arr
|
||||
|
||||
|
||||
func GetAllLoadingZoneTransporters() -> Array[LoadingZoneTransporter]:
|
||||
func GetAllLoadingZoneTransporters() -> Array[EntranceTransporter]:
|
||||
var nodes := get_tree().get_nodes_in_group("Loading Zone Transporter Group")
|
||||
var arr: Array[LoadingZoneTransporter] = []
|
||||
var arr: Array[EntranceTransporter] = []
|
||||
|
||||
for node in nodes:
|
||||
if node is LoadingZoneTransporter:
|
||||
if node is EntranceTransporter:
|
||||
arr.append(node)
|
||||
|
||||
return arr
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
[ext_resource type="Texture2D" uid="uid://hop1gedjh8s4" path="res://Assets/Spritesheets/Player/icons_full_32.png" id="4_r8s0p"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/Individual Components/body.tscn" id="5_6ky6i"]
|
||||
[ext_resource type="Texture2D" uid="uid://crebnygky3qv0" path="res://Assets/Sprites/Black Square.png" id="6_kt7c3"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="6_t8w5b"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_transporter.tscn" id="6_t8w5b"]
|
||||
[ext_resource type="PackedScene" uid="uid://vc0dkptkr1ow" path="res://Entities/Map Objects/Triggers/on_collision_trigger.tscn" id="7_6p5cp"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf6llktwqhs8l" path="res://Assets/Sprites/Door Fade.png" id="7_7ftpj"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca75b65eh7vv8" path="res://Entities/Map Objects/Loading Zone/collision_loading_zone.tscn" id="9_kp1fr"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fdj0q"]
|
||||
atlas = ExtResource("4_r8s0p")
|
||||
@@ -42,9 +42,8 @@ script = ExtResource("1_83xsp")
|
||||
[node name="Shop Item Notification Connector" type="Node" parent="." unique_id=1088308326]
|
||||
script = ExtResource("2_r8s0p")
|
||||
|
||||
[node name="Spawn Marker Connector" type="Node" parent="." unique_id=2053338893 node_paths=PackedStringArray("player", "markers")]
|
||||
[node name="Spawn Marker Connector" type="Node" parent="." unique_id=2053338893 node_paths=PackedStringArray("markers")]
|
||||
script = ExtResource("3_t8w5b")
|
||||
player = NodePath("../Player Body")
|
||||
markers = NodePath("../Spawn Markers")
|
||||
|
||||
[node name="Tilemap" type="Node2D" parent="." unique_id=81778152]
|
||||
@@ -100,14 +99,13 @@ debug_color = Color(0.9710676, 0.103622, 0.35069537, 0.41960785)
|
||||
|
||||
[node name="Loading Zones" type="Node2D" parent="." unique_id=525992692]
|
||||
|
||||
[node name="Collision Loading Zone" parent="Loading Zones" unique_id=1043800735 node_paths=PackedStringArray("loading_zone_transporter") instance=ExtResource("9_kp1fr")]
|
||||
loading_zone_transporter = NodePath("Loading Zone Transporter")
|
||||
[node name="On Collision Trigger" parent="Loading Zones" unique_id=895298999 instance=ExtResource("7_6p5cp")]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Loading Zones/Collision Loading Zone" unique_id=1798970421]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Loading Zones/On Collision Trigger" unique_id=1798970421]
|
||||
position = Vector2(224, 243)
|
||||
shape = SubResource("RectangleShape2D_kp1fr")
|
||||
|
||||
[node name="Loading Zone Transporter" parent="Loading Zones/Collision Loading Zone" unique_id=1690817663 instance=ExtResource("6_t8w5b")]
|
||||
[node name="Loading Zone Transporter" parent="Loading Zones/On Collision Trigger" unique_id=1690817663 instance=ExtResource("6_t8w5b")]
|
||||
destination_marker_name = "Shop Entrance"
|
||||
|
||||
[node name="Spawn Markers" type="Node2D" parent="." unique_id=680471197]
|
||||
@@ -145,3 +143,5 @@ texture = ExtResource("6_kt7c3")
|
||||
position = Vector2(224, 232)
|
||||
scale = Vector2(2, 1)
|
||||
texture = ExtResource("7_7ftpj")
|
||||
|
||||
[connection signal="body_entered" from="Loading Zones/On Collision Trigger" to="Loading Zones/On Collision Trigger/Loading Zone Transporter" method="Activate" unbinds=1]
|
||||
|
||||
@@ -1,10 +1 @@
|
||||
extends Node
|
||||
|
||||
# Public Methods
|
||||
func OnPlayerAreaEntered(area: Area2D) -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Node
|
||||
|
||||
@export var player: CharacterBody2D
|
||||
@export var player_entity: Node2D
|
||||
@export var markers: Node2D
|
||||
|
||||
# Public Methods
|
||||
func _ready() -> void:
|
||||
var body := player_entity.get_node("Player Body") as CharacterBody2D
|
||||
|
||||
var marker_name := MapLoader.GetSpawnMarker()
|
||||
if !marker_name:
|
||||
return
|
||||
@@ -13,4 +15,4 @@ func _ready() -> void:
|
||||
if child.name == marker_name:
|
||||
var marker := child as Marker2D
|
||||
var position := marker.global_position
|
||||
player.position = position
|
||||
body.position = position
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
[ext_resource type="Script" uid="uid://dbscr0b7k3rtp" path="res://Maps/Connectors/Scripts/collision_loading_zone_connector.gd" id="1_18bbf"]
|
||||
[ext_resource type="TileSet" uid="uid://df0lg5vkqwbbt" path="res://Resources/Tilesets/home_interior.tres" id="1_rf04x"]
|
||||
[ext_resource type="Script" uid="uid://dkcsftcdqtmg" path="res://Maps/Connectors/Scripts/spawn_marker_connector.gd" id="2_16uj4"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca75b65eh7vv8" path="res://Entities/Map Objects/Loading Zone/collision_loading_zone.tscn" id="2_fdso5"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="3_7kg22"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_transporter.tscn" id="3_7kg22"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl2jpjtbiju34" path="res://Maps/Connectors/chest_interaction_connector.tscn" id="3_ec540"]
|
||||
[ext_resource type="PackedScene" uid="uid://b7u4hlvuqiefn" path="res://Entities/Map Objects/Chests/Item Chests/item_chest_02 (Metal).tscn" id="4_a58cd"]
|
||||
[ext_resource type="PackedScene" uid="uid://b60nr4wfvijpf" path="res://Entities/Map Objects/Dialogue/dialogue_trigger.tscn" id="5_msu6a"]
|
||||
[ext_resource type="Texture2D" uid="uid://bm5ewxv51potl" path="res://Assets/Spritesheets/NPCs/Miner_Mike.png" id="6_x3y8m"]
|
||||
[ext_resource type="PackedScene" uid="uid://vc0dkptkr1ow" path="res://Entities/Map Objects/Triggers/on_collision_trigger.tscn" id="7_s4nwa"]
|
||||
[ext_resource type="Texture2D" uid="uid://bqvnkdyhfa1yq" path="res://Maps/Forest Dungeon Entrance/Interiors/Home_01_Overlay_01.png" id="11_6xfm6"]
|
||||
[ext_resource type="PackedScene" uid="uid://c65cfm3t0obwq" path="res://Entities/Characters/Player/player_map_entity.tscn" id="11_s4nwa"]
|
||||
|
||||
@@ -79,13 +79,12 @@ y_sort_enabled = true
|
||||
[node name="Collision Loading Zone Connector" type="Node" parent="Connectors" unique_id=483597596]
|
||||
script = ExtResource("1_18bbf")
|
||||
|
||||
[node name="Spawn Marker Connector" type="Node" parent="Connectors" unique_id=296643918 node_paths=PackedStringArray("player", "markers")]
|
||||
[node name="Spawn Marker Connector" type="Node" parent="Connectors" unique_id=296643918 node_paths=PackedStringArray("player_entity", "markers")]
|
||||
script = ExtResource("2_16uj4")
|
||||
player = NodePath("")
|
||||
player_entity = NodePath("../../Player Map Entity")
|
||||
markers = NodePath("../../Spawn Markers")
|
||||
|
||||
[node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 node_paths=PackedStringArray("player") instance=ExtResource("3_ec540")]
|
||||
player = NodePath("")
|
||||
[node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 instance=ExtResource("3_ec540")]
|
||||
|
||||
[node name="Tilemap" type="Node2D" parent="." unique_id=894627186]
|
||||
y_sort_enabled = true
|
||||
@@ -115,16 +114,16 @@ locked_message_dialogue_trigger = NodePath("Locked Dialogue Trigger")
|
||||
[node name="Locked Dialogue Trigger" parent="Objects/Item Chest 02" unique_id=189867444 instance=ExtResource("5_msu6a")]
|
||||
dialogue_name = "MSG_FOREST_DUNGEON_ENTRANCE_HOME_01_LOCKED_CHEST_01"
|
||||
|
||||
[node name="Loading Zones" type="Node2D" parent="." unique_id=1862302491]
|
||||
[node name="Entrances" type="Node2D" parent="." unique_id=1862302491]
|
||||
|
||||
[node name="Collision Loading Zone" parent="Loading Zones" unique_id=1043800735 node_paths=PackedStringArray("loading_zone_transporter") instance=ExtResource("2_fdso5")]
|
||||
loading_zone_transporter = NodePath("Loading Zone Transporter")
|
||||
[node name="On Collision Trigger" parent="Entrances" unique_id=895298999 instance=ExtResource("7_s4nwa")]
|
||||
collision_mask = 16
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Loading Zones/Collision Loading Zone" unique_id=2049955470]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Entrances/On Collision Trigger" unique_id=2049955470]
|
||||
position = Vector2(80, 188)
|
||||
shape = SubResource("RectangleShape2D_7kg22")
|
||||
|
||||
[node name="Loading Zone Transporter" parent="Loading Zones/Collision Loading Zone" unique_id=1690817663 instance=ExtResource("3_7kg22")]
|
||||
[node name="Loading Zone Transporter" parent="Entrances/On Collision Trigger" unique_id=1690817663 instance=ExtResource("3_7kg22")]
|
||||
destination_map_id = 2
|
||||
destination_marker_name = "Home 01 Entrance"
|
||||
|
||||
@@ -166,3 +165,5 @@ position = Vector2(124, 217)
|
||||
scale = Vector2(0.25, 0.25)
|
||||
texture = ExtResource("11_6xfm6")
|
||||
offset = Vector2(16, -436)
|
||||
|
||||
[connection signal="body_entered" from="Entrances/On Collision Trigger" to="Entrances/On Collision Trigger/Loading Zone Transporter" method="Activate" unbinds=1]
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
[ext_resource type="PackedScene" uid="uid://303hbhqetdhy" path="res://Maps/Connectors/arrow_spawner.tscn" id="2_jtncl"]
|
||||
[ext_resource type="PackedScene" uid="uid://divmfeqf10ri1" path="res://Maps/Connectors/bench_interaction_connector.tscn" id="3_x6da4"]
|
||||
[ext_resource type="Script" uid="uid://kfupww4frb1r" path="res://Maps/Connectors/Scripts/camera_limit_connector.gd" id="3_ycf72"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/Individual Components/body.tscn" id="4_4igim"]
|
||||
[ext_resource type="PackedScene" uid="uid://b03s7fw8bxdxs" path="res://Maps/Connectors/interactive_loading_zone_connector.tscn" id="4_4lnhp"]
|
||||
[ext_resource type="PackedScene" uid="uid://byp273amg5ji8" path="res://Entities/Map Objects/Chests/Item Chests/item_chest_01 (Wooden).tscn" id="5_bnsbe"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf6llktwqhs8l" path="res://Assets/Sprites/Door Fade.png" id="5_jett5"]
|
||||
@@ -23,12 +22,13 @@
|
||||
[ext_resource type="PackedScene" uid="uid://23tpba4r6ucg" path="res://Entities/Map Objects/Decorative/Outdoor/wooden_bench.tscn" id="14_kgsic"]
|
||||
[ext_resource type="PackedScene" uid="uid://dwbg6wca6yl5j" path="res://Entities/Map Objects/Decorative/Signs/wooden_sign_01.tscn" id="16_dc5v0"]
|
||||
[ext_resource type="PackedScene" uid="uid://c2p8fteeqyikf" path="res://Entities/Characters/Animals/Frog/npc_frog.tscn" id="18_tfw55"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="19_c5vrl"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_transporter.tscn" id="19_c5vrl"]
|
||||
[ext_resource type="PackedScene" uid="uid://coaf2ndwb6h61" path="res://Entities/Map Objects/Decorative/Signs/wooden_sign_02.tscn" id="19_jtncl"]
|
||||
[ext_resource type="PackedScene" uid="uid://cla2d3gii8qda" path="res://Entities/Map Objects/Loading Zone/interactive_loading_zone.tscn" id="20_c5vrl"]
|
||||
[ext_resource type="PackedScene" uid="uid://b60nr4wfvijpf" path="res://Entities/Map Objects/Dialogue/dialogue_trigger.tscn" id="20_x6da4"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7rjjlamkqhnw" path="res://Debug/Utility Objects/under_construction_block.tscn" id="26_4lnhp"]
|
||||
[ext_resource type="PackedScene" uid="uid://nbkisxm2oekn" path="res://Entities/Characters/Utility/Components/movement_component.tscn" id="28_mf3dv"]
|
||||
[ext_resource type="PackedScene" uid="uid://c65cfm3t0obwq" path="res://Entities/Characters/Player/player_map_entity.tscn" id="27_0w1de"]
|
||||
[ext_resource type="Script" uid="uid://dtwxia7rlu5xt" path="res://Scripts/Utility/child_node_appender.gd" id="28_mf3dv"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lwurn"]
|
||||
size = Vector2(768, 494)
|
||||
@@ -68,21 +68,16 @@ y_sort_enabled = true
|
||||
|
||||
[node name="Map Connectors" type="Node" parent="." unique_id=1365901208]
|
||||
|
||||
[node name="Chest Interaction Connector" parent="Map Connectors" unique_id=625804018 node_paths=PackedStringArray("player") instance=ExtResource("1_jtncl")]
|
||||
player = NodePath("../../Player")
|
||||
[node name="Chest Interaction Connector" parent="Map Connectors" unique_id=625804018 instance=ExtResource("1_jtncl")]
|
||||
|
||||
[node name="Arrow Spawner" parent="Map Connectors" unique_id=627092886 node_paths=PackedStringArray("player", "arrow_parent") instance=ExtResource("2_jtncl")]
|
||||
player = NodePath("../../Player")
|
||||
arrow_parent = NodePath("../../Objects/Projectiles")
|
||||
[node name="Arrow Spawner" parent="Map Connectors" unique_id=627092886 instance=ExtResource("2_jtncl")]
|
||||
|
||||
[node name="Bench Interaction Connector" parent="Map Connectors" unique_id=541204437 node_paths=PackedStringArray("player") instance=ExtResource("3_x6da4")]
|
||||
player = NodePath("../../Player")
|
||||
[node name="Bench Interaction Connector" parent="Map Connectors" unique_id=541204437 instance=ExtResource("3_x6da4")]
|
||||
|
||||
[node name="Interactive Loading Zone Connector" parent="Map Connectors" unique_id=833475826 node_paths=PackedStringArray("player") instance=ExtResource("4_4lnhp")]
|
||||
player = NodePath("../../Player")
|
||||
[node name="Interactive Loading Zone Connector" parent="Map Connectors" unique_id=833475826 instance=ExtResource("4_4lnhp")]
|
||||
|
||||
[node name="Spawn Marker Connector" parent="Map Connectors" unique_id=807187299 node_paths=PackedStringArray("player", "markers") instance=ExtResource("5_lphfo")]
|
||||
player = NodePath("../../Player")
|
||||
[node name="Spawn Marker Connector" parent="Map Connectors" unique_id=807187299 node_paths=PackedStringArray("player_entity", "markers") instance=ExtResource("5_lphfo")]
|
||||
player_entity = NodePath("../../Player Map Entity")
|
||||
markers = NodePath("../../Spawn Markers")
|
||||
|
||||
[node name="Persistence Connectors" type="Node" parent="." unique_id=1245900932]
|
||||
@@ -97,7 +92,7 @@ gates = Array[NodePath]([NodePath("../../Objects/Spike Gate"), NodePath("../../O
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
script = ExtResource("3_ycf72")
|
||||
camera_to_limit = NodePath("../Player/Camera2D")
|
||||
camera_to_limit = NodePath("../Player Map Entity/Child Node Appender/Camera2D")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Camera Limit Connector" unique_id=456404995]
|
||||
position = Vector2(384, 408)
|
||||
@@ -350,13 +345,13 @@ destination_marker_name = "Entrance"
|
||||
[node name="Home 01 Entrance" type="Marker2D" parent="Spawn Markers" unique_id=1662896687]
|
||||
position = Vector2(278, 474)
|
||||
|
||||
[node name="Player" parent="." unique_id=1502234578 instance=ExtResource("4_4igim")]
|
||||
position = Vector2(656, 498)
|
||||
[node name="Player Map Entity" parent="." unique_id=469362016 instance=ExtResource("27_0w1de")]
|
||||
|
||||
[node name="Movement Component" parent="Player" unique_id=737644583 instance=ExtResource("28_mf3dv")]
|
||||
[node name="Child Node Appender" type="Node" parent="Player Map Entity" unique_id=1527392334]
|
||||
script = ExtResource("28_mf3dv")
|
||||
relative_path = "Player Body"
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Player" unique_id=1115720225]
|
||||
position = Vector2(0, 1)
|
||||
[node name="Camera2D" type="Camera2D" parent="Player Map Entity/Child Node Appender" unique_id=1115720225]
|
||||
zoom = Vector2(3, 3)
|
||||
position_smoothing_enabled = true
|
||||
|
||||
@@ -398,7 +393,6 @@ position = Vector2(760, 312)
|
||||
[node name="Under Construction Block12" parent="Debug" unique_id=1005752992 instance=ExtResource("26_4lnhp")]
|
||||
position = Vector2(760, 328)
|
||||
|
||||
[connection signal="SitOnBenchTriggered" from="Map Connectors/Bench Interaction Connector" to="Player" method="OnSitOnFurnitureTriggered"]
|
||||
[connection signal="TargetHit" from="Objects/ArrowTarget" to="Objects/Spike Gate" method="OpenGate"]
|
||||
[connection signal="TargetHit" from="Objects/ArrowTarget" to="Objects/Spike Gate2" method="OpenGate"]
|
||||
[connection signal="PressurePlateTripped" from="Objects/PressurePlate" to="Objects/Spike Gate" method="OpenGate"]
|
||||
|
||||
26
Scripts/Utility/child_node_appender.gd
Normal file
26
Scripts/Utility/child_node_appender.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends Node
|
||||
|
||||
# child_node_appender.gd
|
||||
|
||||
# All children of this node will be moved onto the node that is specified by
|
||||
# provided path relative to the parent of this node
|
||||
|
||||
@export var relative_path: String
|
||||
|
||||
func _ready() -> void:
|
||||
var parent := get_parent()
|
||||
|
||||
if parent == null:
|
||||
push_error("Child Node Appender has no parent")
|
||||
return
|
||||
|
||||
var node := parent.get_node_or_null(relative_path)
|
||||
|
||||
if node == null:
|
||||
push_error("Provided path does not resolve to a node")
|
||||
return
|
||||
|
||||
var children := get_children()
|
||||
for child in children:
|
||||
remove_child(child)
|
||||
node.add_child(child)
|
||||
1
Scripts/Utility/child_node_appender.gd.uid
Normal file
1
Scripts/Utility/child_node_appender.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtwxia7rlu5xt
|
||||
13
Scripts/vector2_utils.gd
Normal file
13
Scripts/vector2_utils.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends Node
|
||||
class_name Vector2Utils
|
||||
|
||||
static func GetClosestDirectionVector(dv: Vector2) -> Vector2:
|
||||
if dv == Vector2.ZERO:
|
||||
return dv
|
||||
if dv.y < 0:
|
||||
return Vector2.UP
|
||||
if dv.y > 0:
|
||||
return Vector2.DOWN
|
||||
if dv.x < 0:
|
||||
return Vector2.LEFT
|
||||
return Vector2.RIGHT
|
||||
1
Scripts/vector2_utils.gd.uid
Normal file
1
Scripts/vector2_utils.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b7tucdfjejupa
|
||||
@@ -77,6 +77,7 @@ locale/translations=PackedStringArray("res://Resources/Dialogue/Archipelago Game
|
||||
2d_physics/layer_2="Interaction"
|
||||
2d_physics/layer_3="Projectile Collision"
|
||||
2d_physics/layer_4="Occlusion"
|
||||
2d_physics/layer_5="Entrance"
|
||||
|
||||
[physics]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user