Add CameraTrigger

phantom-camera
HumanoidSandvichDispenser 2024-06-06 19:15:07 -07:00
parent ad8ef32ea0
commit ceba8f9386
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
4 changed files with 106 additions and 26 deletions

View File

@ -0,0 +1,32 @@
using Godot;
namespace SupaLidlGame.BoundingBoxes;
public partial class CameraTrigger : Area2D
{
[Export]
public Node Camera { get; set; }
[Export]
public int EnablePriority { get; set; } = 2;
[Export]
public int DisablePriority { get; set; } = 0;
public override void _Ready()
{
Connect(SignalName.BodyEntered, new Callable(this, nameof(OnBodyEntered)));
Connect(SignalName.BodyExited, new Callable(this, nameof(OnBodyExited)));
}
private void OnBodyEntered(Node2D node)
{
Camera.Set("priority", EnablePriority);
Camera.Set("follow_target", node);
}
private void OnBodyExited(Node2D node)
{
Camera.Set("priority", DisablePriority);
}
}

View File

@ -364,13 +364,11 @@ curve = SubResource("Curve_30p4b")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_qdhau"]
particle_flag_disable_z = true
spread = 180.0
gravity = Vector3(0, 0, 0)
initial_velocity_min = 32.0
initial_velocity_max = 32.0
angular_velocity_min = 90.0
angular_velocity_max = 90.0
orbit_velocity_min = 0.0
orbit_velocity_max = 0.0
gravity = Vector3(0, 0, 0)
linear_accel_min = -64.0
linear_accel_max = -32.0
tangential_accel_min = 8.0
@ -442,7 +440,6 @@ MaxDistanceToTarget = 128.0
UseItemDistance = 128.0
PassiveState = NodePath("../Pursue")
PursueState = NodePath("../Pursue")
PursueOnLineOfSight = false
NPC = NodePath("../..")
[node name="Idle" type="Node" parent="ThinkerStateMachine" node_paths=PackedStringArray("PursueState", "NavigationAgent", "NPC")]
@ -451,7 +448,6 @@ PursueState = NodePath("../Pursue")
MinTargetDistance = 32.0
PursueOnLineOfSight = true
MinLineOfSightDistance = 128.0
ShouldReturnToOriginalPosition = true
NavigationAgent = NodePath("../../NavigationAgent2D")
NPC = NodePath("../..")
@ -531,15 +527,17 @@ hframes = 6
position = Vector2(0, -4)
shape = SubResource("RectangleShape2D_bfqew")
[node name="Inventory" type="Node2D" parent="."]
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Hotbar")]
position = Vector2(0, -4)
script = ExtResource("17_sjq8t")
Hotbar = []
[node name="ProjectileSpawner" parent="Inventory" instance=ExtResource("17_dmlbb")]
[node name="ProjectileSpawner" parent="Inventory" node_paths=PackedStringArray("StateMachine") instance=ExtResource("17_dmlbb")]
Projectile = ExtResource("18_lwg36")
ShouldOverrideProjectileDamage = false
ShouldOverrideVelocity = false
ShouldRotate = false
StateMachine = NodePath("StateMachine")
UseTime = 2.0
[node name="Hurtbox" parent="." instance=ExtResource("18_ajs2x")]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=4 uid="uid://b2x17su05ou5w"]
[gd_scene load_steps=26 format=4 uid="uid://b2x17su05ou5w"]
[ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_ifiic"]
[ext_resource type="TileSet" uid="uid://l61kbx31ug4p" path="res://Scenes/Maps/ArenaTileset.tres" id="2_x0mh7"]
@ -9,8 +9,10 @@
[ext_resource type="Texture2D" uid="uid://d1ukste16yq6v" path="res://Assets/Sprites/Particles/player-light.png" id="7_y7j0e"]
[ext_resource type="AudioStream" uid="uid://dy4qjflo1k28b" path="res://Assets/Sounds/calm-storm-ambient.mp3" id="8_wox7d"]
[ext_resource type="Script" path="res://BoundingBoxes/ConnectorBox.cs" id="9_fg062"]
[ext_resource type="PackedScene" uid="uid://malbos18dh7l" path="res://BoundingBoxes/CameraBounds.tscn" id="11_j2620"]
[ext_resource type="Script" path="res://BoundingBoxes/CameraTrigger.cs" id="11_0u80h"]
[ext_resource type="Script" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="11_q01ik"]
[ext_resource type="Texture2D" uid="uid://c1a7lvb4uuwfy" path="res://Assets/Sprites/Particles/circle-16.png" id="11_yjp7m"]
[ext_resource type="Script" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="12_ca3oh"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_i5p65"]
resource_local_to_scene = true
@ -52,7 +54,22 @@ turbulence_enabled = true
size = Vector2(40, 20)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_iw8cv"]
size = Vector2(64, 360)
size = Vector2(32, 256)
[sub_resource type="Resource" id="Resource_jab5j"]
script = ExtResource("12_ca3oh")
duration = 1.0
transition = 0
ease = 2
[sub_resource type="RectangleShape2D" id="RectangleShape2D_28nvi"]
size = Vector2(1024, 384)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8id2f"]
size = Vector2(256, 256)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_idjmj"]
size = Vector2(512, 384)
[node name="Arena" node_paths=PackedStringArray("Entities", "Areas", "Spawners", "Markers") instance=ExtResource("1_ifiic")]
Entities = NodePath("Entities")
@ -207,24 +224,58 @@ ToConnector = "ArenaEntrance"
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Entrance" index="0"]
shape = SubResource("RectangleShape2D_2xagi")
[node name="EntranceCameraBounds" parent="Areas" index="1" node_paths=PackedStringArray("Trigger", "TopLeft", "BottomRight") instance=ExtResource("11_j2620")]
Trigger = NodePath("Area2D")
TopLeft = NodePath("TopLeft")
BottomRight = NodePath("BottomRight")
[node name="Area2D" type="Area2D" parent="Areas" index="1" node_paths=PackedStringArray("Camera")]
position = Vector2(0, 384)
collision_layer = 0
collision_mask = 4
monitorable = false
script = ExtResource("11_0u80h")
Camera = NodePath("Node/PhantomCamera2D")
[node name="Area2D" parent="Areas/EntranceCameraBounds" index="0"]
position = Vector2(0, 377)
[node name="CollisionShape2D" parent="Areas/EntranceCameraBounds/Area2D" index="0"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D" index="0"]
shape = SubResource("RectangleShape2D_iw8cv")
debug_color = Color(0.631373, 0.345098, 1, 0.419608)
[node name="TopLeft" parent="Areas/EntranceCameraBounds" index="1"]
position = Vector2(-256, 0)
[node name="Node" type="Node" parent="Areas/Area2D" index="1"]
[node name="BottomRight" parent="Areas/EntranceCameraBounds" index="2"]
position = Vector2(256, 384)
[node name="PhantomCamera2D" type="Node2D" parent="Areas/Area2D/Node" index="0"]
position = Vector2(0, 248)
script = ExtResource("11_q01ik")
zoom = Vector2(4, 4)
tween_resource = SubResource("Resource_jab5j")
draw_limits = true
limit_left = -384
limit_top = -400
limit_right = 384
limit_bottom = 400
limit_target = NodePath("../CollisionShape2D")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D/Node" index="1"]
position = Vector2(0, 192)
shape = SubResource("RectangleShape2D_28nvi")
[node name="Area2D2" type="Area2D" parent="Areas" index="2" node_paths=PackedStringArray("Camera")]
position = Vector2(0, -3)
collision_layer = 0
collision_mask = 4
monitorable = false
script = ExtResource("11_0u80h")
Camera = NodePath("Node/PhantomCamera2D")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D2" index="0"]
shape = SubResource("RectangleShape2D_8id2f")
debug_color = Color(0.631373, 0.345098, 1, 0.419608)
[node name="Node" type="Node" parent="Areas/Area2D2" index="1"]
[node name="PhantomCamera2D" type="Node2D" parent="Areas/Area2D2/Node" index="0"]
script = ExtResource("11_q01ik")
zoom = Vector2(3, 3)
tween_resource = SubResource("Resource_jab5j")
draw_limits = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D2/Node" index="1"]
shape = SubResource("RectangleShape2D_idjmj")
[node name="Entrance" type="Marker2D" parent="Markers" index="0"]
position = Vector2(0, 352)
[editable path="Areas/EntranceCameraBounds"]

View File

@ -349,7 +349,6 @@ cell_size = 16.0
agent_radius = 8.0
[node name="ArenaExterior" node_paths=PackedStringArray("Entities", "Areas", "Spawners", "Markers") groups=["navigation"] instance=ExtResource("1_ci4ij")]
tile_set = ExtResource("2_m6h7j")
Entities = NodePath("Entities")
Areas = NodePath("Areas")
Spawners = NodePath("Spawners")
@ -384,7 +383,7 @@ tile_set = ExtResource("2_m6h7j")
[node name="z-index 0 (walls)" parent="Layers" index="6"]
tile_set = ExtResource("2_m6h7j")
[node name="CanvasModulate" parent="." index="2"]
[node name="CanvasModulate" parent="." index="1"]
color = Color(0.5, 0.5, 0.5, 1)
[node name="Static@Godrays" type="Node2D" parent="Props" index="0"]