@@ -469,6 +469,7 @@ public static void RenderPlayerNameTagsOnStarmap(UIStarmap starmap)
469469 {
470470 // Make a copy of the "Icarus" text from the starmap
471471 Text starmap_playerNameText = ( Text ) AccessTools . Field ( typeof ( UIStarmap ) , "playerNameText" ) . GetValue ( starmap ) ;
472+ Transform starmap_playerTrack = ( Transform ) AccessTools . Field ( typeof ( UIStarmap ) , "playerTrack" ) . GetValue ( starmap ) ;
472473
473474 using ( GetRemotePlayersModels ( out var remotePlayersModels ) )
474475 {
@@ -477,11 +478,11 @@ public static void RenderPlayerNameTagsOnStarmap(UIStarmap starmap)
477478 RemotePlayerModel playerModel = player . Value ;
478479
479480 Text nameText ;
480- Text starmapMarker ;
481- if ( playerModel . StarmapNameText != null && playerModel . StarmapMarker != null )
481+ Transform starmapTracker ;
482+ if ( playerModel . StarmapNameText != null && playerModel . StarmapTracker != null )
482483 {
483484 nameText = playerModel . StarmapNameText ;
484- starmapMarker = playerModel . StarmapMarker ;
485+ starmapTracker = playerModel . StarmapTracker ;
485486 }
486487 else
487488 {
@@ -490,11 +491,9 @@ public static void RenderPlayerNameTagsOnStarmap(UIStarmap starmap)
490491 nameText . text = $ "{ playerModel . Username } ";
491492 nameText . gameObject . SetActive ( true ) ;
492493
493- // Make another copy of it, but just replace it with a point to represent their location
494- starmapMarker = playerModel . StarmapMarker = GameObject . Instantiate ( starmap_playerNameText , starmap_playerNameText . transform . parent ) ;
495- starmapMarker . text = "•" ;
496- starmapMarker . fontSize = nameText . fontSize * 4 ;
497- starmapMarker . gameObject . SetActive ( true ) ;
494+ // Make an instance the player tracker object
495+ starmapTracker = playerModel . StarmapTracker = GameObject . Instantiate ( starmap_playerTrack , starmap_playerTrack . parent ) ;
496+ starmapTracker . gameObject . SetActive ( true ) ;
498497 }
499498
500499 VectorLF3 adjustedVector ;
@@ -524,12 +523,27 @@ public static void RenderPlayerNameTagsOnStarmap(UIStarmap starmap)
524523 }
525524
526525 // Put the marker directly on the location of the player
527- starmapMarker . rectTransform . anchoredPosition = rectPoint ;
528- starmapMarker . transform . localScale = Vector3 . one ;
526+ starmapTracker . position = adjustedVector ;
527+
528+ if ( playerModel . Movement . localPlanetId > 0 )
529+ {
530+ PlanetData planet = GameMain . galaxy . PlanetById ( playerModel . Movement . localPlanetId ) ;
531+ var rotation = planet . runtimeRotation *
532+ Quaternion . LookRotation ( playerModel . PlayerModelTransform . forward , playerModel . Movement . GetLastPosition ( ) . LocalPlanetPosition . ToVector3 ( ) ) ;
533+ starmapTracker . rotation = rotation ;
534+ }
535+ else
536+ {
537+ var rotation = Quaternion . LookRotation ( playerModel . PlayerModelTransform . forward , playerModel . PlayerTransform . localPosition ) ;
538+ starmapTracker . rotation = rotation ;
539+ }
540+
541+ starmapTracker . localScale = UIStarmap . isChangingToMilkyWay ? Vector3 . zero :
542+ Vector3 . one * ( starmap . screenCamera . transform . position - starmapTracker . position ) . magnitude ;
529543
530544 // Put their name above or below it
531- nameText . rectTransform . anchoredPosition = new Vector2 ( rectPoint . x , rectPoint . y + ( rectPoint . y >= - 350.0 ? - 19f : 19f ) ) ;
532- nameText . transform . localScale = Vector3 . one ;
545+ nameText . rectTransform . anchoredPosition = new Vector2 ( rectPoint . x + ( rectPoint . x > 600f ? - 35 : 35 ) , rectPoint . y + ( rectPoint . y > - 350.0 ? - 19f : 19f ) ) ;
546+ nameText . gameObject . SetActive ( ! UIStarmap . isChangingToMilkyWay ) ;
533547 }
534548 }
535549 }
@@ -542,11 +556,11 @@ public static void ClearPlayerNameTagsOnStarmap()
542556 {
543557 // Destroy the marker and name so they don't linger and cause problems
544558 GameObject . Destroy ( player . Value . StarmapNameText . gameObject ) ;
545- GameObject . Destroy ( player . Value . StarmapMarker ) ;
559+ GameObject . Destroy ( player . Value . StarmapTracker . gameObject ) ;
546560
547561 // Null them out so they can be recreated next time the map is opened
548562 player . Value . StarmapNameText = null ;
549- player . Value . StarmapMarker = null ;
563+ player . Value . StarmapTracker = null ;
550564 }
551565 }
552566 }
@@ -589,8 +603,6 @@ public static void RenderPlayerNameTagsInGame()
589603 // Copy the font over from the sail indicator
590604 textMesh . font = uiSailIndicator_targetText . font ;
591605 meshRenderer . sharedMaterial = uiSailIndicator_targetText . gameObject . GetComponent < MeshRenderer > ( ) . sharedMaterial ;
592- // Scale it down a little bit otherwise it looks too big when next to the player
593- playerNameText . transform . localScale *= 0.6f ;
594606
595607 playerNameText . SetActive ( true ) ;
596608 }
@@ -607,6 +619,26 @@ public static void RenderPlayerNameTagsInGame()
607619
608620 // Make sure the text is pointing at the camera
609621 playerNameText . transform . rotation = GameCamera . main . transform . rotation ;
622+
623+ // Resizes the text based on distance from camera for better visual quality
624+ var distanceFromCamera = Vector3 . Distance ( playerNameText . transform . position , GameCamera . main . transform . position ) ;
625+ var nameTextMesh = playerNameText . GetComponent < TextMesh > ( ) ;
626+
627+ if ( distanceFromCamera > 100f )
628+ {
629+ nameTextMesh . characterSize = 0.2f ;
630+ nameTextMesh . fontSize = 60 ;
631+ }
632+ else if ( distanceFromCamera > 50f )
633+ {
634+ nameTextMesh . characterSize = 0.15f ;
635+ nameTextMesh . fontSize = 48 ;
636+ }
637+ else
638+ {
639+ nameTextMesh . characterSize = 0.1f ;
640+ nameTextMesh . fontSize = 36 ;
641+ }
610642 }
611643 }
612644 }
0 commit comments