From 3a652ef683e6d18d3e3fcc26309e4f2f0f03bcdb Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 12 Feb 2023 21:10:28 +0100 Subject: [PATCH] Interaction with Chests! --- components/NavigationComponent.cs | 82 ++++++++----- components/TaskQueueComponent.cs | 54 +++++++-- entities/Chest.cs | 28 +++++ entities/Chest.tscn | 118 ++++++++++++++++++- entities/Player.cs | 13 ++- scenes/Game.cs | 30 +++-- scenes/Game.tscn | 185 ++---------------------------- 7 files changed, 270 insertions(+), 240 deletions(-) diff --git a/components/NavigationComponent.cs b/components/NavigationComponent.cs index ef9c399..1b49c83 100644 --- a/components/NavigationComponent.cs +++ b/components/NavigationComponent.cs @@ -36,6 +36,41 @@ public class NavigationComponent : Node WorldOrientation = worldOrientation; Flags = NavigationFlags.Orientation; } + + public NavigationPoint(Transform worldTransform) + { + WorldPosition = worldTransform.origin; + WorldOrientation = worldTransform.basis.Quat(); + Flags = NavigationFlags.Position | NavigationFlags.Orientation; + } + + public bool IsReached(Transform worldTransform) + { + bool goalReached = false; + float positionErrorSquared = (worldTransform.origin - WorldPosition).LengthSquared(); + float orientationError = Mathf.Abs(worldTransform.basis.Quat().AngleTo(WorldOrientation)); + + if (Flags.HasFlag(NavigationPoint.NavigationFlags.Position) + && Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation) + && positionErrorSquared < Globals.EpsPositionSquared + && orientationError < Globals.EpsRadians) + { + goalReached = true; + } + else if (Flags.HasFlag(NavigationPoint.NavigationFlags.Position) && + positionErrorSquared < Globals.EpsPositionSquared) + { + goalReached = true; + } + else if (Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation) && + orientationError < Globals.EpsRadians) + + { + goalReached = true; + } + + return goalReached; + } } public TileWorld TileWorld { set; get; } @@ -106,6 +141,22 @@ public class NavigationComponent : Node } + public void Plan(Transform fromTransformWorld, NavigationPoint navigationPoint) + { + if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position) + && navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation)) + { + Plan(fromTransformWorld.origin, navigationPoint.WorldPosition, navigationPoint.WorldOrientation); + } else if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position)) + { + Plan(fromTransformWorld.origin, navigationPoint.WorldPosition); + } else + { + throw new NotImplementedException(); + } + } + + private void UpdateCurrentGoal() { if (_pathWorldNavigationPoints.Count == 0) @@ -145,37 +196,8 @@ public class NavigationComponent : Node { _currentGoalOrientationWorld = currentTransformWorld.basis.Quat(); } - - Vector3 currentPositionWorld = currentTransformWorld.origin; - Quat currentOrientationWorld = currentTransformWorld.basis.Quat(); - Vector2 currentPositionPlane = new Vector2(currentPositionWorld.x, currentPositionWorld.z); - Vector2 currentGoalPlane = new Vector2(_currentGoal.WorldPosition.x, _currentGoal.WorldPosition.z); - - bool goalReached = false; - float positionErrorSquared = (currentPositionPlane - currentGoalPlane).LengthSquared(); - float orientationError = _currentGoalOrientationWorld.AngleTo(currentOrientationWorld); - - if (_currentGoal.Flags.HasFlag(NavigationPoint.NavigationFlags.Position) - && _currentGoal.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation) - && positionErrorSquared < Globals.EpsPositionSquared - && orientationError < Globals.EpsRadians) - { - goalReached = true; - } - else if (_currentGoal.Flags.HasFlag(NavigationPoint.NavigationFlags.Position) && - positionErrorSquared < Globals.EpsPositionSquared) - { - goalReached = true; - } - else if (_currentGoal.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation) && - orientationError < Globals.EpsRadians) - - { - goalReached = true; - } - - if (goalReached) + if (_currentGoal.IsReached(currentTransformWorld)) { _pathWorldNavigationPoints.RemoveAt(0); UpdateCurrentGoal(); diff --git a/components/TaskQueueComponent.cs b/components/TaskQueueComponent.cs index 400ff6a..f9122df 100644 --- a/components/TaskQueueComponent.cs +++ b/components/TaskQueueComponent.cs @@ -5,26 +5,46 @@ using System.Diagnostics; public class TaskQueueComponent : Component { - public class Task + public abstract class Task { + public abstract bool PerformTask(Entity entity, float delta); } public class NavigationTask : Task { - [Flags] public enum Flags + public NavigationComponent.NavigationPoint NavigationPoint; + + public NavigationTask(NavigationComponent.NavigationPoint navigationPoint) { - Position = 1, - Orientation = 2 + NavigationPoint = navigationPoint; } - public Vector3 TargetPositionWorld = Vector3.Zero; - public Quat TargetOrientationWorld = Quat.Identity; - public Flags NavigationFlags = Flags.Position | Flags.Orientation; + public override bool PerformTask(Entity entity, float delta) + { + return NavigationPoint.IsReached(entity.GlobalTransform); + } } public class InteractionTask : Task { public Entity TargetEntity; + + public InteractionTask(Entity entity) + { + TargetEntity = entity; + } + + public override bool PerformTask(Entity entity, float delta) + { + GD.Print("Interaction of " + entity + " with " + TargetEntity); + + if (TargetEntity is Chest) + { + Chest chest = (Chest)TargetEntity; + chest.OnInteract(); + } + return true; + } } public Queue Queue; @@ -39,4 +59,24 @@ public class TaskQueueComponent : Component { Queue.Clear(); } + + public void Process(Entity entity, float delta) + { + if (Queue.Count == 0) + { + return; + } + + Task currentTask = Queue.Peek(); + while (currentTask.PerformTask(entity, delta)) + { + Queue.Dequeue(); + if (Queue.Count == 0) + { + break; + } + + currentTask = Queue.Peek(); + } + } } \ No newline at end of file diff --git a/entities/Chest.cs b/entities/Chest.cs index 8d7c137..c50aacb 100644 --- a/entities/Chest.cs +++ b/entities/Chest.cs @@ -7,9 +7,17 @@ public class Chest : Entity // private int a = 2; // private string b = "text"; + public enum LidState + { + Closed, + Open + } + + public LidState State = LidState.Closed; public bool IsMouseOver = false; private MeshInstance _mesh; private SpatialMaterial _previousMaterial; + private AnimationPlayer _animationPlayer; [Signal] delegate void EntityClicked(Entity entity); @@ -18,6 +26,7 @@ public class Chest : Entity public override void _Ready() { _mesh = GetNode("Armature/Skeleton/Chest"); + _animationPlayer = GetNode("AnimationPlayer"); Connect("input_event", this, nameof(OnAreaInputEvent)); Connect("mouse_entered", this, nameof(OnAreaMouseEntered)); @@ -38,6 +47,7 @@ public class Chest : Entity } } + public void OnAreaMouseEntered() { IsMouseOver = true; @@ -46,9 +56,27 @@ public class Chest : Entity _mesh.MaterialOverride = overrideMaterial; } + public void OnAreaMouseExited() { IsMouseOver = false; _mesh.MaterialOverride = null; } + + + public void OnInteract() + { + _animationPlayer.Stop(); + + if (State == LidState.Closed) + { + State = LidState.Open; + _animationPlayer.Play("ChestOpen"); + } + else + { + _animationPlayer.PlayBackwards("ChestOpen"); + State = LidState.Closed; + } + } } diff --git a/entities/Chest.tscn b/entities/Chest.tscn index 1b58112..a28a608 100644 --- a/entities/Chest.tscn +++ b/entities/Chest.tscn @@ -1,10 +1,116 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=10 format=2] -[ext_resource path="res://assets/Objects/chest.glb" type="PackedScene" id=1] -[ext_resource path="res://entities/Chest.cs" type="Script" id=2] +[ext_resource path="res://entities/Chest.cs" type="Script" id=1] +[ext_resource path="res://assets/Objects/Wood.material" type="Material" id=2] +[ext_resource path="res://assets/Objects/Lock.material" type="Material" id=3] -[node name="Chest" instance=ExtResource( 1 )] -script = ExtResource( 2 ) +[sub_resource type="ArrayMesh" id=12] +resource_name = "chest_Cube" +surfaces/0 = { +"aabb": AABB( -0.763939, 0, -1.05715, 1.52788, 1.5, 2.11429 ), +"array_data": PoolByteArray( 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 0, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 191, 0, 129, 127, 63, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 191, 127, 127, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 191, 127, 0, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 63, 127, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 129, 127, 63, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 63, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 191, 129, 0, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 0, 59, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 191, 129, 0, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 191, 0, 129, 127, 63, 0, 48, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 191, 127, 127, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 63, 129, 0, 0, 127, 0, 57, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 127, 0, 57, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 0, 59, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 63, 129, 0, 0, 127, 0, 54, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 63, 0, 129, 127, 63, 0, 48, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 127, 0, 54, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 191, 114, 127, 217, 103, 0, 57, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 191, 0, 127, 0, 63, 29, 5, 63, 54, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 191, 75, 51, 208, 98, 0, 57, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 191, 0, 129, 127, 63, 0, 54, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 191, 114, 127, 208, 98, 0, 54, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 191, 75, 51, 207, 99, 0, 54, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 63, 0, 12, 200, 102, 0, 57, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 63, 0, 127, 0, 63, 255, 59, 63, 54, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 63, 75, 51, 201, 102, 0, 57, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 63, 0, 129, 127, 63, 0, 54, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 63, 0, 12, 223, 115, 0, 54, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 63, 75, 51, 200, 102, 0, 54, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 191, 181, 51, 49, 99, 0, 57, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 191, 114, 127, 48, 98, 0, 57, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 191, 0, 127, 0, 63, 30, 5, 255, 59, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 191, 181, 51, 48, 98, 0, 54, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 191, 0, 129, 127, 63, 0, 48, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 191, 114, 127, 23, 110, 0, 54, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 63, 181, 51, 56, 102, 0, 57, 0, 60, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 63, 0, 12, 47, 107, 0, 57, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 63, 0, 127, 0, 63, 255, 59, 255, 59, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 63, 181, 51, 55, 102, 0, 54, 0, 60, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 63, 0, 129, 127, 63, 0, 48, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 63, 0, 12, 56, 102, 0, 54, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0 ), +"array_index_data": PoolByteArray( 1, 0, 20, 0, 14, 0, 1, 0, 7, 0, 20, 0, 10, 0, 19, 0, 6, 0, 10, 0, 23, 0, 19, 0, 21, 0, 12, 0, 18, 0, 21, 0, 15, 0, 12, 0, 16, 0, 9, 0, 3, 0, 16, 0, 22, 0, 9, 0, 5, 0, 8, 0, 2, 0, 5, 0, 11, 0, 8, 0, 17, 0, 0, 0, 13, 0, 17, 0, 4, 0, 0, 0, 25, 0, 44, 0, 38, 0, 25, 0, 31, 0, 44, 0, 34, 0, 43, 0, 30, 0, 34, 0, 47, 0, 43, 0, 45, 0, 36, 0, 42, 0, 45, 0, 39, 0, 36, 0, 40, 0, 33, 0, 27, 0, 40, 0, 46, 0, 33, 0, 29, 0, 32, 0, 26, 0, 29, 0, 35, 0, 32, 0, 41, 0, 24, 0, 37, 0, 41, 0, 28, 0, 24, 0 ), +"blend_shape_data": [ ], +"format": 2194903, +"index_count": 72, +"material": ExtResource( 2 ), +"primitive": 4, +"skeleton_aabb": [ AABB( -0.696499, 0, -1, 1.39301, 1.00001, 2 ), AABB( -0.763939, 1.1, -1.05715, 1.52788, 0.40001, 2.11429 ) ], +"vertex_count": 48 +} +surfaces/1 = { +"aabb": AABB( -0.904068, 0.508223, -0.240492, 0.305096, 0.507121, 0.480994 ), +"array_data": PoolByteArray( 8, 113, 103, 191, 238, 26, 2, 63, 128, 67, 118, 62, 129, 0, 0, 127, 0, 54, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 129, 127, 63, 0, 48, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 54, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 128, 67, 118, 62, 129, 0, 0, 127, 0, 57, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 57, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 127, 129, 63, 0, 59, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 114, 67, 118, 190, 129, 0, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 114, 67, 118, 190, 0, 129, 127, 63, 0, 48, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 114, 67, 118, 190, 129, 0, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 114, 67, 118, 190, 0, 127, 129, 63, 0, 59, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 129, 127, 63, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 128, 67, 118, 62, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 127, 129, 63, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 128, 67, 118, 62, 127, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 114, 67, 118, 190, 0, 129, 127, 63, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 114, 67, 118, 190, 127, 0, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 114, 67, 118, 190, 0, 127, 129, 63, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 114, 67, 118, 190, 127, 0, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0 ), +"array_index_data": PoolByteArray( 0, 0, 9, 0, 3, 0, 0, 0, 6, 0, 9, 0, 8, 0, 21, 0, 10, 0, 8, 0, 19, 0, 21, 0, 20, 0, 17, 0, 23, 0, 20, 0, 14, 0, 17, 0, 13, 0, 4, 0, 15, 0, 13, 0, 2, 0, 4, 0, 7, 0, 12, 0, 18, 0, 7, 0, 1, 0, 12, 0, 22, 0, 5, 0, 11, 0, 22, 0, 16, 0, 5, 0 ), +"blend_shape_data": [ ], +"format": 2194903, +"index_count": 36, +"material": ExtResource( 3 ), +"primitive": 4, +"skeleton_aabb": [ AABB( -0.904068, 0.508223, -0.240492, 0.305096, 0.507121, 0.480994 ) ], +"vertex_count": 24 +} -[node name="Armature" parent="." index="2"] +[sub_resource type="Skin" id=13] +resource_name = "Skin" +bind_count = 2 +bind/0/name = "Body" +bind/0/bone = -1 +bind/0/pose = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.697618, 0.0422799, 5.68067e-09 ) +bind/1/name = "Lid" +bind/1/bone = -1 +bind/1/pose = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.693102, -1.13623, -1.52663e-07 ) + +[sub_resource type="Animation" id=3] +resource_name = "ChestOpen" +length = 0.333333 +tracks/0/type = "transform" +tracks/0/path = NodePath("Armature/Skeleton:Lid") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.0666667, 1, 0, 0, 0, 0, 0, -0.079364, 0.996846, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, -0.489957, 0.871747, 1, 1, 1, 0.2, 1, 0, 0, 0, 0, 0, -0.855809, 0.517292, 1, 1, 1, 0.266667, 1, 2.37487e-08, 0, 0, 4.03449e-08, -3.99897e-08, 0.919654, -0.39273, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.45046e-08, 1.43769e-08, -0.808978, 0.587839, 1, 1, 1 ) +tracks/1/type = "transform" +tracks/1/path = NodePath("Armature/Skeleton:Body") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.266667, 1, 0, 0, 0, -5.57256e-17, 1.47956e-08, -0.0876532, 0.996151, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.11023e-16, -2.8211e-10, 0.00209969, 0.999998, 1, 1, 1 ) + +[sub_resource type="CubeMesh" id=14] + +[sub_resource type="PrismMesh" id=15] + +[sub_resource type="BoxShape" id=16] +extents = Vector3( 0.19, 0.19, 0.332 ) + +[node name="Chest" type="KinematicBody"] +script = ExtResource( 1 ) + +[node name="Armature" type="Spatial" parent="."] transform = Transform( -0.259808, 0, 0.15, 0, 0.3, 0, -0.15, 0, -0.259808, 0, 0, 0 ) + +[node name="Skeleton" type="Skeleton" parent="Armature"] +bones/0/name = "Body" +bones/0/parent = -1 +bones/0/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.697618, -0.0422799, -5.68067e-09 ) +bones/0/enabled = true +bones/0/bound_children = [ ] +bones/1/name = "Lid" +bones/1/parent = 0 +bones/1/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00451577, 1.17851, 1.58344e-07 ) +bones/1/enabled = true +bones/1/bound_children = [ ] + +[node name="Chest" type="MeshInstance" parent="Armature/Skeleton"] +mesh = SubResource( 12 ) +skin = SubResource( 13 ) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +anims/ChestOpen = SubResource( 3 ) + +[node name="State" type="Node" parent="."] + +[node name="MountPoint" type="Spatial" parent="."] +transform = Transform( -0.524001, 0, -0.851718, 0, 1, 0, 0.851718, 0, -0.524001, 0.717306, 0, 0.400936 ) + +[node name="Arrow" type="Spatial" parent="MountPoint"] +transform = Transform( -1, 0, -8.74227e-08, 0, 1, 0, 8.74227e-08, 0, -1, 2.38419e-07, 0, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="MountPoint/Arrow"] +transform = Transform( -0.1, 0, -1.24676e-08, 0, 0.1, 0, 1.24676e-08, 0, -0.1, 0, 0, 0.0394838 ) +mesh = SubResource( 14 ) +skeleton = NodePath("../..") + +[node name="MeshInstance2" type="MeshInstance" parent="MountPoint/Arrow"] +transform = Transform( -0.1, -1.24676e-08, 6.04182e-16, 0, -4.37114e-09, -0.1, 1.24676e-08, -0.1, 4.37114e-09, 0, 0, -0.151838 ) +mesh = SubResource( 15 ) +skeleton = NodePath("../..") + +[node name="ResourceContainer" type="Node" parent="."] + +[node name="CollisionShape" type="CollisionShape" parent="."] +transform = Transform( -0.866026, 0, 0.5, 0, 1, 0, -0.5, 0, -0.866026, 0, 0.240716, 0 ) +shape = SubResource( 16 ) diff --git a/entities/Player.cs b/entities/Player.cs index 25308d2..3009f13 100644 --- a/entities/Player.cs +++ b/entities/Player.cs @@ -50,11 +50,16 @@ public class Player : Entity if (TaskQueueComponent != null && TaskQueueComponent.Queue.Count > 0) { - var currentTask = TaskQueueComponent.Queue.Peek(); - if (currentTask is TaskQueueComponent.NavigationTask) + TaskQueueComponent.Process(this, delta); + + if (TaskQueueComponent.Queue.Count > 0) { - TaskQueueComponent.NavigationTask navigationTask = (TaskQueueComponent.NavigationTask)TaskQueueComponent.Queue.Dequeue(); - + var currentTask = TaskQueueComponent.Queue.Peek(); + if (currentTask is TaskQueueComponent.NavigationTask) + { + TaskQueueComponent.NavigationTask navigationTask = (TaskQueueComponent.NavigationTask)currentTask; + _navigationComponent.Plan(GlobalTransform, navigationTask.NavigationPoint); + } } } diff --git a/scenes/Game.cs b/scenes/Game.cs index 8efe7bf..c75631d 100644 --- a/scenes/Game.cs +++ b/scenes/Game.cs @@ -62,7 +62,7 @@ public class Game : Spatial _tileWorld = GetNode("TileWorld"); _camera = GetNode("Camera"); _cameraOffset = _camera.GlobalTranslation - _player.GlobalTranslation; - + Debug.Assert(_tileWorld != null); // resources @@ -76,12 +76,12 @@ public class Game : Spatial // update data _worldTextureRect.RectSize = _tileWorld.Size; - + // connect signals _streamContainerArea.Connect("input_event", this, nameof(OnAreaInputEvent)); _streamContainer.Connect("TileClicked", this, nameof(OnTileClicked)); _tileWorld.Connect("WorldGenerated", this, nameof(OnWorldGenerated)); - + // register entity events Array entityNodes = FindNode("Entities").GetChildren(); foreach (Node node in entityNodes) @@ -91,7 +91,7 @@ public class Game : Spatial node.Connect("EntityClicked", this, nameof(OnEntityClicked)); } } - + // perform dependency injection //_streamContainer.SetWorld(_tileWorld); WorldInfoComponent worldInfoComponent = _player.GetNode("WorldInfo"); @@ -99,7 +99,7 @@ public class Game : Spatial { worldInfoComponent.SetWorld(_tileWorld); } - + _tileWorld.Generate(); UpdateCurrentTile(); _streamContainer.SetCenterTile(_currentTile); @@ -139,7 +139,6 @@ public class Game : Spatial } - public override void _Process(float delta) { _framesPerSecondLabel.Text = Engine.GetFramesPerSecond().ToString(); @@ -181,7 +180,7 @@ public class Game : Spatial _mouseTileLabel.Text = cellAtCursor.OffsetCoords.ToString(); _mouseTileHighlight.Transform = highlightTransform; - if (inputEvent is InputEventMouseButton && ((InputEventMouseButton) inputEvent).Pressed) + if (inputEvent is InputEventMouseButton && ((InputEventMouseButton)inputEvent).Pressed) { _streamContainer.EmitSignal("TileClicked", _streamContainer.GetTile3dAt(cellAtCursor.OffsetCoords)); } @@ -195,12 +194,9 @@ public class Game : Spatial return; } - if (_player.Navigation == null) - { - return; - } - - _player.Navigation.Plan(_player.GlobalTranslation, tile.GlobalTranslation); + _player.TaskQueueComponent.Reset(); + _player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask( + new NavigationComponent.NavigationPoint(tile.GlobalTranslation))); } @@ -211,8 +207,10 @@ public class Game : Spatial Spatial mountPoint = (Spatial)entity.FindNode("MountPoint"); if (mountPoint != null) { - GD.Print("Mount point!"); - _player.Navigation.Plan(_player.GlobalTranslation, mountPoint.GlobalTranslation, mountPoint.GlobalTransform.basis.Quat()); + _player.TaskQueueComponent.Reset(); + _player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask( + new NavigationComponent.NavigationPoint(mountPoint.GlobalTransform))); + _player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.InteractionTask(entity)); } } @@ -221,7 +219,7 @@ public class Game : Spatial { GD.Print("Using new map"); ImageTexture new_world_texture = new ImageTexture(); - + _tileWorld.Heightmap.Unlock(); new_world_texture.CreateFromImage(_tileWorld.Heightmap); _tileWorld.Heightmap.Lock(); diff --git a/scenes/Game.tscn b/scenes/Game.tscn index c85e62f..3030a06 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=34 format=2] +[gd_scene load_steps=27 format=2] [ext_resource path="res://scenes/StreamContainer.cs" type="Script" id=1] [ext_resource path="res://components/NavigationComponent.cs" type="Script" id=2] @@ -6,12 +6,10 @@ [ext_resource path="res://components/MovableComponent.cs" type="Script" id=4] [ext_resource path="res://utils/TileHighlight.tscn" type="PackedScene" id=5] [ext_resource path="res://components/WorldInfoComponent.cs" type="Script" id=6] -[ext_resource path="res://entities/Chest.cs" type="Script" id=7] +[ext_resource path="res://entities/Chest.tscn" type="PackedScene" id=7] [ext_resource path="res://scenes/TileWorld.cs" type="Script" id=8] [ext_resource path="res://scenes/Game.cs" type="Script" id=9] [ext_resource path="res://scenes/DebugCamera.gd" type="Script" id=10] -[ext_resource path="res://assets/Objects/Lock.material" type="Material" id=11] -[ext_resource path="res://assets/Objects/Wood.material" type="Material" id=12] [ext_resource path="res://assets/CreatusPiratePack/characters/Pirate1final_0.01.glb" type="PackedScene" id=13] [ext_resource path="res://components/ClickableComponent.cs" type="Script" id=14] [ext_resource path="res://entities/Flower.cs" type="Script" id=15] @@ -51,64 +49,6 @@ radial_segments = 16 [sub_resource type="PrismMesh" id=15] -[sub_resource type="ArrayMesh" id=12] -resource_name = "chest_Cube" -surfaces/0 = { -"aabb": AABB( -0.763939, 0, -1.05715, 1.52788, 1.5, 2.11429 ), -"array_data": PoolByteArray( 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 191, 127, 0, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 191, 0, 129, 127, 63, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 191, 127, 127, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 191, 127, 0, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 128, 63, 0, 0, 128, 63, 127, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 129, 127, 63, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 63, 0, 0, 0, 0, 0, 0, 128, 63, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 191, 129, 0, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 191, 127, 127, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 191, 0, 127, 129, 63, 0, 59, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 191, 129, 0, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 191, 0, 129, 127, 63, 0, 48, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 191, 127, 127, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 63, 129, 0, 0, 127, 0, 57, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 127, 0, 57, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 128, 63, 0, 0, 128, 63, 0, 127, 129, 63, 0, 59, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 63, 129, 0, 0, 127, 0, 54, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 63, 0, 129, 127, 63, 0, 48, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 187, 77, 50, 191, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 127, 0, 54, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 191, 114, 127, 217, 103, 0, 57, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 191, 0, 127, 0, 63, 29, 5, 63, 54, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 191, 75, 51, 208, 98, 0, 57, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 191, 0, 129, 127, 63, 0, 54, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 191, 114, 127, 208, 98, 0, 54, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 191, 75, 51, 207, 99, 0, 54, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 63, 0, 12, 200, 102, 0, 57, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 63, 0, 127, 0, 63, 255, 59, 63, 54, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 62, 255, 255, 191, 63, 156, 158, 129, 63, 75, 51, 201, 102, 0, 57, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 63, 0, 129, 127, 63, 0, 54, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 63, 0, 12, 223, 115, 0, 54, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 63, 204, 204, 140, 63, 148, 80, 135, 63, 75, 51, 200, 102, 0, 54, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 191, 181, 51, 49, 99, 0, 57, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 191, 114, 127, 48, 98, 0, 57, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 191, 0, 127, 0, 63, 30, 5, 255, 59, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 191, 181, 51, 48, 98, 0, 54, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 191, 0, 129, 127, 63, 0, 48, 0, 56, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 191, 114, 127, 23, 110, 0, 54, 0, 58, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 63, 181, 51, 56, 102, 0, 57, 0, 60, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 63, 0, 12, 47, 107, 0, 57, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 6, 160, 249, 190, 255, 255, 191, 63, 156, 158, 129, 63, 0, 127, 0, 63, 255, 59, 255, 59, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 63, 181, 51, 55, 102, 0, 54, 0, 60, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 63, 0, 129, 127, 63, 0, 48, 0, 52, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 125, 145, 67, 191, 204, 204, 140, 63, 148, 80, 135, 63, 0, 12, 56, 102, 0, 54, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0 ), -"array_index_data": PoolByteArray( 1, 0, 20, 0, 14, 0, 1, 0, 7, 0, 20, 0, 10, 0, 19, 0, 6, 0, 10, 0, 23, 0, 19, 0, 21, 0, 12, 0, 18, 0, 21, 0, 15, 0, 12, 0, 16, 0, 9, 0, 3, 0, 16, 0, 22, 0, 9, 0, 5, 0, 8, 0, 2, 0, 5, 0, 11, 0, 8, 0, 17, 0, 0, 0, 13, 0, 17, 0, 4, 0, 0, 0, 25, 0, 44, 0, 38, 0, 25, 0, 31, 0, 44, 0, 34, 0, 43, 0, 30, 0, 34, 0, 47, 0, 43, 0, 45, 0, 36, 0, 42, 0, 45, 0, 39, 0, 36, 0, 40, 0, 33, 0, 27, 0, 40, 0, 46, 0, 33, 0, 29, 0, 32, 0, 26, 0, 29, 0, 35, 0, 32, 0, 41, 0, 24, 0, 37, 0, 41, 0, 28, 0, 24, 0 ), -"blend_shape_data": [ ], -"format": 2194903, -"index_count": 72, -"material": ExtResource( 12 ), -"primitive": 4, -"skeleton_aabb": [ AABB( -0.696499, 0, -1, 1.39301, 1.00001, 2 ), AABB( -0.763939, 1.1, -1.05715, 1.52788, 0.40001, 2.11429 ) ], -"vertex_count": 48 -} -surfaces/1 = { -"aabb": AABB( -0.904068, 0.508223, -0.240492, 0.305096, 0.507121, 0.480994 ), -"array_data": PoolByteArray( 8, 113, 103, 191, 238, 26, 2, 63, 128, 67, 118, 62, 129, 0, 0, 127, 0, 54, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 129, 127, 63, 0, 48, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 54, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 128, 67, 118, 62, 129, 0, 0, 127, 0, 57, 0, 60, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 57, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 127, 129, 63, 0, 59, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 114, 67, 118, 190, 129, 0, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 114, 67, 118, 190, 0, 129, 127, 63, 0, 48, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 238, 26, 2, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 54, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 114, 67, 118, 190, 129, 0, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 57, 0, 58, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 8, 113, 103, 191, 205, 246, 129, 63, 114, 67, 118, 190, 0, 127, 129, 63, 0, 59, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 129, 127, 63, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 128, 67, 118, 62, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 128, 67, 118, 62, 0, 127, 129, 63, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 128, 67, 118, 62, 127, 0, 0, 127, 0, 57, 0, 52, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 114, 67, 118, 190, 0, 129, 127, 63, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 238, 26, 2, 63, 114, 67, 118, 190, 127, 0, 0, 127, 0, 54, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 114, 67, 118, 190, 127, 127, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 114, 67, 118, 190, 0, 127, 129, 63, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 70, 86, 25, 191, 205, 246, 129, 63, 114, 67, 118, 190, 127, 0, 0, 127, 0, 57, 0, 56, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0 ), -"array_index_data": PoolByteArray( 0, 0, 9, 0, 3, 0, 0, 0, 6, 0, 9, 0, 8, 0, 21, 0, 10, 0, 8, 0, 19, 0, 21, 0, 20, 0, 17, 0, 23, 0, 20, 0, 14, 0, 17, 0, 13, 0, 4, 0, 15, 0, 13, 0, 2, 0, 4, 0, 7, 0, 12, 0, 18, 0, 7, 0, 1, 0, 12, 0, 22, 0, 5, 0, 11, 0, 22, 0, 16, 0, 5, 0 ), -"blend_shape_data": [ ], -"format": 2194903, -"index_count": 36, -"material": ExtResource( 11 ), -"primitive": 4, -"skeleton_aabb": [ AABB( -0.904068, 0.508223, -0.240492, 0.305096, 0.507121, 0.480994 ) ], -"vertex_count": 24 -} - -[sub_resource type="Skin" id=13] -resource_name = "Skin" -bind_count = 2 -bind/0/name = "Body" -bind/0/bone = -1 -bind/0/pose = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.697618, 0.0422799, 5.68067e-09 ) -bind/1/name = "Lid" -bind/1/bone = -1 -bind/1/pose = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.693102, -1.13623, -1.52663e-07 ) - -[sub_resource type="Animation" id=3] -resource_name = "ChestOpen" -length = 0.333333 -tracks/0/type = "transform" -tracks/0/path = NodePath("Armature/Skeleton:Lid") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.0666667, 1, 0, 0, 0, 0, 0, -0.079364, 0.996846, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, -0.489957, 0.871747, 1, 1, 1, 0.2, 1, 0, 0, 0, 0, 0, -0.855809, 0.517292, 1, 1, 1, 0.266667, 1, 2.37487e-08, 0, 0, 4.03449e-08, -3.99897e-08, 0.919654, -0.39273, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.45046e-08, 1.43769e-08, -0.808978, 0.587839, 1, 1, 1 ) -tracks/1/type = "transform" -tracks/1/path = NodePath("Armature/Skeleton:Body") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.266667, 1, 0, 0, 0, -5.57256e-17, 1.47956e-08, -0.0876532, 0.996151, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.11023e-16, -2.8211e-10, 0.00209969, 0.999998, 1, 1, 1 ) - -[sub_resource type="BoxShape" id=16] -extents = Vector3( 0.19, 0.19, 0.332 ) - [sub_resource type="CubeMesh" id=17] [sub_resource type="BoxShape" id=18] @@ -116,24 +56,6 @@ extents = Vector3( 0.2, 0.2, 0.2 ) [sub_resource type="BoxShape" id=19] -[sub_resource type="Animation" id=21] -resource_name = "ChestOpen" -length = 0.333333 -tracks/0/type = "transform" -tracks/0/path = NodePath("Armature/Skeleton:Lid") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.0666667, 1, 0, 0, 0, 0, 0, -0.079364, 0.996846, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, -0.489957, 0.871747, 1, 1, 1, 0.2, 1, 0, 0, 0, 0, 0, -0.855809, 0.517292, 1, 1, 1, 0.266667, 1, 2.37487e-08, 0, 0, 4.03449e-08, -3.99897e-08, 0.919654, -0.39273, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.45046e-08, 1.43769e-08, -0.808978, 0.587839, 1, 1, 1 ) -tracks/1/type = "transform" -tracks/1/path = NodePath("Armature/Skeleton:Body") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.266667, 1, 0, 0, 0, -5.57256e-17, 1.47956e-08, -0.0876532, 0.996151, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.11023e-16, -2.8211e-10, 0.00209969, 0.999998, 1, 1, 1 ) - [node name="Game" type="Spatial"] script = ExtResource( 9 ) @@ -363,55 +285,8 @@ script = ExtResource( 2 ) [node name="Entities" type="Spatial" parent="."] -[node name="Chest" type="KinematicBody" parent="Entities"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.36874, 0, -1.70504 ) -script = ExtResource( 7 ) - -[node name="Armature" type="Spatial" parent="Entities/Chest"] -transform = Transform( -0.259808, 0, 0.15, 0, 0.3, 0, -0.15, 0, -0.259808, 0, 0, 0 ) - -[node name="Skeleton" type="Skeleton" parent="Entities/Chest/Armature"] -bones/0/name = "Body" -bones/0/parent = -1 -bones/0/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.697618, -0.0422799, -5.68067e-09 ) -bones/0/enabled = true -bones/0/bound_children = [ ] -bones/1/name = "Lid" -bones/1/parent = 0 -bones/1/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00451577, 1.17851, 1.58344e-07 ) -bones/1/enabled = true -bones/1/bound_children = [ ] - -[node name="Chest" type="MeshInstance" parent="Entities/Chest/Armature/Skeleton"] -mesh = SubResource( 12 ) -skin = SubResource( 13 ) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="Entities/Chest"] -anims/ChestOpen = SubResource( 3 ) - -[node name="State" type="Node" parent="Entities/Chest"] - -[node name="MountPoint" type="Spatial" parent="Entities/Chest"] -transform = Transform( -0.468254, 0, -0.883594, 0, 1, 0, 0.883594, 0, -0.468254, 0.922324, 0, 0.544538 ) - -[node name="Arrow" type="Spatial" parent="Entities/Chest/MountPoint"] -transform = Transform( -1, 0, -8.74227e-08, 0, 1, 0, 8.74227e-08, 0, -1, 2.38419e-07, 0, 0 ) - -[node name="MeshInstance" type="MeshInstance" parent="Entities/Chest/MountPoint/Arrow"] -transform = Transform( -0.1, 0, -1.24676e-08, 0, 0.1, 0, 1.24676e-08, 0, -0.1, 0, 0, 0.0394838 ) -mesh = SubResource( 14 ) -skeleton = NodePath("../..") - -[node name="MeshInstance2" type="MeshInstance" parent="Entities/Chest/MountPoint/Arrow"] -transform = Transform( -0.1, -1.24676e-08, 6.04182e-16, 0, -4.37114e-09, -0.1, 1.24676e-08, -0.1, 4.37114e-09, 0, 0, -0.151838 ) -mesh = SubResource( 15 ) -skeleton = NodePath("../..") - -[node name="ResourceContainer" type="Node" parent="Entities/Chest"] - -[node name="CollisionShape" type="CollisionShape" parent="Entities/Chest"] -transform = Transform( -0.866026, 0, 0.5, 0, 1, 0, -0.5, 0, -0.866026, 0, 0.240716, 0 ) -shape = SubResource( 16 ) +[node name="Chest" parent="Entities" instance=ExtResource( 7 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.01499, 0, -1.3224 ) [node name="Flower" type="KinematicBody" parent="Entities"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75737, 0, -3.73012 ) @@ -433,52 +308,8 @@ script = ExtResource( 14 ) transform = Transform( 0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0 ) shape = SubResource( 19 ) -[node name="Chest2" type="KinematicBody" parent="Entities"] -transform = Transform( -0.437806, 0, -0.899069, 0, 1, 0, 0.899069, 0, -0.437806, -1.05888, 0, -2.14715 ) -script = ExtResource( 7 ) +[node name="Chest3" parent="Entities" instance=ExtResource( 7 )] +transform = Transform( 0.550568, 0, -0.83479, 0, 1, 0, 0.83479, 0, 0.550568, 4.88275, 0, -1.70504 ) -[node name="Armature" type="Spatial" parent="Entities/Chest2"] -transform = Transform( -0.259808, 0, 0.15, 0, 0.3, 0, -0.15, 0, -0.259808, 0, 0, 0 ) - -[node name="Skeleton" type="Skeleton" parent="Entities/Chest2/Armature"] -bones/0/name = "Body" -bones/0/parent = -1 -bones/0/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.697618, -0.0422799, -5.68067e-09 ) -bones/0/enabled = true -bones/0/bound_children = [ ] -bones/1/name = "Lid" -bones/1/parent = 0 -bones/1/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00451577, 1.17851, 1.58344e-07 ) -bones/1/enabled = true -bones/1/bound_children = [ ] - -[node name="Chest" type="MeshInstance" parent="Entities/Chest2/Armature/Skeleton"] -mesh = SubResource( 12 ) -skin = SubResource( 13 ) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="Entities/Chest2"] -anims/ChestOpen = SubResource( 21 ) - -[node name="State" type="Node" parent="Entities/Chest2"] - -[node name="MountPoint" type="Spatial" parent="Entities/Chest2"] -transform = Transform( -0.468254, 0, -0.883594, 0, 1, 0, 0.883594, 0, -0.468254, 0.922324, 0, 0.544538 ) - -[node name="Arrow" type="Spatial" parent="Entities/Chest2/MountPoint"] -transform = Transform( -1, 0, -8.74227e-08, 0, 1, 0, 8.74227e-08, 0, -1, 2.38419e-07, 0, 0 ) - -[node name="MeshInstance" type="MeshInstance" parent="Entities/Chest2/MountPoint/Arrow"] -transform = Transform( -0.1, 0, -1.24676e-08, 0, 0.1, 0, 1.24676e-08, 0, -0.1, 0, 0, 0.0394838 ) -mesh = SubResource( 14 ) -skeleton = NodePath("../..") - -[node name="MeshInstance2" type="MeshInstance" parent="Entities/Chest2/MountPoint/Arrow"] -transform = Transform( -0.1, -1.24676e-08, 6.04182e-16, 0, -4.37114e-09, -0.1, 1.24676e-08, -0.1, 4.37114e-09, 0, 0, -0.151838 ) -mesh = SubResource( 15 ) -skeleton = NodePath("../..") - -[node name="ResourceContainer" type="Node" parent="Entities/Chest2"] - -[node name="CollisionShape" type="CollisionShape" parent="Entities/Chest2"] -transform = Transform( -0.866026, 0, 0.5, 0, 1, 0, -0.5, 0, -0.866026, 0, 0.240716, 0 ) -shape = SubResource( 16 ) +[node name="Chest2" parent="Entities" instance=ExtResource( 7 )] +transform = Transform( 0.793576, 0, -0.608471, 0, 1, 0, 0.608471, 0, 0.793576, 2.79265, 0, -5.36551 )