Fixed content visibility and changed spawn creation
This commit is contained in:
@@ -18,12 +18,17 @@ public class MoveNode : ProgramNode
|
|||||||
startPosition = robot.Position;
|
startPosition = robot.Position;
|
||||||
Vector3 target = pathPoints[0] - startPosition;
|
Vector3 target = pathPoints[0] - startPosition;
|
||||||
float distance = target.Length();
|
float distance = target.Length();
|
||||||
|
|
||||||
if (distance < 0.1f)
|
if (distance < 0.1f)
|
||||||
{
|
{
|
||||||
robot.Position = pathPoints[0];
|
robot.Position = pathPoints[0];
|
||||||
Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
|
Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
|
||||||
GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z].wasVisited = true;
|
Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z];
|
||||||
|
if (!tile.wasVisited)
|
||||||
|
{
|
||||||
|
tile.wasVisited = true;
|
||||||
|
tile.ContentNode.Visible = true;
|
||||||
|
}
|
||||||
pathPoints.Remove(pathPoints[0]);
|
pathPoints.Remove(pathPoints[0]);
|
||||||
if (pathPoints.Count <= 0)
|
if (pathPoints.Count <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public partial class Layer : Node3D
|
|||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearDecorations()
|
public void ClearDecorations()
|
||||||
@@ -88,7 +88,8 @@ public partial class Layer : Node3D
|
|||||||
{
|
{
|
||||||
var node = new Node3D
|
var node = new Node3D
|
||||||
{
|
{
|
||||||
Position = tile.Position
|
Position = tile.Position,
|
||||||
|
Visible = false
|
||||||
};
|
};
|
||||||
decorationRoot.AddChild(node);
|
decorationRoot.AddChild(node);
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public partial class Tile
|
|||||||
|
|
||||||
public void SpawnContent(Dictionary<string, MeshInstance3D> contentMeshes, Transform3D transform, List<Placeholder> placeholders)
|
public void SpawnContent(Dictionary<string, MeshInstance3D> contentMeshes, Transform3D transform, List<Placeholder> placeholders)
|
||||||
{
|
{
|
||||||
if(!wasVisited) return;
|
|
||||||
foreach (Placeholder placeholder in placeholders)
|
foreach (Placeholder placeholder in placeholders)
|
||||||
{
|
{
|
||||||
if (containsLight && placeholder.name == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
|
if (containsLight && placeholder.name == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public partial class World : Node3D
|
|||||||
{
|
{
|
||||||
Robot robot = ResourceLoader.LoadRobotPrefab().Instantiate<Robot>();
|
Robot robot = ResourceLoader.LoadRobotPrefab().Instantiate<Robot>();
|
||||||
robot.Name = $"Robot #{robots.Count + 1}";
|
robot.Name = $"Robot #{robots.Count + 1}";
|
||||||
robot.Position = map[0].tiles[0,0].Position;
|
robot.Position = map[0].tiles[0, 0].Position;
|
||||||
AddChild(robot);
|
AddChild(robot);
|
||||||
robots.Add(robot);
|
robots.Add(robot);
|
||||||
}
|
}
|
||||||
@@ -113,10 +113,16 @@ public partial class World : Node3D
|
|||||||
|
|
||||||
map[layer] = layerNode;
|
map[layer] = layerNode;
|
||||||
}
|
}
|
||||||
map[0].tiles[0,0].wasVisited = true;
|
SetupSpawn();
|
||||||
map[0].tiles[0,0].containsDecoration = true;
|
}
|
||||||
map[0].tiles[0,0].containsLight = true;
|
|
||||||
map[0].tiles[0,0].containsResource = false;
|
private void SetupSpawn()
|
||||||
|
{
|
||||||
|
map[0].tiles[0, 0].wasVisited = true;
|
||||||
|
map[0].tiles[0, 0].containsDecoration = true;
|
||||||
|
map[0].tiles[0, 0].containsLight = true;
|
||||||
|
map[0].tiles[0, 0].containsResource = false;
|
||||||
|
map[0].tiles[0, 0].ContentNode.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleTileVisit(int level)
|
private void HandleTileVisit(int level)
|
||||||
|
|||||||
Reference in New Issue
Block a user