/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ using System; using Cinemachine; using GameCult.Aetheria.State.Verse; using GameCult.Mesh; using UnityEngine; using UnityEngine.UI; public sealed class AetheriaUnityGameplaySceneWiring { public ZoneRenderer ZoneRenderer { get; set; } public CinemachineVirtualCamera DockCamera { get; set; } public CinemachineVirtualCamera FollowCamera { get; set; } public MenuPanel Menu { get; set; } public TradeMenu TradeMenu { get; set; } public CanvasGroup GameplayUI { get; set; } public InventoryMenu Inventory { get; set; } public InventoryPanel ShipPanel { get; set; } public InventoryPanel TargetShipPanel { get; set; } public SchematicDisplay SchematicDisplay { get; set; } public SchematicDisplay TargetSchematicDisplay { get; set; } public PlaceUIElementWorldspace[] Crosshairs { get; set; } = Array.Empty(); public Prototype LockIndicator { get; set; } public GameObject HitMarker { get; set; } public float HitMarkerDuration { get; set; } public Image TargetShieldsBackground { get; set; } public Image TargetShieldsIcon { get; set; } public Color ShieldColor { get; set; } public Color NoShieldColor { get; set; } public Sprite ShieldIcon { get; set; } public Sprite NoShieldIcon { get; set; } public Prototype HostileTargetIndicator { get; set; } public Prototype FriendlyTargetIndicator { get; set; } private AetheriaClientState _targetPresentationState; private AetheriaClientState TargetPresentationState { get { _targetPresentationState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-target-presentation"); return _targetPresentationState; } } public PlaceUIElementWorldspace ViewDot { get; set; } public PlaceUIElementWorldspace TargetIndicator { get; set; } public Image TargetHitpointsFill { get; set; } public Image TargetVisibilityFill { get; set; } public Image VisibilityToTargetFill { get; set; } public Image TargetShieldsFill { get; set; } public MainMenu MainMenu { get; set; } public void ConfigureCurrentEntityPresentation( AetheriaUnityCurrentEntityPresentation presentation, AetheriaRuntimeCatalogSnapshot runtimeCatalog) { if (presentation == null) return; presentation.ZoneRenderer = ZoneRenderer; presentation.RuntimeCatalog = runtimeCatalog; presentation.DockCamera = DockCamera; presentation.FollowCamera = FollowCamera; presentation.Menu = Menu; presentation.TradeMenu = TradeMenu; presentation.GameplayUI = GameplayUI; presentation.ShipPanel = ShipPanel; presentation.TargetShipPanel = TargetShipPanel; presentation.SchematicDisplay = SchematicDisplay; presentation.TargetSchematicDisplay = TargetSchematicDisplay; presentation.Crosshairs = Crosshairs; presentation.LockIndicator = LockIndicator; presentation.HitMarker = HitMarker; presentation.HitMarkerDuration = HitMarkerDuration; presentation.TargetImages = new ImageTargetPresentation { TargetShieldsBackground = TargetShieldsBackground, TargetShieldsIcon = TargetShieldsIcon, ShieldColor = ShieldColor, NoShieldColor = NoShieldColor, ShieldIcon = ShieldIcon, NoShieldIcon = NoShieldIcon }; } public void ConfigureTargetPresentation( AetheriaUnityTargetPresentation presentation, AetheriaRuntimeCatalogSnapshot runtimeCatalog, AetheriaUnityPresentationEntityIndex presentationEntityIndex) { if (presentation == null) return; presentation.ZoneRenderer = ZoneRenderer; presentation.RuntimeCatalog = runtimeCatalog; presentation.HostileTargetIndicator = HostileTargetIndicator; presentation.FriendlyTargetIndicator = FriendlyTargetIndicator; presentation.ViewDot = ViewDot; presentation.TargetIndicator = TargetIndicator; presentation.TargetHitpointsFill = TargetHitpointsFill; presentation.TargetVisibilityFill = TargetVisibilityFill; presentation.VisibilityToTargetFill = VisibilityToTargetFill; presentation.TargetShieldsFill = TargetShieldsFill; presentation.ResolveEntity = daemonEntityIndex => presentationEntityIndex != null && presentationEntityIndex.TryGetPresentationEntityByDaemonIndex(daemonEntityIndex, out var entity) ? entity : null; presentation.ResolveZoneContacts = ReadZoneContacts; } private AetheriaRuntimeZoneContactsDocument ReadZoneContacts() { try { return TargetPresentationState.ZoneContacts.Latest(); } catch (Exception ex) { Debug.LogWarning($"Failed to read Aetheria zone contacts for target presentation: {ex.Message}"); return null; } } public void ConfigureInventoryDragSession(AetheriaUnityDragSession dragSession) { Inventory?.SetDragSession(dragSession); ShipPanel?.SetDragSession(dragSession); TargetShipPanel?.SetDragSession(dragSession); } public void ConfigureActionBarPresentation( AetheriaUnityActionBarPresentation actionBarPresentation, AetheriaUnityGameplayInputShell gameplayInputShell, AetheriaRuntimeCatalogSnapshot runtimeCatalog, GameSettings settings, Func resolveCurrentEntity, Func resolveActionBarControl) { actionBarPresentation?.Bind( gameplayInputShell?.ActionBarSlots ?? Array.Empty(), runtimeCatalog, settings, resolveCurrentEntity, resolveActionBarControl); Inventory?.SetActionBarPresentation(actionBarPresentation); } public void ConfigureRuntimeInputScreenShell(AetheriaUnityMenuShell menuShell) { MainMenu?.SetRuntimeInputScreenShell(menuShell.CanOpenRuntimeInputScreen, menuShell.ShowRuntimeInputScreen); } public void ConfigurePresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex) { Inventory?.SetPresentationEntityIndex(presentationEntityIndex); ShipPanel?.SetPresentationEntityIndex(presentationEntityIndex); TargetShipPanel?.SetPresentationEntityIndex(presentationEntityIndex); foreach (var localMenu in UnityEngine.Object.FindObjectsByType(FindObjectsSortMode.None)) localMenu.SetPresentationEntityIndex(presentationEntityIndex); } }