Slight movement improvements.

WorldChunkRefactoring
Martin Felis 2023-02-12 16:44:48 +01:00
parent 716654a6fd
commit f3108b13f5
4 changed files with 23 additions and 6 deletions

View File

@ -106,6 +106,10 @@ public class GroundMotionComponent : Component
} }
float orientationErrorRadians = entity.GlobalTransform.basis.Quat().AngleTo(targetOrientation); float orientationErrorRadians = entity.GlobalTransform.basis.Quat().AngleTo(targetOrientation);
if (Mathf.Abs(orientationErrorRadians) > Mathf.Pi * 1.1)
{
GD.Print("moep");
}
if (orientationErrorRadians > 0) if (orientationErrorRadians > 0)
{ {
Transform entityTransform = entity.Transform; Transform entityTransform = entity.Transform;

View File

@ -86,6 +86,11 @@ public class NavigationComponent : Node
if ((toPositionWorld - TileWorld.GetTileWorldCenterFromOffset(toCell.OffsetCoords)).LengthSquared() > if ((toPositionWorld - TileWorld.GetTileWorldCenterFromOffset(toCell.OffsetCoords)).LengthSquared() >
Globals.EpsPositionSquared) Globals.EpsPositionSquared)
{ {
// Remove the last one, because it is only the position rounded to HexGrid coordinates.
if (_pathWorldNavigationPoints.Count > 1)
{
_pathWorldNavigationPoints.RemoveAt(_pathWorldNavigationPoints.Count - 1);
}
_pathWorldNavigationPoints.Add(new NavigationPoint(toPositionWorld)); _pathWorldNavigationPoints.Add(new NavigationPoint(toPositionWorld));
} }

View File

@ -1,9 +1,6 @@
using Godot; using Godot;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using GoDotLog;
using Dictionary = Godot.Collections.Dictionary;
using Array = Godot.Collections.Array; using Array = Godot.Collections.Array;
public class Game : Spatial public class Game : Spatial
@ -80,7 +77,16 @@ public class Game : Spatial
_streamContainerArea.Connect("input_event", this, nameof(OnAreaInputEvent)); _streamContainerArea.Connect("input_event", this, nameof(OnAreaInputEvent));
_streamContainer.Connect("TileClicked", this, nameof(OnTileClicked)); _streamContainer.Connect("TileClicked", this, nameof(OnTileClicked));
_tileWorld.Connect("WorldGenerated", this, nameof(OnWorldGenerated)); _tileWorld.Connect("WorldGenerated", this, nameof(OnWorldGenerated));
_chest.Connect("EntityClicked", this, nameof(OnEntityClicked));
// register entity events
Array entityNodes = FindNode("Entities").GetChildren();
foreach (Node node in entityNodes)
{
if (node is Chest)
{
node.Connect("EntityClicked", this, nameof(OnEntityClicked));
}
}
// perform dependency injection // perform dependency injection
//_streamContainer.SetWorld(_tileWorld); //_streamContainer.SetWorld(_tileWorld);

View File

@ -35,7 +35,7 @@ albedo_color = Color( 1, 1, 1, 0.156863 )
extents = Vector3( 20, 1, 20 ) extents = Vector3( 20, 1, 20 )
[sub_resource type="CapsuleShape" id=7] [sub_resource type="CapsuleShape" id=7]
radius = 0.4 radius = 0.3
height = 0.2 height = 0.2
[sub_resource type="SpatialMaterial" id=20] [sub_resource type="SpatialMaterial" id=20]
@ -107,7 +107,7 @@ 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 ) 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] [sub_resource type="BoxShape" id=16]
extents = Vector3( 0.2, 0.2, 0.332224 ) extents = Vector3( 0.19, 0.19, 0.332 )
[sub_resource type="CubeMesh" id=17] [sub_resource type="CubeMesh" id=17]
@ -320,6 +320,8 @@ fov = 60.0
script = ExtResource( 10 ) script = ExtResource( 10 )
[node name="Player" type="KinematicBody" parent="."] [node name="Player" type="KinematicBody" parent="."]
axis_lock_motion_y = true
move_lock_y = true
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="CollisionShape" type="CollisionShape" parent="Player"] [node name="CollisionShape" type="CollisionShape" parent="Player"]