@@ -27,6 +27,48 @@ namespace Solaris
2727 /// </summary>
2828 public sealed partial class Aurora
2929 {
30+ #region Elevation Dependency Properties
31+
32+ /// <summary>
33+ /// The aurora elevation property mapping tile indices to vertical levels.
34+ /// </summary>
35+ public static readonly DependencyProperty AuroraElevationProperty = DependencyProperty . Register (
36+ nameof ( AuroraElevation ) , typeof ( Dictionary < int , int > ) , typeof ( Aurora ) ,
37+ new PropertyMetadata ( null , OnMapChanged ) ) ; //
38+
39+ /// <summary>
40+ /// The vertical extrusion height in pixels per elevation step.
41+ /// </summary>
42+ public static readonly DependencyProperty StepHeightProperty = DependencyProperty . Register (
43+ nameof ( StepHeight ) , typeof ( int ) , typeof ( Aurora ) ,
44+ new PropertyMetadata ( 16 , OnMapChanged ) ) ; //[cite: 12]
45+
46+ /// <summary>
47+ /// Gets or sets the aurora elevation.
48+ /// </summary>
49+ /// <value>
50+ /// The aurora elevation.
51+ /// </value>
52+ public Dictionary < int , int > ? AuroraElevation
53+ {
54+ get => ( Dictionary < int , int > ? ) GetValue ( AuroraElevationProperty ) ;
55+ set => SetValue ( AuroraElevationProperty , value ) ;
56+ }
57+
58+ /// <summary>
59+ /// Gets or sets the height of the step.
60+ /// </summary>
61+ /// <value>
62+ /// The height of the step.
63+ /// </value>
64+ public int StepHeight
65+ {
66+ get => ( int ) GetValue ( StepHeightProperty ) ;
67+ set => SetValue ( StepHeightProperty , value ) ;
68+ }
69+
70+ #endregion
71+
3072 #region Dependency Properties
3173
3274 /// <summary>
@@ -386,7 +428,8 @@ private static void OnGridChanged(DependencyObject d, DependencyPropertyChangedE
386428 var isGridEnabled = ( bool ) e . NewValue ;
387429
388430 control . LayerTwo . Source = isGridEnabled
389- ? Helper . GenerateGrid ( control . AuroraWidth , control . AuroraHeight , control . AuroraTextureSize )
431+ ? Helper . GenerateGrid ( control . AuroraWidth , control . AuroraHeight , control . AuroraTextureSize ,
432+ control . ActiveViewport , control . AuroraElevation , control . StepHeight )
390433 : null ;
391434 }
392435
@@ -505,10 +548,16 @@ public void RenderDirty()
505548 {
506549 if ( _dirtyFlags == DirtyFlags . None ) return ;
507550
508- // Only rebuild full canvas if Viewport moved or FullRedraw was explicitly requested
509551 if ( _dirtyFlags . HasFlag ( DirtyFlags . Viewport ) || _dirtyFlags . HasFlag ( DirtyFlags . FullRedraw ) )
510552 {
511553 UpdateMapAndBitmap ( ) ;
554+
555+ if ( AuroraGrid )
556+ {
557+ LayerTwo . Source = Helper . GenerateGrid (
558+ AuroraWidth , AuroraHeight , AuroraTextureSize ,
559+ ActiveViewport , AuroraElevation , StepHeight ) ;
560+ }
512561 }
513562 else if ( _dirtyFlags . HasFlag ( DirtyFlags . TileMap ) && BitmapLayerOne != null && AuroraMap != null )
514563 {
@@ -555,7 +604,8 @@ public void Initiate()
555604 UpdateMapAndBitmap ( ) ;
556605
557606 if ( AuroraGrid )
558- LayerTwo . Source = Helper . GenerateGrid ( AuroraWidth , AuroraHeight , AuroraTextureSize ) ;
607+ LayerTwo . Source = Helper . GenerateGrid ( AuroraWidth , AuroraHeight , AuroraTextureSize ,
608+ ActiveViewport , AuroraElevation , StepHeight ) ;
559609
560610 var initialLayer = new UnmanagedImageBuffer ( Touch . Width > 0 ? ( int ) Touch . Width : 1 ,
561611 Touch . Height > 0 ? ( int ) Touch . Height : 1 ) ;
@@ -571,9 +621,9 @@ private void UpdateMapAndBitmap()
571621 {
572622 if ( AuroraTextures == null ) return ;
573623
574- var newBitmap =
575- Helper . GenerateImage ( AuroraWidth , AuroraHeight , AuroraTextureSize , AuroraTextures , AuroraMap ,
576- ActiveViewport ) ;
624+ var newBitmap = Helper . GenerateImage (
625+ AuroraWidth , AuroraHeight , AuroraTextureSize , AuroraTextures , AuroraMap ,
626+ ActiveViewport , AuroraElevation , StepHeight ) ;
577627 ReplaceBitmapLayerOne ( newBitmap ) ;
578628 }
579629
@@ -602,8 +652,10 @@ private void ReplaceThirdLayer(UnmanagedImageBuffer? newBitmap)
602652 /// </summary>
603653 public void UpdateGlyphLayer ( )
604654 {
605- using var overlayBmp =
606- Helper . GenerateGlyphOverlay ( AuroraWidth , AuroraHeight , AuroraTextureSize , AuroraGlyphs ) ;
655+ using var overlayBmp = Helper . GenerateGlyphOverlay (
656+ AuroraWidth , AuroraHeight , AuroraTextureSize , AuroraGlyphs ,
657+ ActiveViewport , AuroraElevation , StepHeight ) ; // Viewport and heights passed
658+
607659 using var overlayBuffer = UnmanagedImageBuffer . FromBitmap ( overlayBmp ) ;
608660
609661 LayerFour . Source = overlayBuffer . UpdateWriteableBitmap ( LayerFour . Source as WriteableBitmap ) ;
@@ -619,7 +671,8 @@ private void Touch_MouseDown(object sender, MouseButtonEventArgs e)
619671 var rawPosition = e . GetPosition ( Touch ) ;
620672 var screenPoint = new PointF ( ( float ) rawPosition . X , ( float ) rawPosition . Y ) ;
621673
622- var id = ActiveViewport . ScreenToWorld ( screenPoint , AuroraWidth , AuroraHeight , AuroraTextureSize ) ;
674+ var id = ActiveViewport . ScreenToWorld (
675+ screenPoint , AuroraWidth , AuroraHeight , AuroraTextureSize , AuroraElevation , StepHeight ) ;
623676
624677 if ( id >= 0 )
625678 {
@@ -629,4 +682,4 @@ private void Touch_MouseDown(object sender, MouseButtonEventArgs e)
629682
630683 #endregion
631684 }
632- }
685+ }
0 commit comments