Formatting of Game.cs.

WorldChunkRefactoring
Martin Felis 2023-08-28 14:01:09 +02:00
parent 76a7abf22f
commit 64e7db9800
1 changed files with 8 additions and 7 deletions

View File

@ -114,7 +114,8 @@ public class Game : Spatial
_streamContainer.Connect("TileHovered", this, nameof(OnTileHovered)); _streamContainer.Connect("TileHovered", this, nameof(OnTileHovered));
_tileWorld.Connect("WorldGenerated", this, nameof(OnWorldGenerated)); _tileWorld.Connect("WorldGenerated", this, nameof(OnWorldGenerated));
_generateWorldButton.Connect("pressed", this, nameof(OnGenerateButton)); _generateWorldButton.Connect("pressed", this, nameof(OnGenerateButton));
_player.TaskQueueComponent.Connect("StartInteraction", _interactionSystem, nameof(_interactionSystem.OnStartInteraction)); _player.TaskQueueComponent.Connect("StartInteraction", _interactionSystem,
nameof(_interactionSystem.OnStartInteraction));
_player.Connect("GoldCountChanged", this, nameof(OnGoldCountChanged)); _player.Connect("GoldCountChanged", this, nameof(OnGoldCountChanged));
// register entity events // register entity events
@ -259,7 +260,7 @@ public class Game : Spatial
{ {
_player.InteractionComponent.EmitSignal("InteractionEnd"); _player.InteractionComponent.EmitSignal("InteractionEnd");
} }
_player.TaskQueueComponent.Reset(); _player.TaskQueueComponent.Reset();
_player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask( _player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask(
new NavigationComponent.NavigationPoint(tile.GlobalTranslation))); new NavigationComponent.NavigationPoint(tile.GlobalTranslation)));
@ -273,7 +274,7 @@ public class Game : Spatial
_mouseWorldLabel.Text = highlightTransform.origin.ToString(); _mouseWorldLabel.Text = highlightTransform.origin.ToString();
_mouseTileOffsetLabel.Text = tile.OffsetCoords.ToString(); _mouseTileOffsetLabel.Text = tile.OffsetCoords.ToString();
_mouseTileCubeLabel.Text = tile.Cell.CubeCoords.ToString(); _mouseTileCubeLabel.Text = tile.Cell.CubeCoords.ToString();
_player.Navigation.FindPath(_player, _player.GlobalTranslation, tile.GlobalTranslation); _player.Navigation.FindPath(_player, _player.GlobalTranslation, tile.GlobalTranslation);
} }
@ -303,7 +304,7 @@ public class Game : Spatial
playerStartTransform.basis.Quat()); playerStartTransform.basis.Quat());
_goldCountLabel.Text = "0"; _goldCountLabel.Text = "0";
foreach (Spatial entity in GetNode("Entities").GetChildren()) foreach (Spatial entity in GetNode("Entities").GetChildren())
{ {
Transform entityTransform = entity.Transform; Transform entityTransform = entity.Transform;
@ -320,14 +321,14 @@ public class Game : Spatial
GD.Print("Using new map. Size: " + (int)_tileWorld.ColormapImage.GetSize().x); GD.Print("Using new map. Size: " + (int)_tileWorld.ColormapImage.GetSize().x);
_goldCountLabel.Text = "0"; _goldCountLabel.Text = "0";
UpdateWorldTextures(); UpdateWorldTextures();
_streamContainer.OnWorldGenerated(); _streamContainer.OnWorldGenerated();
// Reset player transform to offset 0,0 and at current height // Reset player transform to offset 0,0 and at current height
ResetGameState(); ResetGameState();
// Connect all signals of the generated world // Connect all signals of the generated world
foreach (Node node in _tileWorld.Entities.GetChildren()) foreach (Node node in _tileWorld.Entities.GetChildren())
{ {
@ -341,7 +342,7 @@ public class Game : Spatial
private void UpdateWorldTextures() private void UpdateWorldTextures()
{ {
GD.Print("Updating World textures"); GD.Print("Updating World textures");
ImageTexture newWorldTexture = new ImageTexture(); ImageTexture newWorldTexture = new ImageTexture();
newWorldTexture.CreateFromImage(_tileWorld.ColormapImage, newWorldTexture.CreateFromImage(_tileWorld.ColormapImage,
(uint)(Texture.FlagsEnum.Mipmaps | Texture.FlagsEnum.Repeat)); (uint)(Texture.FlagsEnum.Mipmaps | Texture.FlagsEnum.Repeat));