Removed OmniLights from Walls, added spotlights to robots. Added vase 3D model
This commit is contained in:
Binary file not shown.
@@ -15,3 +15,10 @@ script = ExtResource("2_j80uv")
|
|||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1405728816]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1405728816]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.05883789, 0.29821777, -0.01171875)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.05883789, 0.29821777, -0.01171875)
|
||||||
shape = SubResource("BoxShape3D_vquur")
|
shape = SubResource("BoxShape3D_vquur")
|
||||||
|
|
||||||
|
[node name="SpotLight3D" type="SpotLight3D" parent="." unique_id=1638370223]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.37939095, -0.31055498)
|
||||||
|
light_energy = 16.0
|
||||||
|
spot_range = 4.0
|
||||||
|
spot_attenuation = 0.0
|
||||||
|
spot_angle = 75.0
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ public static class SaveGameDataApplier
|
|||||||
|
|
||||||
Tile tile = layer.tiles[savedTile.X, savedTile.Y];
|
Tile tile = layer.tiles[savedTile.X, savedTile.Y];
|
||||||
tile.collapsedMesh = savedTile.CollapsedMesh;
|
tile.collapsedMesh = savedTile.CollapsedMesh;
|
||||||
tile.containsLight = savedTile.ContainsLight;
|
|
||||||
tile.containsDecoration = savedTile.ContainsDecoration;
|
tile.containsDecoration = savedTile.ContainsDecoration;
|
||||||
tile.containsResource = savedTile.ContainsResource;
|
tile.containsResource = savedTile.ContainsResource;
|
||||||
tile.wasVisited = savedTile.WasVisited;
|
tile.wasVisited = savedTile.WasVisited;
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ public static class SaveGameDataFactory
|
|||||||
X = tile.GridPosition.X,
|
X = tile.GridPosition.X,
|
||||||
Y = tile.GridPosition.Y,
|
Y = tile.GridPosition.Y,
|
||||||
CollapsedMesh = tile.collapsedMesh,
|
CollapsedMesh = tile.collapsedMesh,
|
||||||
ContainsLight = tile.containsLight,
|
|
||||||
ContainsDecoration = tile.containsDecoration,
|
ContainsDecoration = tile.containsDecoration,
|
||||||
ContainsResource = tile.containsResource,
|
ContainsResource = tile.containsResource,
|
||||||
WasVisited = tile.wasVisited,
|
WasVisited = tile.wasVisited,
|
||||||
|
|||||||
@@ -101,10 +101,11 @@ public partial class RobotList : PanelContainer
|
|||||||
robot.Position = GameData.map[0].tiles[0, 0].Position;
|
robot.Position = GameData.map[0].tiles[0, 0].Position;
|
||||||
robot.robotType = spawnId;
|
robot.robotType = spawnId;
|
||||||
GetNode("/root/Main/World").AddChild(robot);
|
GetNode("/root/Main/World").AddChild(robot);
|
||||||
|
LightHandler.lights.Add(robot.GetNode("./SpotLight3D") as SpotLight3D);
|
||||||
robot.Name = $"Robot #{GameData.robots.Count}";
|
robot.Name = $"Robot #{GameData.robots.Count}";
|
||||||
GameData.robots.Add(robot);
|
GameData.robots.Add(robot);
|
||||||
spawnId = "";
|
spawnId = "";
|
||||||
|
LightHandler.RedrawLights(GameData.lightColor);
|
||||||
ReloadRobots();
|
ReloadRobots();
|
||||||
ReloadSelectableRobots();
|
ReloadSelectableRobots();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
public static class LightHandler
|
public static class LightHandler
|
||||||
{
|
{
|
||||||
public static List<OmniLight3D> lights = new List<OmniLight3D>();
|
public static List<SpotLight3D> lights = new List<SpotLight3D>();
|
||||||
|
|
||||||
public static void RedrawLights(Color color)
|
public static void RedrawLights(Color color)
|
||||||
{
|
{
|
||||||
List<OmniLight3D> availableLights = new List<OmniLight3D>();
|
List<SpotLight3D> availableLights = new List<SpotLight3D>();
|
||||||
|
|
||||||
foreach (OmniLight3D light in lights)
|
foreach (SpotLight3D light in lights)
|
||||||
{
|
{
|
||||||
if (!GodotObject.IsInstanceValid(light)) continue;
|
if (!GodotObject.IsInstanceValid(light)) continue;
|
||||||
|
|
||||||
|
|||||||
+2
-28
@@ -11,7 +11,7 @@ public partial class Tile
|
|||||||
public Vector2I GridPosition;
|
public Vector2I GridPosition;
|
||||||
public Node3D ContentNode;
|
public Node3D ContentNode;
|
||||||
|
|
||||||
public bool containsLight, containsDecoration, containsResource;
|
public bool containsDecoration, containsResource;
|
||||||
public GameResource resource;
|
public GameResource resource;
|
||||||
public bool wasVisited;
|
public bool wasVisited;
|
||||||
public event EventHandler OnTileVisited;
|
public event EventHandler OnTileVisited;
|
||||||
@@ -74,7 +74,6 @@ public partial class Tile
|
|||||||
public void Reset(Dictionary<string, MeshInstance3D> tileMeshes)
|
public void Reset(Dictionary<string, MeshInstance3D> tileMeshes)
|
||||||
{
|
{
|
||||||
collapsedMesh = null;
|
collapsedMesh = null;
|
||||||
containsLight = false;
|
|
||||||
containsDecoration = false;
|
containsDecoration = false;
|
||||||
containsResource = false;
|
containsResource = false;
|
||||||
resource = null;
|
resource = null;
|
||||||
@@ -86,36 +85,11 @@ public partial class Tile
|
|||||||
{
|
{
|
||||||
foreach (Placeholder placeholder in placeholders)
|
foreach (Placeholder placeholder in placeholders)
|
||||||
{
|
{
|
||||||
if (containsLight && placeholder.name == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
|
if (containsResource && placeholder.name == "resource") SpawnResource(contentMeshes["resource"], placeholder, transform);
|
||||||
else if (containsResource && placeholder.name == "resource") SpawnResource(contentMeshes["resource"], placeholder, transform);
|
|
||||||
else if (containsDecoration && placeholder.name != "light" && placeholder.name != "resource") SpawnDecorations(contentMeshes, placeholder, transform);
|
else if (containsDecoration && placeholder.name != "light" && placeholder.name != "resource") SpawnDecorations(contentMeshes, placeholder, transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnLight(MeshInstance3D lightMesh, Placeholder placeholder, Transform3D transform)
|
|
||||||
{
|
|
||||||
MeshInstance3D light = new MeshInstance3D
|
|
||||||
{
|
|
||||||
Mesh = lightMesh.Mesh,
|
|
||||||
Position = placeholder.transform.Origin
|
|
||||||
};
|
|
||||||
OmniLight3D lightSource = new OmniLight3D()
|
|
||||||
{
|
|
||||||
OmniAttenuation = 2f,
|
|
||||||
LightColor = GameData.lightColor,
|
|
||||||
ShadowEnabled = true,
|
|
||||||
LightEnergy = 100f,
|
|
||||||
LightIndirectEnergy = 1.5f,
|
|
||||||
OmniRange = 20f,
|
|
||||||
Position = placeholder.transform.Origin
|
|
||||||
};
|
|
||||||
lightSource.Position.MoveToward(transform.Origin, 0.1f);
|
|
||||||
LightHandler.lights.Add(lightSource);
|
|
||||||
light.AddChild(lightSource);
|
|
||||||
ContentNode.AddChild(light);
|
|
||||||
light.LookAt(transform.Origin, Vector3.Up);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SpawnResource(MeshInstance3D resourceMesh, Placeholder placeholder, Transform3D transform)
|
private void SpawnResource(MeshInstance3D resourceMesh, Placeholder placeholder, Transform3D transform)
|
||||||
{
|
{
|
||||||
MeshInstance3D resource = new MeshInstance3D
|
MeshInstance3D resource = new MeshInstance3D
|
||||||
|
|||||||
+2
-18
@@ -142,6 +142,8 @@ public partial class World : Node3D
|
|||||||
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);
|
||||||
|
LightHandler.lights.Add(robot.GetNode("./SpotLight3D") as SpotLight3D);
|
||||||
|
LightHandler.RedrawLights(lightColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnSavedRobots(List<RobotSaveData> savedRobots)
|
private void SpawnSavedRobots(List<RobotSaveData> savedRobots)
|
||||||
@@ -193,7 +195,6 @@ public partial class World : Node3D
|
|||||||
{
|
{
|
||||||
map[0].tiles[0, 0].wasVisited = true;
|
map[0].tiles[0, 0].wasVisited = true;
|
||||||
map[0].tiles[0, 0].containsDecoration = 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].containsResource = false;
|
||||||
map[0].tiles[0, 0].ContentNode.Visible = true;
|
map[0].tiles[0, 0].ContentNode.Visible = true;
|
||||||
}
|
}
|
||||||
@@ -234,22 +235,10 @@ public partial class World : Node3D
|
|||||||
private void DistributeTileContent(Layer layer)
|
private void DistributeTileContent(Layer layer)
|
||||||
{
|
{
|
||||||
int currentDecoration = 0;
|
int currentDecoration = 0;
|
||||||
int currentLight = 0;
|
|
||||||
int currentResource = 0;
|
int currentResource = 0;
|
||||||
|
|
||||||
int posX, posY;
|
int posX, posY;
|
||||||
|
|
||||||
while (currentLight < layerSize * 3)
|
|
||||||
{
|
|
||||||
posX = rand.Next(layerSize);
|
|
||||||
posY = rand.Next(layerSize);
|
|
||||||
if (CannotContainLight(layer.tiles[posX, posY])) continue;
|
|
||||||
if (layer.tiles[posX, posY].containsLight) continue;
|
|
||||||
|
|
||||||
layer.tiles[posX, posY].containsLight = true;
|
|
||||||
currentLight++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (currentDecoration < layerSize)
|
while (currentDecoration < layerSize)
|
||||||
{
|
{
|
||||||
posX = rand.Next(layerSize);
|
posX = rand.Next(layerSize);
|
||||||
@@ -273,11 +262,6 @@ public partial class World : Node3D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CannotContainLight(Tile tile)
|
|
||||||
{
|
|
||||||
return tile.collapsedMesh == "junction" || tile.collapsedMesh == "gate";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleRenderData(List<TileRenderData> renderData)
|
private void HandleRenderData(List<TileRenderData> renderData)
|
||||||
{
|
{
|
||||||
multiMeshHandler.Build(renderData);
|
multiMeshHandler.Build(renderData);
|
||||||
|
|||||||
Reference in New Issue
Block a user