Pathsmoothing should work now for simple paths... I hope.
parent
d1f59643f0
commit
2ed41b6236
|
@ -2,4 +2,4 @@
|
|||
|
||||
[ext_resource path="res://assets/KenneySurvivalKit/Models/grass.glb" type="PackedScene" id=1]
|
||||
|
||||
[node name="grass" instance=ExtResource( 1 )]
|
||||
[node name="grass" groups=["GameGeometry"] instance=ExtResource( 1 )]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource path="res://assets/KenneySurvivalKit/Models/grassLarge.glb" type="PackedScene" id=1]
|
||||
|
||||
[node name="grassLarge" instance=ExtResource( 1 )]
|
||||
[node name="grassLarge" groups=["GameGeometry"] instance=ExtResource( 1 )]
|
||||
|
||||
[node name="grassLarge" parent="." index="0"]
|
||||
transform = Transform( 1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0 )
|
||||
|
|
|
@ -85,7 +85,7 @@ public class NavigationComponent : Spatial
|
|||
|
||||
private List<NavigationPoint> _pathWorldNavigationPoints = new List<NavigationPoint>();
|
||||
private List<NavigationPoint> _smoothedPathWorldNavigationPoints = new List<NavigationPoint>();
|
||||
|
||||
|
||||
private HexCell[] _path;
|
||||
|
||||
public override void _Ready()
|
||||
|
@ -117,7 +117,7 @@ public class NavigationComponent : Spatial
|
|||
_pathWorldNavigationPoints = new List<NavigationPoint>();
|
||||
_pathWorldNavigationPoints.Add(
|
||||
new NavigationPoint(TileWorld.GetHexCenterFromOffset(fromPositionOffset)));
|
||||
|
||||
|
||||
foreach (int index in Enumerable.Range(1, _path.Length - 1))
|
||||
{
|
||||
_pathWorldNavigationPoints.Add(
|
||||
|
@ -145,7 +145,8 @@ public class NavigationComponent : Spatial
|
|||
}
|
||||
|
||||
|
||||
public void PlanGridPath(KinematicBody body, Vector3 fromPositionWorld, Vector3 toPositionWorld, Quat toWorldOrientation)
|
||||
public void PlanGridPath(KinematicBody body, Vector3 fromPositionWorld, Vector3 toPositionWorld,
|
||||
Quat toWorldOrientation)
|
||||
{
|
||||
PlanGridPath(body, fromPositionWorld, toPositionWorld);
|
||||
|
||||
|
@ -158,7 +159,8 @@ public class NavigationComponent : Spatial
|
|||
if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position)
|
||||
&& navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation))
|
||||
{
|
||||
PlanGridPath(body, fromTransformWorld.origin, navigationPoint.WorldPosition, navigationPoint.WorldOrientation);
|
||||
PlanGridPath(body, fromTransformWorld.origin, navigationPoint.WorldPosition,
|
||||
navigationPoint.WorldOrientation);
|
||||
}
|
||||
else if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position))
|
||||
{
|
||||
|
@ -180,7 +182,8 @@ public class NavigationComponent : Spatial
|
|||
}
|
||||
|
||||
|
||||
public void PlanDirectPath(KinematicBody body, Vector3 fromPositionWorld, Vector3 toPositionWorld, Quat toWorldOrientation)
|
||||
public void PlanDirectPath(KinematicBody body, Vector3 fromPositionWorld, Vector3 toPositionWorld,
|
||||
Quat toWorldOrientation)
|
||||
{
|
||||
PlanDirectPath(body, fromPositionWorld, toPositionWorld);
|
||||
|
||||
|
@ -192,11 +195,13 @@ public class NavigationComponent : Spatial
|
|||
{
|
||||
Vector3 fromPositionLocal = GlobalTransform.XformInv(fromPositionWorld);
|
||||
Vector3 toPositionLocal = GlobalTransform.XformInv(toPositionWorld);
|
||||
Vector3 relativeVelocity = GlobalTransform.basis.Xform(toPositionLocal - fromPositionLocal);
|
||||
|
||||
KinematicCollision moveCollision = body.MoveAndCollide(toPositionLocal + Vector3.Up * 0.5f, true, true, true);
|
||||
KinematicCollision moveCollision = body.MoveAndCollide(relativeVelocity, true, true, true);
|
||||
if (moveCollision != null)
|
||||
{
|
||||
GD.Print("Found collision: " + moveCollision.Collider);
|
||||
Spatial colliderSpatial = moveCollision.Collider as Spatial;
|
||||
GD.Print("Found collision: " + moveCollision.Collider + " (" + colliderSpatial.Name + ")");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -208,14 +213,14 @@ public class NavigationComponent : Spatial
|
|||
Debug.Assert(navigationPoints.Count > 2);
|
||||
|
||||
Vector3 bodyGlobalTranslation = body.GlobalTranslation;
|
||||
List<NavigationPoint> smoothedPath = new List<NavigationPoint>();
|
||||
|
||||
List<NavigationPoint> smoothedPath = new List<NavigationPoint>();
|
||||
|
||||
int startIndex = 0;
|
||||
int endIndex = navigationPoints.Count > 1 ? 1 : 0;
|
||||
smoothedPath.Add(navigationPoints[startIndex]);
|
||||
Vector3 startPoint = navigationPoints[startIndex].WorldPosition;
|
||||
|
||||
while (endIndex != navigationPoints.Count - 1)
|
||||
|
||||
while (endIndex != navigationPoints.Count)
|
||||
{
|
||||
Vector3 endPoint = navigationPoints[endIndex].WorldPosition;
|
||||
|
||||
|
@ -227,22 +232,26 @@ public class NavigationComponent : Spatial
|
|||
body.GlobalTranslation = bodyGlobalTranslation;
|
||||
return smoothedPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
smoothedPath.Add(navigationPoints[endIndex - 1]);
|
||||
startIndex = endIndex - 1;
|
||||
startPoint = navigationPoints[startIndex].WorldPosition;
|
||||
body.GlobalTranslation = startPoint;
|
||||
|
||||
continue;
|
||||
}
|
||||
smoothedPath.Add(navigationPoints[endIndex - 1]);
|
||||
startIndex = endIndex - 1;
|
||||
startPoint = navigationPoints[startIndex].WorldPosition;
|
||||
body.GlobalTranslation = startPoint;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (endIndex == navigationPoints.Count - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
endIndex += 1;
|
||||
}
|
||||
|
||||
|
||||
smoothedPath.Add(navigationPoints[endIndex]);
|
||||
body.GlobalTranslation = bodyGlobalTranslation;
|
||||
|
||||
|
||||
return smoothedPath;
|
||||
}
|
||||
|
||||
|
@ -251,7 +260,8 @@ public class NavigationComponent : Spatial
|
|||
if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position)
|
||||
&& navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation))
|
||||
{
|
||||
PlanDirectPath(body, fromTransformWorld.origin, navigationPoint.WorldPosition, navigationPoint.WorldOrientation);
|
||||
PlanDirectPath(body, fromTransformWorld.origin, navigationPoint.WorldPosition,
|
||||
navigationPoint.WorldOrientation);
|
||||
}
|
||||
else if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position))
|
||||
{
|
||||
|
@ -337,7 +347,6 @@ public class NavigationComponent : Spatial
|
|||
|
||||
public void DebugDraw(Spatial parentNode, DebugGeometry debugGeometry)
|
||||
{
|
||||
|
||||
Vector3 yOffset = Vector3.Up * 0.1f;
|
||||
|
||||
debugGeometry.GlobalTransform = Transform.Identity;
|
||||
|
@ -362,7 +371,7 @@ public class NavigationComponent : Spatial
|
|||
|
||||
previousPoint = point.WorldPosition;
|
||||
}
|
||||
|
||||
|
||||
previousPoint = parentNode.GlobalTranslation;
|
||||
foreach (NavigationPoint point in _smoothedPathWorldNavigationPoints)
|
||||
{
|
||||
|
@ -372,7 +381,7 @@ public class NavigationComponent : Spatial
|
|||
|
||||
previousPoint = point.WorldPosition;
|
||||
}
|
||||
|
||||
|
||||
debugGeometry.End();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=10 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://entities/Chest.cs" type="Script" id=1]
|
||||
[ext_resource path="res://assets/Objects/Wood.material" type="Material" id=2]
|
||||
|
@ -80,12 +80,19 @@ tracks/2/keys = {
|
|||
[sub_resource type="PrismMesh" id=15]
|
||||
|
||||
[sub_resource type="BoxShape" id=16]
|
||||
extents = Vector3( 0.19, 0.19, 0.332 )
|
||||
extents = Vector3( 0.19, 0.19, 0.33 )
|
||||
|
||||
[sub_resource type="CubeMesh" id=17]
|
||||
size = Vector3( 0.38, 0.38, 0.66 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=18]
|
||||
flags_transparent = true
|
||||
albedo_color = Color( 0.380392, 0.145098, 0.145098, 0.501961 )
|
||||
|
||||
[node name="Chest" type="KinematicBody"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Geometry" type="Spatial" parent="."]
|
||||
[node name="Geometry" type="Spatial" parent="." groups=["GameGeometry"]]
|
||||
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="Geometry"]
|
||||
|
@ -128,3 +135,7 @@ skeleton = NodePath("../..")
|
|||
[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 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="CollisionShape" groups=["PhysicsGeometry"]]
|
||||
mesh = SubResource( 17 )
|
||||
material/0 = SubResource( 18 )
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://entities/Player.cs" type="Script" id=1]
|
||||
[ext_resource path="res://components/NavigationComponent.cs" type="Script" id=2]
|
||||
[ext_resource path="res://materials/debug/PlayerPhysicsGeometry.tres" type="Material" id=3]
|
||||
[ext_resource path="res://assets/Characters/Pirate.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://components/WorldInfoComponent.cs" type="Script" id=5]
|
||||
[ext_resource path="res://utils/DebugGeometry.cs" type="Script" id=6]
|
||||
|
@ -11,12 +12,19 @@
|
|||
radius = 0.27
|
||||
height = 0.4
|
||||
|
||||
[sub_resource type="CapsuleMesh" id=26]
|
||||
radius = 0.27
|
||||
mid_height = 0.4
|
||||
|
||||
[sub_resource type="CylinderShape" id=24]
|
||||
height = 0.2
|
||||
radius = 0.2
|
||||
|
||||
[sub_resource type="SphereShape" id=23]
|
||||
radius = 0.1
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=28]
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=25]
|
||||
flags_unshaded = true
|
||||
vertex_color_use_as_albedo = true
|
||||
|
@ -30,6 +38,15 @@ script = ExtResource( 1 )
|
|||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.5, 0 )
|
||||
shape = SubResource( 7 )
|
||||
__meta__ = {
|
||||
"_editor_description_": "Player World Collision Shape
|
||||
"
|
||||
}
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="CollisionShape" groups=["PhysicsGeometry"]]
|
||||
visible = false
|
||||
mesh = SubResource( 26 )
|
||||
material/0 = ExtResource( 3 )
|
||||
|
||||
[node name="Movable" parent="." instance=ExtResource( 7 )]
|
||||
|
||||
|
@ -38,11 +55,14 @@ script = ExtResource( 5 )
|
|||
World = NodePath("../../TileWorld")
|
||||
|
||||
[node name="Navigation" type="Spatial" parent="."]
|
||||
visible = false
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="ItemAttractorArea" type="Area" parent="."]
|
||||
visible = false
|
||||
collision_layer = 0
|
||||
collision_mask = 8
|
||||
input_ray_pickable = false
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="ItemAttractorArea"]
|
||||
|
@ -50,14 +70,22 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.123516, 0 )
|
|||
shape = SubResource( 24 )
|
||||
|
||||
[node name="ItemPickupArea" type="Area" parent="."]
|
||||
visible = false
|
||||
collision_layer = 0
|
||||
collision_mask = 8
|
||||
input_ray_pickable = false
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="ItemPickupArea"]
|
||||
shape = SubResource( 23 )
|
||||
|
||||
[node name="Geometry" parent="." instance=ExtResource( 4 )]
|
||||
[node name="Geometry" parent="." groups=["GameGeometry"] instance=ExtResource( 4 )]
|
||||
|
||||
[node name="ToolAttachement" parent="Geometry/Armature/Skeleton" index="5"]
|
||||
transform = Transform( 1, 8.68458e-08, -1.04308e-07, 1.74623e-07, -1, -1.30385e-07, 1.41561e-07, 1.50874e-07, -1, -0.72, 0.45, 3.28113e-08 )
|
||||
|
||||
[node name="AnimationTree" parent="Geometry" index="2"]
|
||||
parameters/playback = SubResource( 28 )
|
||||
|
||||
[node name="DebugGeometry" type="Spatial" parent="."]
|
||||
script = ExtResource( 6 )
|
||||
|
@ -66,3 +94,5 @@ script = ExtResource( 6 )
|
|||
material_override = SubResource( 25 )
|
||||
cast_shadow = 0
|
||||
generate_lightmap = false
|
||||
|
||||
[editable path="Geometry"]
|
||||
|
|
|
@ -27,7 +27,7 @@ public class Tree : StaticBody, IInteractionInterface
|
|||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
_geometry = GetNode<MeshInstance>("Geometry");
|
||||
_geometry = GetNode<MeshInstance>("Geometry/tree");
|
||||
Debug.Assert(_geometry != null);
|
||||
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
Debug.Assert(_animationPlayer != null);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,20 +1,27 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/KenneySurvivalKit/Models/rockA.glb" type="PackedScene" id=1]
|
||||
[ext_resource path="res://materials/debug/RockPhysicsGeometry.tres" type="Material" id=2]
|
||||
|
||||
[sub_resource type="CylinderShape" id=1]
|
||||
height = 0.736755
|
||||
height = 0.7
|
||||
radius = 0.4
|
||||
|
||||
[node name="rockA" instance=ExtResource( 1 )]
|
||||
[sub_resource type="CylinderMesh" id=2]
|
||||
top_radius = 0.4
|
||||
bottom_radius = 0.4
|
||||
height = 0.7
|
||||
|
||||
[node name="rockA" parent="." index="0"]
|
||||
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 )
|
||||
[node name="rockA" type="StaticBody"]
|
||||
|
||||
[node name="StaticBody" type="StaticBody" parent="." index="1"]
|
||||
collision_mask = 0
|
||||
input_ray_pickable = false
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="StaticBody" index="0"]
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.373712, 0 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="CollisionShape" groups=["PhysicsGeometry"]]
|
||||
visible = false
|
||||
mesh = SubResource( 2 )
|
||||
material/0 = ExtResource( 2 )
|
||||
|
||||
[node name="rockA2" parent="." groups=["GameGeometry"] instance=ExtResource( 1 )]
|
||||
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 )
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/KenneySurvivalKit/Models/rockB.glb" type="PackedScene" id=1]
|
||||
[ext_resource path="res://materials/debug/RockPhysicsGeometry.tres" type="Material" id=2]
|
||||
|
||||
[sub_resource type="CylinderShape" id=1]
|
||||
height = 0.679261
|
||||
[sub_resource type="CylinderShape" id=3]
|
||||
height = 0.7
|
||||
radius = 0.4
|
||||
|
||||
[node name="rockB" instance=ExtResource( 1 )]
|
||||
[sub_resource type="CylinderMesh" id=2]
|
||||
top_radius = 0.4
|
||||
bottom_radius = 0.4
|
||||
height = 0.7
|
||||
|
||||
[node name="rockB" parent="." index="0"]
|
||||
transform = Transform( 1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.6, 0, 0, 0 )
|
||||
[node name="rockB" type="StaticBody"]
|
||||
|
||||
[node name="StaticBody" type="StaticBody" parent="." index="1"]
|
||||
input_ray_pickable = false
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="StaticBody" index="0"]
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 0.999997, -0.00240855, 0, 0.00240855, 0.999997, 0, 0.376176, 0 )
|
||||
shape = SubResource( 1 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="CollisionShape" groups=["PhysicsGeometry"]]
|
||||
visible = false
|
||||
mesh = SubResource( 2 )
|
||||
material/0 = ExtResource( 2 )
|
||||
|
||||
[node name="Geometry" parent="." groups=["GameGeometry"] instance=ExtResource( 1 )]
|
||||
transform = Transform( 1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.6, 0, 0, 0 )
|
||||
|
|
|
@ -1,19 +1,31 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/KenneySurvivalKit/Models/rockC.glb" type="PackedScene" id=1]
|
||||
[ext_resource path="res://materials/debug/RockPhysicsGeometry.tres" type="Material" id=2]
|
||||
|
||||
[sub_resource type="CylinderShape" id=1]
|
||||
height = 1.38848
|
||||
height = 0.8
|
||||
radius = 0.4
|
||||
|
||||
[node name="rockC" instance=ExtResource( 1 )]
|
||||
[sub_resource type="CylinderMesh" id=3]
|
||||
material = ExtResource( 2 )
|
||||
top_radius = 0.4
|
||||
bottom_radius = 0.4
|
||||
height = 0.8
|
||||
|
||||
[node name="rockC" parent="." index="0"]
|
||||
[node name="rockC" type="StaticBody"]
|
||||
|
||||
[node name="Geometry" parent="." groups=["GameGeometry"] instance=ExtResource( 1 )]
|
||||
transform = Transform( 1.7, 0, 0, 0, 1.7, 0, 0, 0, 1.7, 0, 0, 0 )
|
||||
|
||||
[node name="StaticBody" type="StaticBody" parent="." index="1"]
|
||||
input_ray_pickable = false
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="StaticBody" index="0"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.746043, 0 )
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0 )
|
||||
shape = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_editor_description_": "Rock World Collision Shape
|
||||
"
|
||||
}
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="CollisionShape" groups=["PhysicsGeometry"]]
|
||||
visible = false
|
||||
mesh = SubResource( 3 )
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[gd_resource type="SpatialMaterial" format=2]
|
||||
|
||||
[resource]
|
||||
flags_transparent = true
|
||||
albedo_color = Color( 0.733333, 0.113725, 0.113725, 0.501961 )
|
|
@ -0,0 +1,5 @@
|
|||
[gd_resource type="SpatialMaterial" format=2]
|
||||
|
||||
[resource]
|
||||
flags_transparent = true
|
||||
albedo_color = Color( 0.584314, 0.580392, 0.482353, 0.501961 )
|
|
@ -0,0 +1,5 @@
|
|||
[gd_resource type="SpatialMaterial" format=2]
|
||||
|
||||
[resource]
|
||||
flags_transparent = true
|
||||
albedo_color = Color( 0.294118, 0.588235, 0.309804, 0.501961 )
|
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/StreamContainer.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://entities/Player.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://scenes/Camera.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://ui/EditorUI.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://utils/TileHighlight.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://entities/Chest.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://scenes/TileWorld.tscn" type="PackedScene" id=8]
|
||||
|
@ -273,6 +274,9 @@ rect_min_size = Vector2( 100, 100 )
|
|||
stretch_mode = 1
|
||||
flip_v = true
|
||||
|
||||
[node name="EditorUI" parent="." instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
|
||||
[node name="StreamContainer" parent="." instance=ExtResource( 1 )]
|
||||
ShowHexTiles = true
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/HexTile3D.cs" type="Script" id=1]
|
||||
[ext_resource path="res://materials/HexTileTextureLookup.tres" type="Material" id=2]
|
||||
|
@ -8,11 +8,21 @@
|
|||
height = 1.0
|
||||
radius = 0.5
|
||||
|
||||
[sub_resource type="CylinderMesh" id=6]
|
||||
top_radius = 0.5
|
||||
bottom_radius = 0.5
|
||||
height = 1.0
|
||||
radial_segments = 16
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=7]
|
||||
flags_transparent = true
|
||||
albedo_color = Color( 0.968627, 0.882353, 0.529412, 0.501961 )
|
||||
|
||||
[node name="HexTile3D" type="Spatial"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0096302, 0, 0 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Mesh" type="MeshInstance" parent="."]
|
||||
[node name="Mesh" type="MeshInstance" parent="." groups=["GameGeometry"]]
|
||||
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, -5, 0 )
|
||||
mesh = ExtResource( 3 )
|
||||
material/0 = ExtResource( 2 )
|
||||
|
@ -23,6 +33,11 @@ material/0 = ExtResource( 2 )
|
|||
transform = Transform( -4.37114e-08, 0, 1, 0, 10, 0, -1, 0, -4.37114e-08, 0, -5, 0 )
|
||||
shape = SubResource( 5 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="StaticBody/CollisionShape" groups=["PhysicsGeometry"]]
|
||||
visible = false
|
||||
mesh = SubResource( 6 )
|
||||
material/0 = SubResource( 7 )
|
||||
|
||||
[node name="MultiMeshInstance" type="MultiMeshInstance" parent="."]
|
||||
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, -5, 0 )
|
||||
visible = false
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using Array = Godot.Collections.Array;
|
||||
|
||||
public class EditorUI : Control
|
||||
{
|
||||
|
@ -16,6 +17,9 @@ public class EditorUI : Control
|
|||
private Button _sandButton;
|
||||
private Button _waterButton;
|
||||
|
||||
private CheckBox _gameGeometryCheckBox;
|
||||
private CheckBox _physicsGeometryCheckBox;
|
||||
|
||||
private TileWorld _tileWorld;
|
||||
private StreamContainer _streamContainer;
|
||||
|
||||
|
@ -46,6 +50,12 @@ public class EditorUI : Control
|
|||
|
||||
_waterButton = (Button) FindNode("WaterButton");
|
||||
_waterButton.Connect("pressed", this, nameof(OnWaterButton));
|
||||
|
||||
_gameGeometryCheckBox = (CheckBox)FindNode("GameGeometryCheckBox");
|
||||
_gameGeometryCheckBox.Connect("toggled", this, nameof(OnGameGeometryCheckBoxToggled));
|
||||
|
||||
_physicsGeometryCheckBox = (CheckBox)FindNode("PhysicsGeometryCheckBox");
|
||||
_physicsGeometryCheckBox.Connect("toggled", this, nameof(OnPhysicsGeometryCheckBoxToggled));
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,6 +82,31 @@ public class EditorUI : Control
|
|||
_currentTileType = TileType.Water;
|
||||
}
|
||||
|
||||
public void OnGameGeometryCheckBoxToggled(bool pressed)
|
||||
{
|
||||
Array gameGeometries = GetTree().GetNodesInGroup("GameGeometry");
|
||||
foreach (Spatial mesh in gameGeometries)
|
||||
{
|
||||
if (mesh != null)
|
||||
{
|
||||
mesh.Visible = pressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnPhysicsGeometryCheckBoxToggled(bool pressed)
|
||||
{
|
||||
Array physicsGeometries = GetTree().GetNodesInGroup("PhysicsGeometry");
|
||||
foreach (Spatial mesh in physicsGeometries)
|
||||
{
|
||||
if (mesh != null)
|
||||
{
|
||||
mesh.Visible = pressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTileClicked(Vector2 offsetCoord)
|
||||
{
|
||||
switch (_currentTileType)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=16 format=2]
|
||||
|
||||
[ext_resource path="res://entities/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scenes/TileWorld.tscn" type="PackedScene" id=2]
|
||||
|
@ -6,13 +6,13 @@
|
|||
[ext_resource path="res://scenes/tests/NavigationTests.cs" type="Script" id=4]
|
||||
[ext_resource path="res://scenes/StreamContainer.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://scenes/Camera.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://scenes/tests/EditorUI.cs" type="Script" id=7]
|
||||
[ext_resource path="res://ui/EditorUI.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://entities/Tree.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://scenes/HexTile3DPatch.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://entities/rockB.tscn" type="PackedScene" id=10]
|
||||
[ext_resource path="res://entities/Chest.tscn" type="PackedScene" id=11]
|
||||
|
||||
[sub_resource type="ButtonGroup" id=4]
|
||||
resource_local_to_scene = false
|
||||
resource_name = "TileTypeButtonGroup"
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=8]
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
resource_name = "Idle"
|
||||
|
@ -84,60 +84,18 @@ tracks/1/keys = {
|
|||
[node name="NavigationTests" type="Spatial"]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="EditorUI" type="Control" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
script = ExtResource( 7 )
|
||||
World = NodePath("../TileWorld")
|
||||
StreamContainer = NodePath("../StreamContainer")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="EditorUI"]
|
||||
margin_left = 5.0
|
||||
margin_top = 5.0
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="ResetButton" type="Button" parent="EditorUI/HBoxContainer"]
|
||||
margin_right = 48.0
|
||||
margin_bottom = 35.0
|
||||
text = "Reset"
|
||||
|
||||
[node name="ModeLabel" type="Label" parent="EditorUI/HBoxContainer"]
|
||||
margin_left = 52.0
|
||||
margin_top = 10.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 24.0
|
||||
text = "Mode"
|
||||
|
||||
[node name="GrassButton" type="Button" parent="EditorUI/HBoxContainer"]
|
||||
margin_left = 92.0
|
||||
margin_right = 140.0
|
||||
margin_bottom = 35.0
|
||||
toggle_mode = true
|
||||
group = SubResource( 4 )
|
||||
text = "Grass"
|
||||
|
||||
[node name="WaterButton" type="Button" parent="EditorUI/HBoxContainer"]
|
||||
margin_left = 144.0
|
||||
margin_right = 194.0
|
||||
margin_bottom = 35.0
|
||||
toggle_mode = true
|
||||
group = SubResource( 4 )
|
||||
text = "Water"
|
||||
|
||||
[node name="SandButton" type="Button" parent="EditorUI/HBoxContainer"]
|
||||
margin_left = 198.0
|
||||
margin_right = 240.0
|
||||
margin_bottom = 35.0
|
||||
toggle_mode = true
|
||||
group = SubResource( 4 )
|
||||
text = "Sand"
|
||||
[node name="EditorUI" parent="." instance=ExtResource( 7 )]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
collision_layer = 1
|
||||
collision_mask = 1
|
||||
TileWorldNode = NodePath("../TileWorld")
|
||||
|
||||
[node name="Skeleton" parent="Player/Geometry/Armature" index="0"]
|
||||
bones/4/bound_children = [ ]
|
||||
|
||||
[node name="AnimationTree" parent="Player/Geometry" index="2"]
|
||||
parameters/playback = SubResource( 8 )
|
||||
|
||||
[node name="TileWorld" parent="." instance=ExtResource( 2 )]
|
||||
GenerationMapType = 2
|
||||
Size = 20
|
||||
|
@ -157,25 +115,36 @@ transform = Transform( 1, 0, 0, 0, 0.60042, 0.799685, 0, -0.799685, 0.60042, -4.
|
|||
[node name="Tree" parent="." instance=ExtResource( 8 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.54934, 0.00752521, 2.60764 )
|
||||
|
||||
[node name="Geometry" parent="Tree" index="0"]
|
||||
[node name="Geometry" parent="Tree" index="3"]
|
||||
transform = Transform( 1.5, 0, 0, 0, 0.984722, 0.266325, 0, -0.177712, 1.47574, 0, 0, 0 )
|
||||
|
||||
[node name="Tree2" parent="." instance=ExtResource( 8 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.73489, 0, 0.451849 )
|
||||
|
||||
[node name="Geometry" parent="Tree2" index="0"]
|
||||
transform = Transform( 1.5, 0, 0, 0, 0.984722, 0.266325, 0, -0.177712, 1.47574, 0, 0, 0 )
|
||||
|
||||
[node name="AnimationPlayer" parent="Tree2" index="3"]
|
||||
[node name="AnimationPlayer" parent="Tree2" index="2"]
|
||||
anims/Idle = SubResource( 5 )
|
||||
anims/RESET = SubResource( 6 )
|
||||
anims/TreeShake = SubResource( 7 )
|
||||
|
||||
[node name="Spatial" parent="." instance=ExtResource( 9 )]
|
||||
[node name="Geometry" parent="Tree2" index="3"]
|
||||
transform = Transform( 1.5, 0, 0, 0, 0.984722, 0.266325, 0, -0.177712, 1.47574, 0, 0, 0 )
|
||||
|
||||
[node name="TilePatch" parent="." instance=ExtResource( 9 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.14454, 0 )
|
||||
|
||||
[node name="rockB" parent="." instance=ExtResource( 10 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.30333, 0, 1.2323 )
|
||||
|
||||
[node name="Chest" parent="." instance=ExtResource( 11 )]
|
||||
transform = Transform( 0.163154, 0, -0.986601, 0, 1, 0, 0.986601, 0, 0.163154, 3.7186, 0, -1.91323 )
|
||||
|
||||
[editable path="Player"]
|
||||
[editable path="Player/Geometry"]
|
||||
[editable path="TileWorld"]
|
||||
[editable path="StreamContainer"]
|
||||
[editable path="Tree"]
|
||||
[editable path="Tree/Geometry"]
|
||||
[editable path="Tree2"]
|
||||
[editable path="Tree2/Geometry"]
|
||||
[editable path="rockB"]
|
||||
[editable path="Chest"]
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/tests/EditorUI.cs" type="Script" id=1]
|
||||
|
||||
[sub_resource type="ButtonGroup" id=4]
|
||||
resource_local_to_scene = false
|
||||
resource_name = "TileTypeButtonGroup"
|
||||
|
||||
[node name="EditorUI" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
World = NodePath("../TileWorld")
|
||||
StreamContainer = NodePath("../StreamContainer")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = 240.0
|
||||
margin_bottom = 35.0
|
||||
|
||||
[node name="ResetButton" type="Button" parent="HBoxContainer"]
|
||||
margin_right = 48.0
|
||||
margin_bottom = 25.0
|
||||
text = "Reset"
|
||||
|
||||
[node name="ModeLabel" type="Label" parent="HBoxContainer"]
|
||||
margin_left = 52.0
|
||||
margin_top = 5.0
|
||||
margin_right = 88.0
|
||||
margin_bottom = 19.0
|
||||
text = "Mode"
|
||||
|
||||
[node name="GrassButton" type="Button" parent="HBoxContainer"]
|
||||
margin_left = 92.0
|
||||
margin_right = 140.0
|
||||
margin_bottom = 25.0
|
||||
toggle_mode = true
|
||||
group = SubResource( 4 )
|
||||
text = "Grass"
|
||||
|
||||
[node name="WaterButton" type="Button" parent="HBoxContainer"]
|
||||
margin_left = 144.0
|
||||
margin_right = 194.0
|
||||
margin_bottom = 25.0
|
||||
toggle_mode = true
|
||||
group = SubResource( 4 )
|
||||
text = "Water"
|
||||
|
||||
[node name="SandButton" type="Button" parent="HBoxContainer"]
|
||||
margin_left = 198.0
|
||||
margin_right = 240.0
|
||||
margin_bottom = 25.0
|
||||
toggle_mode = true
|
||||
group = SubResource( 4 )
|
||||
text = "Sand"
|
||||
|
||||
[node name="ViewFlagsContainer" type="HBoxContainer" parent="."]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -40.0
|
||||
margin_right = 146.0
|
||||
|
||||
[node name="Label" type="Label" parent="ViewFlagsContainer"]
|
||||
margin_top = 13.0
|
||||
margin_right = 30.0
|
||||
margin_bottom = 27.0
|
||||
text = "View"
|
||||
|
||||
[node name="GameGeometryCheckBox" type="CheckBox" parent="ViewFlagsContainer"]
|
||||
margin_left = 34.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 40.0
|
||||
text = "Game"
|
||||
|
||||
[node name="PhysicsGeometryCheckBox" type="CheckBox" parent="ViewFlagsContainer"]
|
||||
margin_left = 104.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 40.0
|
||||
text = "Physics"
|
Loading…
Reference in New Issue