Fixed build NavigationTests.cs, still defunct though.
parent
cfb731c27e
commit
453cfcde00
|
@ -27,18 +27,16 @@ public class NavigationTests : Spatial {
|
|||
|
||||
_editorUi = GetNode<EditorUI>("EditorUI");
|
||||
_world = GetNode<World>("World");
|
||||
_world.Connect("WorldGenerated", this, nameof(OnWorldGenerated));
|
||||
_streamContainer = GetNode<StreamContainer>("StreamContainer");
|
||||
|
||||
_streamContainer.SetCenterTile(_currentTile);
|
||||
|
||||
_player = GetNode<Player>("Player");
|
||||
_playerNavigationComponent = _player.GetNode<NavigationComponent>("Navigation");
|
||||
|
||||
// input handling
|
||||
// _groundLayer.Connect("input_event", this, nameof(OnGroundLayerInputEvent));
|
||||
// connect signals
|
||||
_world.Connect("TileClicked", this, nameof(OnTileClicked));
|
||||
_world.Connect("TileHovered", this, nameof(OnTileHovered));
|
||||
_world.Connect("OnWorldViewTileTypeImageChanged", this, nameof(OnWorldViewTileTypeImageChanged));
|
||||
_world.Connect("OnHeightmapImageChanged", this, nameof(OnHeightmapImageChanged));
|
||||
|
||||
|
||||
CorrectEntityGridPositions();
|
||||
}
|
||||
|
@ -62,24 +60,21 @@ public class NavigationTests : Spatial {
|
|||
}
|
||||
}
|
||||
|
||||
public void OnWorldGenerated() {
|
||||
_streamContainer.OnWorldGenerated();
|
||||
|
||||
// Properly place the Player
|
||||
Vector2 centerTileCoord = (Vector2.One * _world.Size / 2).Round();
|
||||
Vector3 worldCenterTileCoords = _world.GetTileWorldCenterFromOffset(centerTileCoord);
|
||||
worldCenterTileCoords.y = _world.GetHeightAtOffset(centerTileCoord);
|
||||
Transform playerTransform = Transform.Identity;
|
||||
playerTransform.origin = worldCenterTileCoords;
|
||||
_player.Transform = playerTransform;
|
||||
|
||||
ImageTexture newWorldTexture = new();
|
||||
newWorldTexture.CreateFromImage(_world.ColormapImage,
|
||||
private void OnHeightmapImageChanged(Image heightmapImage) {
|
||||
ImageTexture newHeightmapTexture = new();
|
||||
newHeightmapTexture.CreateFromImage(heightmapImage,
|
||||
(uint)(Texture.FlagsEnum.Mipmaps | Texture.FlagsEnum.Repeat));
|
||||
_tileMaterial.SetShaderParam("MapAlbedoTexture", newWorldTexture);
|
||||
_tileMaterial.SetShaderParam("TextureSize", (int)_world.ColormapImage.GetSize().x);
|
||||
}
|
||||
|
||||
CorrectEntityGridPositions();
|
||||
private void OnWorldViewTileTypeImageChanged(Image viewTileTypeImage) {
|
||||
ImageTexture newWorldTexture = new();
|
||||
newWorldTexture.CreateFromImage(viewTileTypeImage,
|
||||
(uint)(Texture.FlagsEnum.Mipmaps | Texture.FlagsEnum.Repeat));
|
||||
|
||||
_tileMaterial.SetShaderParam("MapAlbedoTexture", newWorldTexture);
|
||||
_tileMaterial.SetShaderParam("TextureSize", (int)newWorldTexture.GetSize().x);
|
||||
_tileMaterial.SetShaderParam("CoordinateOffsetU", (int)_world.WorldTextureCoordinateOffset.x);
|
||||
_tileMaterial.SetShaderParam("CoordinateOffsetV", (int)_world.WorldTextureCoordinateOffset.y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,12 +93,6 @@ public class NavigationTests : Spatial {
|
|||
}
|
||||
|
||||
Vector2 planeCoords = _hexGrid.GetHexCenterFromOffset(_currentTile.OffsetCoords);
|
||||
Transform tileTransform = Transform.Identity;
|
||||
tileTransform.origin.x = planeCoords.x;
|
||||
tileTransform.origin.y = _world.GetHeightAtOffset(_currentTile.OffsetCoords) + 0.1f;
|
||||
tileTransform.origin.z = planeCoords.y;
|
||||
|
||||
_mouseHighlight.Transform = tileTransform;
|
||||
}
|
||||
|
||||
public void OnGroundLayerInputEvent(Node camera, InputEvent inputEvent, Vector3 position, Vector3 normal,
|
||||
|
|
Loading…
Reference in New Issue