Removed OmniLights from Walls, added spotlights to robots. Added vase 3D model
This commit is contained in:
@@ -137,7 +137,6 @@ public static class SaveGameDataApplier
|
||||
|
||||
Tile tile = layer.tiles[savedTile.X, savedTile.Y];
|
||||
tile.collapsedMesh = savedTile.CollapsedMesh;
|
||||
tile.containsLight = savedTile.ContainsLight;
|
||||
tile.containsDecoration = savedTile.ContainsDecoration;
|
||||
tile.containsResource = savedTile.ContainsResource;
|
||||
tile.wasVisited = savedTile.WasVisited;
|
||||
|
||||
@@ -135,7 +135,6 @@ public static class SaveGameDataFactory
|
||||
X = tile.GridPosition.X,
|
||||
Y = tile.GridPosition.Y,
|
||||
CollapsedMesh = tile.collapsedMesh,
|
||||
ContainsLight = tile.containsLight,
|
||||
ContainsDecoration = tile.containsDecoration,
|
||||
ContainsResource = tile.containsResource,
|
||||
WasVisited = tile.wasVisited,
|
||||
|
||||
@@ -101,10 +101,11 @@ public partial class RobotList : PanelContainer
|
||||
robot.Position = GameData.map[0].tiles[0, 0].Position;
|
||||
robot.robotType = spawnId;
|
||||
GetNode("/root/Main/World").AddChild(robot);
|
||||
LightHandler.lights.Add(robot.GetNode("./SpotLight3D") as SpotLight3D);
|
||||
robot.Name = $"Robot #{GameData.robots.Count}";
|
||||
GameData.robots.Add(robot);
|
||||
spawnId = "";
|
||||
|
||||
LightHandler.RedrawLights(GameData.lightColor);
|
||||
ReloadRobots();
|
||||
ReloadSelectableRobots();
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ using System.Collections.Generic;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
+2
-28
@@ -11,7 +11,7 @@ public partial class Tile
|
||||
public Vector2I GridPosition;
|
||||
public Node3D ContentNode;
|
||||
|
||||
public bool containsLight, containsDecoration, containsResource;
|
||||
public bool containsDecoration, containsResource;
|
||||
public GameResource resource;
|
||||
public bool wasVisited;
|
||||
public event EventHandler OnTileVisited;
|
||||
@@ -74,7 +74,6 @@ public partial class Tile
|
||||
public void Reset(Dictionary<string, MeshInstance3D> tileMeshes)
|
||||
{
|
||||
collapsedMesh = null;
|
||||
containsLight = false;
|
||||
containsDecoration = false;
|
||||
containsResource = false;
|
||||
resource = null;
|
||||
@@ -86,36 +85,11 @@ public partial class Tile
|
||||
{
|
||||
foreach (Placeholder placeholder in placeholders)
|
||||
{
|
||||
if (containsLight && placeholder.name == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
|
||||
else if (containsResource && placeholder.name == "resource") SpawnResource(contentMeshes["resource"], placeholder, transform);
|
||||
if (containsResource && placeholder.name == "resource") SpawnResource(contentMeshes["resource"], 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)
|
||||
{
|
||||
MeshInstance3D resource = new MeshInstance3D
|
||||
|
||||
+2
-18
@@ -142,6 +142,8 @@ public partial class World : Node3D
|
||||
robot.Position = map[0].tiles[0, 0].Position;
|
||||
AddChild(robot);
|
||||
robots.Add(robot);
|
||||
LightHandler.lights.Add(robot.GetNode("./SpotLight3D") as SpotLight3D);
|
||||
LightHandler.RedrawLights(lightColor);
|
||||
}
|
||||
|
||||
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].containsDecoration = true;
|
||||
map[0].tiles[0, 0].containsLight = true;
|
||||
map[0].tiles[0, 0].containsResource = false;
|
||||
map[0].tiles[0, 0].ContentNode.Visible = true;
|
||||
}
|
||||
@@ -234,22 +235,10 @@ public partial class World : Node3D
|
||||
private void DistributeTileContent(Layer layer)
|
||||
{
|
||||
int currentDecoration = 0;
|
||||
int currentLight = 0;
|
||||
int currentResource = 0;
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
multiMeshHandler.Build(renderData);
|
||||
|
||||
Reference in New Issue
Block a user