mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-03 19:01:16 +00:00
New navigation
This commit is contained in:
parent
c8cbad3268
commit
86f7459837
8 changed files with 119 additions and 56 deletions
|
|
@ -62,6 +62,7 @@ public partial class Barrel : Area2D, IDestructible
|
||||||
|
|
||||||
QueueFree();
|
QueueFree();
|
||||||
|
|
||||||
|
GameManager.Instance.RebakeNavigation();
|
||||||
//GameManager.Instance.RecalculateTilemap(this.GlobalPosition);
|
//GameManager.Instance.RecalculateTilemap(this.GlobalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -16,7 +16,7 @@ region = Rect2(0, 0, 16, 16)
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
|
||||||
size = Vector2(11, 14)
|
size = Vector2(11, 14)
|
||||||
|
|
||||||
[node name="Barrel" type="Area2D" groups=["Destroyable"]]
|
[node name="Barrel" type="Area2D" groups=["Destroyable", "navigation_polygon_source_geometry_group"]]
|
||||||
collision_layer = 64
|
collision_layer = 64
|
||||||
collision_mask = 138
|
collision_mask = 138
|
||||||
script = ExtResource("1_avwdx")
|
script = ExtResource("1_avwdx")
|
||||||
|
|
@ -37,10 +37,9 @@ shape = SubResource("RectangleShape2D_2ewfl")
|
||||||
position = Vector2(0, -2)
|
position = Vector2(0, -2)
|
||||||
texture = SubResource("AtlasTexture_v7gy8")
|
texture = SubResource("AtlasTexture_v7gy8")
|
||||||
|
|
||||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
[node name="RigidBody2D" type="StaticBody2D" parent="." groups=["navigation_polygon_source_geometry_group"]]
|
||||||
collision_layer = 64
|
collision_layer = 64
|
||||||
collision_mask = 10
|
collision_mask = 10
|
||||||
gravity_scale = 0.0
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,10 @@ shape = SubResource("RectangleShape2D_2ewfl")
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_mupuc")
|
sprite_frames = SubResource("SpriteFrames_mupuc")
|
||||||
|
|
||||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
[node name="RigidBody2D" type="StaticBody2D" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
collision_layer = 64
|
collision_layer = 64
|
||||||
collision_mask = 10
|
collision_mask = 10
|
||||||
gravity_scale = 0.0
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
position = Vector2(0, -3)
|
position = Vector2(0, -3)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -64,6 +64,8 @@ public partial class GameManager : Node2D
|
||||||
[Export]
|
[Export]
|
||||||
public int EggStartIndex = 0;
|
public int EggStartIndex = 0;
|
||||||
|
|
||||||
|
[Export] public NavigationRegion2D NavigationRegion { get; private set; }
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|
@ -143,6 +145,8 @@ public partial class GameManager : Node2D
|
||||||
{
|
{
|
||||||
Unpause();
|
Unpause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelayPlayerSpawn()
|
private void DelayPlayerSpawn()
|
||||||
|
|
@ -365,12 +369,20 @@ public partial class GameManager : Node2D
|
||||||
|
|
||||||
public void RecalculateTilemap(Vector2 position)
|
public void RecalculateTilemap(Vector2 position)
|
||||||
{
|
{
|
||||||
CallDeferred(MethodName.RecalculateTilemapDeferred, position);
|
//CallDeferred(MethodName.RecalculateTilemapDeferred, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecalculateTilemapDeferred(Vector2 position)
|
private void RecalculateTilemapDeferred(Vector2 position)
|
||||||
{
|
{
|
||||||
NavigationTilemap.Recalculate(position);
|
//NavigationTilemap.Recalculate(position);
|
||||||
|
GD.Print("Rebaking tilemap");
|
||||||
|
NavigationRegion.BakeNavigationPolygon(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RebakeNavigation()
|
||||||
|
{
|
||||||
|
GD.Print("Rebaking tilemap");
|
||||||
|
//NavigationRegion.BakeNavigationPolygon(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public partial class TilemapAvoidance : TileMapLayer
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
//NavigationServer2D.MapSetEdgeConnectionMargin(this.TileSet.GetRid(), 0f);
|
//NavigationServer2D.MapSetEdgeConnectionMargin(this.TileSet.GetRid(), 0f);
|
||||||
_ = RefreshNavigationAsync();
|
//_ = RefreshNavigationAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,16 +41,16 @@ public partial class TilemapAvoidance : TileMapLayer
|
||||||
//
|
//
|
||||||
if (_needsFullCheck)
|
if (_needsFullCheck)
|
||||||
{
|
{
|
||||||
var spaceState = GetWorld2D().DirectSpaceState;
|
// var spaceState = GetWorld2D().DirectSpaceState;
|
||||||
var globalCoords = ToGlobal(this.MapToLocal(coords));
|
// var globalCoords = ToGlobal(this.MapToLocal(coords));
|
||||||
var query = new PhysicsPointQueryParameters2D();
|
// var query = new PhysicsPointQueryParameters2D();
|
||||||
query.Position = globalCoords;
|
// query.Position = globalCoords;
|
||||||
query.CollisionMask = ObstaclesCollisionMask;
|
// query.CollisionMask = ObstaclesCollisionMask;
|
||||||
query.CollideWithBodies = true;
|
// query.CollideWithBodies = true;
|
||||||
query.CollideWithAreas = true;
|
// query.CollideWithAreas = true;
|
||||||
|
//
|
||||||
var result = spaceState.IntersectPoint(query);
|
// var result = spaceState.IntersectPoint(query);
|
||||||
if (result.Count > 0) return true;
|
// if (result.Count > 0) return true;
|
||||||
|
|
||||||
//_needsFullCheck = false;
|
//_needsFullCheck = false;
|
||||||
return _solidLayers.Aggregate(false,
|
return _solidLayers.Aggregate(false,
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ Interactable=""
|
||||||
Solid=""
|
Solid=""
|
||||||
Acid=""
|
Acid=""
|
||||||
Destroyable=""
|
Destroyable=""
|
||||||
|
navigation_polygon_source_geometry_group=""
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
|
@ -342,6 +343,10 @@ locale/translations=PackedStringArray("res://Dialogue/Translations/dialogic_char
|
||||||
2d_physics/layer_9="Acid"
|
2d_physics/layer_9="Acid"
|
||||||
2d_physics/layer_10="Conveyor"
|
2d_physics/layer_10="Conveyor"
|
||||||
|
|
||||||
|
[navigation]
|
||||||
|
|
||||||
|
2d/use_edge_connections=false
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
common/physics_jitter_fix=0.0
|
common/physics_jitter_fix=0.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue