Restore the stable legacy Unity project

This commit is contained in:
Meta Vens 2026-08-10 14:57:50 +01:00
commit 7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions

View file

@ -1,64 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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 System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
using GameCult.Mesh;
using UnityEngine;
using UniRx;
using UniRx.Triggers;
using Unity.Mathematics;
using UnityEngine.UIElements;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class InventoryMenu : MonoBehaviour
{
public InventoryPanel[] InventoryPanels;
public PropertiesPanel PropertiesPanel;
public ActionGameManager GameManager;
public RectTransform DragParent;
public ConfirmationDialog Dialog;
// public ClickCatcher Background;
private EquippedItem _selectedEquippedItem;
private AetheriaRuntimeCurrentEntityDocument _shipSettingsCurrentEntity;
private UIDocument _shipSettingsSurfaceDocument;
private UIDocument _cargoItemDetailsSurfaceDocument;
private UIDocument _equippedItemDetailsSurfaceDocument;
private AetheriaUnityActionBarPresentation _actionBarPresentation;
private AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
private AetheriaClientState _runtimeState;
private readonly AetheriaEveUnitySurfaceChrome _shipSettingsSurfaceChrome = PanelChrome(360f, 420f);
private readonly AetheriaEveUnitySurfaceChrome _cargoItemDetailsSurfaceChrome = PanelChrome(420f, 520f);
private readonly AetheriaEveUnitySurfaceChrome _equippedItemDetailsSurfaceChrome = PanelChrome(460f, 560f);
private int _currentPanel = -1;
private int2 _selectedPosition;
private InventoryPanel _selectedPanel;
private ItemInstance _selectedItem;
private ItemData _selectedItemData;
// private List<IDisposable> _backgroundSubscriptions;
// private ItemInstance _dragItem;
// private Transform[] _dragCells;
// private Vector2[] _dragOffsets;
public void SetDragSession(AetheriaUnityDragSession dragSession)
{
if (InventoryPanels == null)
return;
foreach (var panel in InventoryPanels)
panel?.SetDragSession(dragSession);
}
public void SetActionBarPresentation(AetheriaUnityActionBarPresentation actionBarPresentation)
{
_actionBarPresentation = actionBarPresentation;
}
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
{
_presentationEntityIndex = presentationEntityIndex;
}
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-inventory-menu");
// private int2 _dragCellOffset;
// private ItemRotation _originalRotation;
// //private Shape _previousFakeOccupancy;
@ -84,557 +58,145 @@ public class InventoryMenu : MonoBehaviour
// {
// _destroyItem = false;
// });
var hasCurrentEntity = TryResolveCurrentEntity(out var currentEntity);
var cargo = TryResolveCurrentDockingBay(out var dockingBay)
? dockingBay
: currentEntity?.CargoBays.FirstOrDefault();
var cargo = GameManager.DockingBay ?? GameManager.CurrentEntity.CargoBays.FirstOrDefault();
if (cargo!=null)
InventoryPanels[0].Display(cargo);
else InventoryPanels[0].Clear();
if(hasCurrentEntity)
InventoryPanels[1].Display(currentEntity);
if(GameManager.CurrentEntity != null)
InventoryPanels[1].Display(GameManager.CurrentEntity);
else InventoryPanels[1].Clear();
}
private void OnDisable()
{
HideCurrentShipSettingsSurface();
HideCargoItemDetailsSurface();
HideEquippedItemDetailsSurface();
// Background.gameObject.SetActive(false);
}
void Start()
{
PropertiesPanel.GameManager = GameManager;
foreach (var panel in InventoryPanels)
{
panel.OnClickAsObservable().Subscribe(e =>
{
if (e.data is InventoryCargoEventData cargoEvent)
{
var item = cargoEvent.CargoBay.Occupancy[cargoEvent.Position.x, cargoEvent.Position.y];
if(item!=null)
{
if (e.clickCount == 2)
{
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
if (otherPanel.CanDropItem(item))
{
otherPanel.DropItem(item);
// TODO: SFX: Equip
cargoEvent.CargoBay.Remove(item);
panel.RefreshCells();
otherPanel.RefreshCells();
}
// else
// TODO: SFX: Fail
}
else
{
if (_selectedPanel != null)
{
if (_selectedPanel.CellInstances.ContainsKey(_selectedPosition))
{
foreach (var v in _selectedItemData.Shape.Coordinates)
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2);
}
}
}
_selectedPanel = panel;
_selectedPosition = cargoEvent.Position;
PropertiesPanel.Inspect(item);
_selectedPanel = panel;
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
_selectedItem = item;
_selectedItemData = item.Data.Value;
foreach (var v in _selectedItemData.Shape.Coordinates)
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2, true);
}
// TODO: SFX: Success
}
}
}
else if (e.data is InventoryEntityEventData entityEvent)
{
var item = entityEvent.Entity.GearOccupancy[entityEvent.Position.x, entityEvent.Position.y];
if (item != null)
{
if (e.clickCount == 2)
{
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
if (otherPanel.CanDropItem(item.EquippableItem))
{
if (!entityEvent.Entity.Active)
{
if (entityEvent.Entity.TryUnequip(item) != null)
{
otherPanel.DropItem(item.EquippableItem);
// TODO: SFX: Unequip
panel.RefreshCells();
otherPanel.RefreshCells();
}
// else
// TODO: SFX: Fail
}
// else
// TODO: SFX: Fail
}
}
else
{
if (_selectedPanel != null)
{
if (_selectedPanel.CellInstances.ContainsKey(_selectedPosition))
{
foreach (var v in _selectedItemData.Shape.Coordinates)
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2);
}
}
}
PropertiesPanel.Inspect(item);
_selectedPanel = panel;
_selectedPosition = item.Position;
_selectedItem = item.EquippableItem;
_selectedItemData = GameManager.ItemManager.GetData(item.EquippableItem);
foreach (var v in _selectedItemData.Shape.Coordinates)
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2, true);
}
// TODO: SFX: Success
}
}
}
});
panel.OnBackgroundClick.Subscribe(data =>
{
if (!TryReadCurrentEntity(out var currentEntity)) return;
RenderCurrentShipSettingsSurface(currentEntity);
if (GameManager.CurrentEntity == null) return; // Only show ship settings if there's a ship, duh!
PropertiesPanel.Clear();
PropertiesPanel.AddField("Shutdown Threshold",
() => GameManager.CurrentEntity.Settings.ShutdownPerformance,
f => GameManager.CurrentEntity.Settings.ShutdownPerformance = f,
0,
1);
});
}
}
private void RenderCurrentShipSettingsSurface(AetheriaRuntimeCurrentEntityDocument currentEntity)
{
if (currentEntity == null || string.IsNullOrWhiteSpace(currentEntity.EntityKey))
return;
HideCargoItemDetailsSurface();
HideEquippedItemDetailsSurface();
ClearSelectedItemSelection();
_shipSettingsCurrentEntity = currentEntity;
_shipSettingsSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_shipSettingsSurfaceDocument,
"Aetheria Inventory Ship Settings Surface",
AetheriaRuntimeShipSettingsSurfaceBuilder.Build(
currentEntity?.Entity?.DisplayName ?? "",
(float)(currentEntity?.ShutdownPerformance ?? 0),
FormatValue),
HandleCurrentShipSettingsSurfaceCommand,
_shipSettingsSurfaceChrome);
}
private void HandleCurrentShipSettingsSurfaceCommand(EveSurfaceCommandRequest request)
{
var currentEntity = _shipSettingsCurrentEntity;
if (currentEntity == null ||
string.IsNullOrWhiteSpace(currentEntity.EntityKey) ||
!TryReadCurrentEntity(out var latestCurrentEntity) ||
!string.Equals(latestCurrentEntity.EntityKey, currentEntity.EntityKey, StringComparison.Ordinal))
{
HideCurrentShipSettingsSurface();
return;
}
_shipSettingsCurrentEntity = latestCurrentEntity;
if (!AetheriaRuntimeShipSettingsSurfaceCommands.TryRead(request, out var command))
{
Debug.LogWarning($"Unknown inventory ship settings command: {request?.Command}");
return;
}
switch (command.Kind)
{
case AetheriaRuntimeShipSettingsCommandKind.DecrementShutdownThreshold:
case AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold:
case AetheriaRuntimeShipSettingsCommandKind.ResetShutdownThreshold:
RequestEntityShutdownPerformance(
latestCurrentEntity.EntityKey,
AetheriaRuntimeShipSettingsSurfaceCommands.ResolveShutdownPerformance(
command.Kind,
(float)latestCurrentEntity.ShutdownPerformance,
ResolveDefaultShutdownPerformance()));
return;
case AetheriaRuntimeShipSettingsCommandKind.Close:
HideCurrentShipSettingsSurface();
return;
default:
Debug.LogWarning($"Unknown inventory ship settings command: {request?.Command}");
return;
}
}
private void HideCurrentShipSettingsSurface()
{
_shipSettingsCurrentEntity = null;
if (_shipSettingsSurfaceDocument == null)
return;
AetheriaEveUnitySurfaceHost.Hide(_shipSettingsSurfaceDocument);
}
private void RenderCargoItemDetailsSurface(ItemInstance item)
{
var typedItem = FindTypedInventoryItem(item);
if (item == null || typedItem == null)
return;
HideEquippedItemDetailsSurface();
_cargoItemDetailsSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_cargoItemDetailsSurfaceDocument,
"Aetheria Inventory Cargo Item Details Surface",
AetheriaRuntimeCargoItemDetailsSurfaceBuilder.Build(
typedItem,
ComposeCargoItemObservation(item),
ResolveManufacturerName(typedItem),
item is EquippableItem equippableItem ? FormatItemTier(typedItem, equippableItem) : "",
FormatValue,
FormatTemperature),
HandleCargoItemDetailsSurfaceCommand,
_cargoItemDetailsSurfaceChrome,
sortingOrder: 1001);
}
private void HandleCargoItemDetailsSurfaceCommand(EveSurfaceCommandRequest request)
{
if (!AetheriaRuntimeCargoItemDetailsSurfaceCommands.TryRead(request, out var command))
{
Debug.LogWarning($"Unknown inventory cargo item details command: {request?.Command}");
return;
}
if (command.Kind == AetheriaRuntimeCargoItemDetailsCommandKind.Close)
{
HideCargoItemDetailsSurface();
ClearSelectedItemSelection();
return;
}
Debug.LogWarning($"Unknown inventory cargo item details command: {request?.Command}");
}
private void HideCargoItemDetailsSurface()
{
if (_cargoItemDetailsSurfaceDocument == null)
return;
AetheriaEveUnitySurfaceHost.Hide(_cargoItemDetailsSurfaceDocument);
}
private void RenderEquippedItemDetailsSurface(EquippedItem item)
{
var typedItem = FindTypedInventoryItem(item?.EquippableItem);
if (item?.EquippableItem == null || typedItem == null)
return;
_equippedItemDetailsSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_equippedItemDetailsSurfaceDocument,
"Aetheria Inventory Equipped Item Details Surface",
AetheriaRuntimeEquippedItemDetailsSurfaceBuilder.Build(
typedItem,
ComposeEquippedItemObservation(item),
BuildEquippedItemTitle(item, typedItem),
ResolveManufacturerName(typedItem),
FormatValue,
FormatTemperature,
ComposeEquippedItemTemperatureControls(item).ToArray(),
item.GetBehavior<Weapon>() != null
? ComposeEquippedItemWeaponGroupControls(item).ToArray()
: Array.Empty<AetheriaRuntimeEquippedItemControl>()),
HandleEquippedItemDetailsSurfaceCommand,
_equippedItemDetailsSurfaceChrome,
sortingOrder: 1002);
}
private void HandleEquippedItemDetailsSurfaceCommand(EveSurfaceCommandRequest request)
{
var item = _selectedEquippedItem;
if (item?.EquippableItem == null)
{
HideEquippedItemDetailsSurface();
ClearSelectedItemSelection();
return;
}
if (!AetheriaRuntimeEquippedItemDetailsSurfaceCommands.TryRead(request, out var command))
{
Debug.LogWarning($"Unknown inventory equipped item details command: {request?.Command}");
return;
}
switch (command.Kind)
{
case AetheriaRuntimeEquippedItemDetailsCommandKind.Close:
HideEquippedItemDetailsSurface();
ClearSelectedItemSelection();
return;
case AetheriaRuntimeEquippedItemDetailsCommandKind.ToggleOverrideShutdown:
RequestEquippedItemOverrideShutdown(item, !item.EquippableItem.OverrideShutdown);
return;
case AetheriaRuntimeEquippedItemDetailsCommandKind.SetTargetTemperature:
if (command.BehaviorIndex >= 0 &&
command.BehaviorIndex < (item.Behaviors?.Length ?? 0) &&
item.Behaviors[command.BehaviorIndex] is Thermotoggle thermotoggle &&
thermotoggle.Adjustable)
{
RequestThermotoggleTargetTemperature(item, command.BehaviorIndex, command.TargetTemperature);
return;
}
Debug.LogWarning("Unable to apply equipped-item target temperature command.");
RenderEquippedItemDetailsSurface(item);
return;
case AetheriaRuntimeEquippedItemDetailsCommandKind.ToggleWeaponGroup:
if (command.GroupIndex >= 0)
{
var assigned = !IsWeaponGroupAssigned(item, command.GroupIndex);
RequestWeaponGroupMembership(item, command.GroupIndex, assigned);
return;
}
Debug.LogWarning("Unable to submit equipped-item weapon group membership request.");
return;
default:
Debug.LogWarning($"Unknown inventory equipped item details command: {request?.Command}");
return;
}
}
private void HideEquippedItemDetailsSurface()
{
if (_equippedItemDetailsSurfaceDocument == null)
return;
AetheriaEveUnitySurfaceHost.Hide(_equippedItemDetailsSurfaceDocument);
}
private static AetheriaEveUnitySurfaceChrome PanelChrome(float width, float maxWidth)
{
return new AetheriaEveUnitySurfaceChrome
{
RootAlignItems = Align.FlexStart,
RootJustifyContent = Justify.FlexStart,
RootPaddingTop = 0f,
Width = width,
MinWidth = 0f,
MaxWidth = maxWidth,
PaddingLeft = 18f,
PaddingRight = 18f,
PaddingTop = 18f,
PaddingBottom = 18f
};
}
private static AetheriaRuntimeEquippedItemObservation ComposeEquippedItemObservation(EquippedItem item)
{
var equippableItem = item?.EquippableItem;
return new AetheriaRuntimeEquippedItemObservation(
equippableItem?.ItemKey ?? "",
equippableItem?.Quality ?? 1,
equippableItem?.Durability ?? 1,
item?.Temperature ?? 0,
equippableItem != null && equippableItem.OverrideShutdown);
}
private IEnumerable<AetheriaRuntimeEquippedItemTemperatureControl> ComposeEquippedItemTemperatureControls(
EquippedItem item)
{
for (var i = 0; i < (item.Behaviors?.Length ?? 0); i++)
{
if (item.Behaviors[i] is not Thermotoggle thermotoggle || !thermotoggle.Adjustable)
continue;
yield return new AetheriaRuntimeEquippedItemTemperatureControl(
$"{AetheriaRuntimeEquippedItemDetailsSurfaceBuilder.SurfaceId}.controls.thermotoggle.{i}.input",
$"Target Temperature {i + 1}",
thermotoggle.TargetTemperature.ToString(CultureInfo.InvariantCulture),
AetheriaRuntimeEquippedItemDetailsSurfaceBuilder.Payload(
("behaviorIndex", i.ToString(CultureInfo.InvariantCulture))));
}
}
private IEnumerable<AetheriaRuntimeEquippedItemControl> ComposeEquippedItemWeaponGroupControls(
EquippedItem item)
{
return Enumerable.Range(0, item.Entity?.WeaponGroups?.Length ?? 0)
.Select(groupIndex => new AetheriaRuntimeEquippedItemControl(
$"{AetheriaRuntimeEquippedItemDetailsSurfaceBuilder.SurfaceId}.weapon_groups.{groupIndex}",
IsWeaponGroupAssigned(item, groupIndex) ? $"G{groupIndex + 1} On" : $"G{groupIndex + 1} Off",
AetheriaRuntimeEquippedItemDetailsSurfaceBuilder.ToggleWeaponGroup,
AetheriaRuntimeEquippedItemDetailsSurfaceBuilder.Payload(
("group", groupIndex.ToString(CultureInfo.InvariantCulture)))));
}
private static AetheriaRuntimeCargoItemObservation ComposeCargoItemObservation(ItemInstance item)
{
var equippableItem = item as EquippableItem;
return new AetheriaRuntimeCargoItemObservation(
item?.ItemKey ?? "",
item is SimpleCommodity simpleCommodity ? simpleCommodity.Quantity : 0,
equippableItem != null,
equippableItem?.Quality ?? 1,
equippableItem?.Durability ?? 1,
0,
equippableItem != null && equippableItem.OverrideShutdown);
}
private string BuildEquippedItemTitle(EquippedItem item, AetheriaRuntimeCatalogItem typedItem)
{
return $"{typedItem?.Name ?? "Unknown Item"} ({FormatItemTier(typedItem, item.EquippableItem)})";
}
private string FormatItemTier(AetheriaRuntimeCatalogItem typedItem, EquippableItem item)
{
var tradeValue = AetheriaRuntimeDaemonTradeItemQueries.TradeItemValue(
typedItem,
ToRuntimeLoadoutItem(item),
CatalogSnapshot()?.TradeValueSettings);
return tradeValue.HasTier
? $"{tradeValue.TierName}{new string('+', tradeValue.Upgrades)}"
: "";
}
private static AetheriaRuntimeLoadoutItemCommit ToRuntimeLoadoutItem(EquippableItem item)
{
return AetheriaRuntimeDaemonItemStatQueries.ItemCommit(
item?.ItemKey ?? "",
item?.Quality ?? 1,
item?.Durability ?? 1,
enabled: true,
overrideShutdown: item != null && item.OverrideShutdown);
}
private static bool IsWeaponGroupAssigned(EquippedItem item, int groupIndex)
{
return item?.Entity?.WeaponGroups != null &&
groupIndex >= 0 &&
groupIndex < item.Entity.WeaponGroups.Length &&
item.Entity.WeaponGroups[groupIndex].items.Contains(item);
}
private void ClearSelectedItemSelection()
{
_selectedEquippedItem = null;
}
private void RequestEntityShutdownPerformance(string targetEntityKey, float shutdownPerformance)
{
if (string.IsNullOrWhiteSpace(targetEntityKey))
return;
TrySubmitOperation(
operations => operations.SetShutdownPerformance(targetEntityKey, shutdownPerformance),
"entity shutdown-performance");
}
private void RequestEquippedItemOverrideShutdown(EquippedItem item, bool enabled)
{
if (!TryResolveEquippedItem(item, out var targetEntityKey, out var equipmentIndex) ||
item?.EquippableItem == null)
{
return;
}
TrySubmitOperation(
operations => operations.SetItemOverrideShutdown(targetEntityKey, equipmentIndex, enabled),
"equipped-item override-shutdown");
}
private void RequestThermotoggleTargetTemperature(
EquippedItem item,
int behaviorIndex,
float targetTemperature)
{
if (!TryResolveEquippedItem(item, out var targetEntityKey, out var equipmentIndex) ||
behaviorIndex < 0 ||
behaviorIndex >= (item?.Behaviors?.Length ?? 0))
{
return;
}
TrySubmitOperation(
operations => operations.SetThermotoggleTargetTemperature(
targetEntityKey,
equipmentIndex,
behaviorIndex,
targetTemperature),
"thermotoggle target-temperature");
}
private void RequestWeaponGroupMembership(EquippedItem item, int groupIndex, bool assigned)
{
if (!TryResolveEquippedItem(item, out var targetEntityKey, out var equipmentIndex) ||
groupIndex < 0)
{
return;
}
TrySubmitOperation(
operations => operations.SetWeaponGroupMembership(
targetEntityKey,
equipmentIndex,
groupIndex,
assigned),
"weapon-group membership");
}
private bool TryGetRecordKeyForPresentationEntity(Entity entity, out string recordKey)
{
recordKey = "";
return _presentationEntityIndex != null &&
_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(entity, out recordKey);
}
private bool IsCurrentEntity(Entity entity)
{
if (entity == null ||
!TryGetRecordKeyForPresentationEntity(entity, out var entityKey) ||
string.IsNullOrWhiteSpace(entityKey) ||
!TryResolveCurrentEntityKey(out var currentEntityKey))
{
return false;
}
return string.Equals(entityKey, currentEntityKey, StringComparison.Ordinal);
}
private bool TryResolveCurrentDockingBayRow(out AetheriaRuntimeStationDockingBayRow dockingBay)
{
dockingBay = null;
var refit = StationRefitSnapshot();
if (refit?.IsDocked != true || refit.DockingBayIndex < 0)
return false;
dockingBay = (refit.DockingBays ?? Array.Empty<AetheriaRuntimeStationDockingBayRow>())
.FirstOrDefault(row => row != null && row.DockingBayIndex == refit.DockingBayIndex);
return dockingBay != null;
}
private bool TryResolveCurrentEntityKey(out string currentEntityKey)
{
currentEntityKey = CurrentEntitySnapshot()?.EntityKey ?? "";
return !string.IsNullOrWhiteSpace(currentEntityKey);
}
private bool TryReadCurrentEntity(out AetheriaRuntimeCurrentEntityDocument currentEntity)
{
currentEntity = CurrentEntitySnapshot();
if (currentEntity == null)
{
Debug.LogWarning("Failed to read Aetheria current entity for inventory ship settings.");
return false;
}
return true;
}
private bool TryResolveCurrentEntity(out Entity currentEntity)
{
currentEntity = null;
var currentEntityKey = CurrentEntitySnapshot()?.EntityKey ?? "";
return _presentationEntityIndex != null &&
!string.IsNullOrWhiteSpace(currentEntityKey) &&
_presentationEntityIndex.TryGetPresentationEntityByRecordKey(currentEntityKey, out currentEntity);
}
private bool TryResolveCurrentDockingBay(out EquippedDockingBay dockingBay)
{
dockingBay = null;
var refit = StationRefitSnapshot();
if (refit?.IsDocked != true ||
refit.DockingBayIndex < 0 ||
string.IsNullOrWhiteSpace(refit.DockParentEntityKey) ||
_presentationEntityIndex == null ||
!_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
refit.DockParentEntityKey,
refit.DockingBayIndex,
out dockingBay))
{
return false;
}
return dockingBay != null;
}
private bool TryResolveEquippedItem(EquippedItem item, out string entityKey, out int equipmentIndex)
{
entityKey = "";
equipmentIndex = -1;
var entity = item?.Entity;
if (entity?.Equipment == null ||
!TryGetRecordKeyForPresentationEntity(entity, out entityKey))
{
return false;
}
equipmentIndex = entity.Equipment.IndexOf(item);
return equipmentIndex >= 0;
}
private bool TrySubmitOperation(
Action<AetheriaControl> submit,
string label)
{
if (submit == null)
return false;
try
{
submit(AetheriaUnityRuntimeClientProvider.Control("unity-inventory-menu"));
return true;
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to send Aetheria daemon inventory menu {label} operation; operation not submitted: {ex.Message}");
return false;
}
}
private AetheriaRuntimeCurrentEntityDocument CurrentEntitySnapshot()
{
try
{
return RuntimeState.CurrentEntity.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria current entity for inventory menu: {ex.Message}");
return null;
}
}
private AetheriaRuntimeStationRefitDocument StationRefitSnapshot()
{
try
{
return RuntimeState.StationRefit.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria station refit for inventory menu: {ex.Message}");
return null;
}
}
void Update()
{
// if (Keyboard.current.qKey.wasPressedThisFrame && _dragItem != null)
@ -646,95 +208,4 @@ public class InventoryMenu : MonoBehaviour
// _dragItem.Rotation = (ItemRotation) (((int) _dragItem.Rotation + 3) % 4);
// }
}
private AetheriaRuntimeCatalogItem FindTypedInventoryItem(ItemInstance item)
{
return CatalogSnapshot()?.FindItem(item, x => x.ItemKey);
}
private AetheriaRuntimeCatalogSnapshot CatalogSnapshot()
{
try
{
return RuntimeState.Catalog.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria runtime catalog for inventory menu: {ex.Message}");
return null;
}
}
private AetheriaRuntimePlayerSettingsDocument PlayerSettingsSnapshot()
{
try
{
return RuntimeState.PlayerSettings.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria player settings for inventory menu: {ex.Message}");
return null;
}
}
private float ResolveDefaultShutdownPerformance()
{
var value = PlayerSettingsSnapshot()?.DefaultShutdownPerformance ?? 0.25;
return (float)(value <= 0 ? 0.25 : value);
}
private string ResolveManufacturerName(AetheriaRuntimeCatalogItem item)
{
return CatalogSnapshot()?.GetManufacturer(item)?.Name ?? "GameCult";
}
private string FormatValue(float value)
{
var settings = PlayerSettingsSnapshot();
var significantDigits = settings?.SignificantDigits ?? 3;
var magnitude = value == 0.0f ? 0 : (int)Math.Floor(Math.Log10(Math.Abs(value))) + 1;
var digits = significantDigits - magnitude;
if (digits < 0)
digits = 0;
var formatted = value.ToString($"N{digits}", CultureInfo.CurrentCulture);
var separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
var decimalSeparator = Convert.ToChar(separator);
return formatted.Contains(separator)
? formatted.TrimEnd('0').TrimEnd(decimalSeparator)
: formatted;
}
private string FormatTemperature(float value)
{
var unit = PlayerSettingsSnapshot()?.TemperatureUnit ?? nameof(TemperatureUnit.Celsius);
if (string.Equals(unit, nameof(TemperatureUnit.Kelvin), StringComparison.OrdinalIgnoreCase))
return $"{FormatValue(value)} K";
if (string.Equals(unit, nameof(TemperatureUnit.Fahrenheit), StringComparison.OrdinalIgnoreCase))
return $"{FormatValue(value * (9f / 5) - 459.67f)} F";
return $"{FormatValue(value - 273.15f)} C";
}
private void OnDestroy()
{
if (_shipSettingsSurfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_shipSettingsSurfaceDocument);
_shipSettingsSurfaceDocument = null;
}
if (_cargoItemDetailsSurfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_cargoItemDetailsSurfaceDocument);
_cargoItemDetailsSurfaceDocument = null;
}
if (_equippedItemDetailsSurfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_equippedItemDetailsSurfaceDocument);
_equippedItemDetailsSurfaceDocument = null;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,16 +2,11 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
using GameCult.Mesh;
using Ink.Runtime;
using TMPro;
using UniRx;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.UIElements;
public class LocalMenu : MonoBehaviour
{
@ -21,42 +16,18 @@ public class LocalMenu : MonoBehaviour
public ChoicePrefab ChoicePrefab;
private string _currentPath;
private LocationStory _currentLocalInkLocation;
private LocationStory _currentLocation;
private Story _activeStory;
private readonly List<ActiveStoryChoice> _activeChoices = new List<ActiveStoryChoice>();
private UIDocument _surfaceDocument;
private readonly AetheriaEveUnitySurfaceChrome _surfaceChrome = new AetheriaEveUnitySurfaceChrome();
private AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
private AetheriaClientState _runtimeState;
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
{
_presentationEntityIndex = presentationEntityIndex;
}
private sealed class ActiveStoryChoice
{
public ActiveStoryChoice(int index, Story story, Choice choice)
{
Index = index;
Story = story;
Choice = choice;
}
public int Index { get; }
public Story Story { get; }
public Choice Choice { get; }
}
private List<GameObject> _choiceInstances = new List<GameObject>();
private void OnEnable()
{
if (!TryResolveDockedLocalInkStory(out _currentLocalInkLocation))
if (ActionGameManager.Instance.DockedEntity is OrbitalEntity orbital)
{
HideStorySurface();
return;
_currentLocation = orbital.Story;
_activeStory = _currentLocation.Story;
}
_activeStory = _currentLocalInkLocation.Story;
else return;
Continue();
}
@ -74,10 +45,11 @@ public class LocalMenu : MonoBehaviour
if (!_activeStory.state.previousPointer.isNull) _currentPath = _activeStory.state.previousPointer.path.head.name;
if(_activeStory.canContinue) _activeStory.Continue();
if (!_activeStory.state.previousPointer.isNull) _currentPath = _activeStory.state.previousPointer.path.head.name;
if (Output != null)
Output.text = _activeStory.currentText;
Output.text = _activeStory.currentText;
_activeChoices.Clear();
foreach(var instance in _choiceInstances)
Destroy(instance);
_choiceInstances.Clear();
if(_activeStory.currentChoices.Any())
{
@ -86,7 +58,7 @@ public class LocalMenu : MonoBehaviour
else if (!_activeStory.canContinue)
{
// There's no choices, but we also can't continue; indicates we hit an END
if (_activeStory == _currentLocalInkLocation.Story)
if (_activeStory == _currentLocation.Story)
{
// END inside location-based story thread, restart the story
_activeStory.ResetState();
@ -95,20 +67,18 @@ public class LocalMenu : MonoBehaviour
else
{
// END inside quest content, switch back to location thread and present choices
_activeStory = _currentLocalInkLocation.Story;
_activeStory = _currentLocation.Story;
Continue();
}
}
RenderStorySurface();
}
void PresentCurrentChoices()
{
Debug.Log($"Current Path: \"{_currentPath}\" in {(_activeStory == _currentLocalInkLocation.Story ? "Location Story" : "Quest Story")}");
if(!string.IsNullOrEmpty(_currentPath) && _currentLocalInkLocation.KnotQuests.ContainsKey(_currentPath))
Debug.Log($"Current Path: \"{_currentPath}\" in {(_activeStory == _currentLocation.Story ? "Location Story" : "Quest Story")}");
if(!string.IsNullOrEmpty(_currentPath) && _currentLocation.KnotQuests.ContainsKey(_currentPath))
{
foreach (var quest in _currentLocalInkLocation.KnotQuests[_currentPath])
foreach (var quest in _currentLocation.KnotQuests[_currentPath])
{
if (quest.Story == _activeStory) continue; // Don't repeat choices for active injected branch
@ -122,140 +92,15 @@ public class LocalMenu : MonoBehaviour
void PresentChoice(Story story, Choice choice)
{
_activeChoices.Add(new ActiveStoryChoice(_activeChoices.Count, story, choice));
}
private void RenderStorySurface()
{
if (_activeStory == null)
return;
if (Output != null)
Output.gameObject.SetActive(false);
if (ChoiceParent != null)
ChoiceParent.gameObject.SetActive(false);
_surfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_surfaceDocument,
"Aetheria Runtime Local Story Surface",
AetheriaRuntimeLocalStorySurfaceBuilder.Build(
ResolveLocationLabel(),
_currentPath,
_activeStory?.currentText ?? "",
_activeStory?.canContinue == true,
_activeChoices.Select(choice => new AetheriaRuntimeLocalStoryChoiceState(
choice.Index,
choice.Choice?.text ?? "")),
DateTime.UtcNow.ToString("O")),
HandleStorySurfaceCommand,
_surfaceChrome);
}
private void HandleStorySurfaceCommand(EveSurfaceCommandRequest request)
{
if (!AetheriaRuntimeLocalStorySurfaceCommands.TryRead(request, out var command))
var choiceInstance = Instantiate(ChoicePrefab, ChoiceParent);
choiceInstance.Label.text = choice.text;
choiceInstance.Button.onClick.AddListener(() =>
{
Debug.LogWarning($"Unknown runtime local story command: {request?.Command}");
return;
}
switch (command.Kind)
{
case AetheriaRuntimeLocalStoryCommandKind.Continue:
Continue();
return;
case AetheriaRuntimeLocalStoryCommandKind.Choose:
ChooseStoryOption(command.ChoiceIndex);
return;
default:
Debug.LogWarning($"Unknown runtime local story command: {request?.Command}");
return;
}
}
private void ChooseStoryOption(int choiceIndex)
{
var selected = _activeChoices.FirstOrDefault(choice => choice.Index == choiceIndex);
if (selected == null)
{
Debug.LogWarning($"Unknown runtime local story choice index: {choiceIndex}");
return;
}
_activeStory = selected.Story;
_activeStory.ChoosePath(selected.Choice.targetPath);
Continue();
}
private string ResolveLocationLabel()
{
if (!string.IsNullOrWhiteSpace(_currentLocalInkLocation?.Name))
return _currentLocalInkLocation.Name;
if (!string.IsNullOrWhiteSpace(_currentLocalInkLocation?.FileName))
return _currentLocalInkLocation.FileName;
return "Local";
}
private bool TryResolveDockedLocalInkStory(out LocationStory story)
{
story = null;
var docking = CurrentDockingSnapshot();
// Ink story execution is still a Unity-local island. The docking identity
// comes from managed typed state; the remaining object lookup should go
// away when local story state becomes a daemon-owned CultMesh document.
if (_presentationEntityIndex == null ||
docking == null ||
!docking.IsDocked ||
string.IsNullOrWhiteSpace(docking.DockParentEntityKey) ||
docking.DockingBayIndex < 0 ||
!_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
docking.DockParentEntityKey,
docking.DockingBayIndex,
out var dockingBay) ||
dockingBay?.Entity is not OrbitalEntity { Story: { } dockedStory })
{
return false;
}
story = dockedStory;
return true;
}
private AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
{
try
{
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-local-menu");
return _runtimeState.CurrentDocking.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria current docking for local menu: {ex.Message}");
return null;
}
}
private void HideStorySurface()
{
if (_surfaceDocument == null)
return;
AetheriaEveUnitySurfaceHost.Hide(_surfaceDocument);
}
private void OnDisable()
{
HideStorySurface();
}
private void OnDestroy()
{
if (_surfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_surfaceDocument);
_surfaceDocument = null;
}
_activeStory = story;
_activeStory.ChoosePath(choice.targetPath);
Continue();
});
_choiceInstances.Add(choiceInstance.gameObject);
}
// Update is called once per frame

View file

@ -1,13 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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 System.Collections;
using System.Collections.Generic;
using System.Linq;
using GameCult.Aetheria.State.Verse;
using GameCult.Mesh;
using TMPro;
using UnityEngine;
using Unity.Mathematics;
@ -17,6 +14,7 @@ using int2 = Unity.Mathematics.int2;
public class MapRenderer : MonoBehaviour
{
public ActionGameManager GameManager;
public ZoneRenderer ZoneRenderer;
public TextMeshProUGUI Title;
public Camera MapOverlayCamera;
@ -25,25 +23,19 @@ public class MapRenderer : MonoBehaviour
public Camera InfluenceCamera;
public Image OverlayDisplay;
public Image GravityDisplay;
public Material GravityBackdropMaterial;
public Image TintDisplay;
public Image InfluenceDisplay;
public AetheriaRenderSplatLayerRenderer SplatLayerRenderer;
public AetheriaDaemonRenderAssetCatalog AssetCatalog;
public RectTransform MapIconRoot;
public RawImage MapIconPrototype;
public float Scale;
public float2 Position;
private AetheriaClientState _runtimeState;
public float IconSize = 1f/128;
private RectTransform _rect;
private RenderTexture _mapTexture;
private RenderTexture _gravityTexture;
private RenderTexture _tintTexture;
private RenderTexture _influenceTexture;
private int2 _size;
private bool _init;
private AetheriaUnityGameViewportDocuments _viewportDocuments;
private float _nextViewportRefreshTime;
private readonly List<RawImage> _mapIconPool = new List<RawImage>();
void Start()
{
@ -53,40 +45,30 @@ public class MapRenderer : MonoBehaviour
private void OnEnable()
{
_init = true;
SetCameraActive(MapOverlayCamera, false);
SetCameraActive(GravityCamera, false);
SetCameraActive(TintCamera, false);
SetCameraActive(InfluenceCamera, false);
if (OverlayDisplay != null)
OverlayDisplay.gameObject.SetActive(false);
if (GravityBackdropMaterial != null && GravityDisplay != null)
GravityDisplay.material = GravityBackdropMaterial;
EnsureMapIconRoot();
SetMapIconsActive(true);
RefreshViewportDocuments(force: true);
MapOverlayCamera.gameObject.SetActive(true);
GravityCamera.gameObject.SetActive(true);
TintCamera.gameObject.SetActive(true);
InfluenceCamera.gameObject.SetActive(true);
Title.text = $"Zone: {GameManager.Zone.GalaxyZone.Name}";
// If hiding minimap asteroids, turn them back on for the map screen
if (!ResolveShowAsteroidsInMinimap())
if (!ActionGameManager.PlayerSettings.GraphicsSettings.ShowAsteroidsInMinimap)
ZoneRenderer.ShowAsteroidUI = true;
}
private void OnDisable()
{
ClearViewportCaches();
if (_mapTexture != null)
{
ReleaseTextures();
}
SetCameraActive(MapOverlayCamera, false);
SetCameraActive(GravityCamera, false);
SetCameraActive(TintCamera, false);
SetCameraActive(InfluenceCamera, false);
if (OverlayDisplay != null)
OverlayDisplay.gameObject.SetActive(false);
SetMapIconsActive(false);
MapOverlayCamera.gameObject.SetActive(false);
GravityCamera.gameObject.SetActive(false);
TintCamera.gameObject.SetActive(false);
InfluenceCamera.gameObject.SetActive(false);
// If hiding minimap asteroids, turn them back off when leaving the map screen
if (!ResolveShowAsteroidsInMinimap())
if (!ActionGameManager.PlayerSettings.GraphicsSettings.ShowAsteroidsInMinimap)
ZoneRenderer.ShowAsteroidUI = false;
}
@ -94,6 +76,12 @@ public class MapRenderer : MonoBehaviour
{
_mapTexture.Release();
_mapTexture = null;
_gravityTexture.Release();
_gravityTexture = null;
_tintTexture.Release();
_tintTexture = null;
_influenceTexture.Release();
_influenceTexture = null;
}
void LateUpdate()
@ -108,230 +96,38 @@ public class MapRenderer : MonoBehaviour
ReleaseTextures();
}
_mapTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
MapOverlayCamera.targetTexture = _mapTexture;
OverlayDisplay.material.SetTexture("_DetailTex", _mapTexture);
_gravityTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.RFloat);
GravityCamera.targetTexture = _gravityTexture;
GravityDisplay.material.SetTexture("_DetailTex", _gravityTexture);
_tintTexture = new RenderTexture(_size.x / 2, _size.y / 2, 0, RenderTextureFormat.RGB111110Float);
TintCamera.targetTexture = _tintTexture;
TintDisplay.material.SetTexture("_DetailTex", _tintTexture);
_influenceTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.RFloat);
InfluenceCamera.targetTexture = _influenceTexture;
InfluenceDisplay.material.SetTexture("_DetailTex", _influenceTexture);
}
var pos = ((Vector2) Position).Flatland(1);
MapOverlayCamera.transform.position = pos;
MapOverlayCamera.orthographicSize = _size.y * Scale * .5f;
GravityCamera.transform.position = pos;
GravityCamera.orthographicSize = _size.y * Scale * .5f;
GravityDisplay.material.SetFloat("_Scale", Scale / 2);
RefreshViewportDocuments(force: false);
RenderSplatLayers();
RenderMapIcons();
}
private void RefreshViewportDocuments(bool force)
{
if (!force && Time.unscaledTime < _nextViewportRefreshTime)
return;
_nextViewportRefreshTime = Time.unscaledTime + .5f;
try
{
var viewport = ResolveViewportBounds();
ClearViewportCaches();
_viewportDocuments = AetheriaUnityRuntimeClientProvider
.MapViewportDocuments(viewport, "unity-map-renderer");
var objectsViewport = _viewportDocuments?.CurrentObjectsViewport;
var zoneName = string.IsNullOrWhiteSpace(objectsViewport?.ZoneName)
? "Unknown"
: objectsViewport.ZoneName;
Title.text = $"Zone: {zoneName}";
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria map viewport from Verse state: {ex.Message}");
Title.text = "Zone: Unknown";
}
}
private void RenderSplatLayers()
{
var renderSplatsViewport = _viewportDocuments?.CurrentRenderSplatsViewport;
if (renderSplatsViewport == null)
return;
if (SplatLayerRenderer == null)
SplatLayerRenderer = GetComponent<AetheriaRenderSplatLayerRenderer>() ??
gameObject.AddComponent<AetheriaRenderSplatLayerRenderer>();
SplatLayerRenderer.Render(renderSplatsViewport, _size.x, _size.y);
ApplyLayerTexture(AetheriaRuntimeRenderSplatLayerKeys.GravityHeight, GravityDisplay);
ApplyLayerTexture(AetheriaRuntimeRenderSplatLayerKeys.FogTint, TintDisplay);
ApplyLayerTexture(AetheriaRuntimeRenderSplatLayerKeys.Influence, InfluenceDisplay);
}
private void ApplyLayerTexture(string layerKey, Image display)
{
if (display == null ||
SplatLayerRenderer == null ||
!SplatLayerRenderer.TryGetTexture(layerKey, out var texture) ||
texture == null)
{
return;
}
display.material.SetTexture("_DetailTex", texture);
}
private static void SetCameraActive(Camera camera, bool active)
{
if (camera != null)
camera.gameObject.SetActive(active);
}
private void RenderMapIcons()
{
EnsureMapIconRoot();
if (MapIconRoot == null)
return;
var objects = _viewportDocuments?.CurrentObjectsViewport?.Objects ?? Array.Empty<AetheriaRuntimeViewportObject>();
for (var i = 0; i < objects.Count; i++)
{
var icon = ResolveMapIcon(i);
ApplyMapIcon(icon, objects[i]);
}
for (var i = objects.Count; i < _mapIconPool.Count; i++)
if (_mapIconPool[i] != null)
_mapIconPool[i].gameObject.SetActive(false);
}
private RawImage ResolveMapIcon(int index)
{
while (_mapIconPool.Count <= index)
{
RawImage icon;
if (MapIconPrototype != null)
{
icon = Instantiate(MapIconPrototype, MapIconRoot);
}
else
{
var go = new GameObject("Map Viewport Icon", typeof(RectTransform), typeof(CanvasRenderer), typeof(RawImage));
go.transform.SetParent(MapIconRoot, false);
icon = go.GetComponent<RawImage>();
icon.texture = Texture2D.whiteTexture;
icon.raycastTarget = false;
}
_mapIconPool.Add(icon);
}
return _mapIconPool[index];
}
private void ApplyMapIcon(RawImage icon, AetheriaRuntimeViewportObject obj)
{
if (icon == null || obj == null)
return;
icon.gameObject.SetActive(true);
if (AssetCatalog != null && AssetCatalog.TryResolveTexture(obj.IconAsset, out var texture))
icon.texture = texture;
icon.color = ResolveIconColor(obj);
var rectTransform = icon.rectTransform;
var pixelSize = Mathf.Max(4f, IconSize * (obj.Controlled ? 1.25f : 1f));
rectTransform.anchorMin = rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
rectTransform.pivot = new Vector2(0.5f, 0.5f);
rectTransform.sizeDelta = new Vector2(pixelSize, pixelSize);
rectTransform.anchoredPosition = WorldToMapPosition(obj.X, obj.Y);
rectTransform.localRotation = Quaternion.Euler(
0,
0,
Mathf.Atan2((float)obj.DirectionY, (float)obj.DirectionX) * Mathf.Rad2Deg - 90f);
}
private Vector2 WorldToMapPosition(double worldX, double worldY)
{
var viewport = _viewportDocuments?.CurrentObjectsViewport?.Viewport ?? ResolveViewportBounds();
var minX = Math.Min(viewport.MinX, viewport.MaxX);
var maxX = Math.Max(viewport.MinX, viewport.MaxX);
var minY = Math.Min(viewport.MinY, viewport.MaxY);
var maxY = Math.Max(viewport.MinY, viewport.MaxY);
var width = Math.Max(0.0001, maxX - minX);
var height = Math.Max(0.0001, maxY - minY);
var rootRect = MapIconRoot != null ? MapIconRoot.rect : new Rect(0, 0, _size.x, _size.y);
var u = (float)((worldX - minX) / width);
var v = (float)((worldY - minY) / height);
return new Vector2(
(u - 0.5f) * rootRect.width,
(v - 0.5f) * rootRect.height);
}
private static Color ResolveIconColor(AetheriaRuntimeViewportObject obj)
{
var color = obj.Controlled
? new Color(0.3f, 0.9f, 1.0f, 1.0f)
: Color.HSVToRGB(frac((obj.FactionKey ?? obj.Kind ?? "").GetHashCode() * 0.0137f), 0.55f, 0.95f);
color.a = Mathf.Clamp01(Mathf.Max(0.25f, (float)obj.Visibility));
return color;
}
private void EnsureMapIconRoot()
{
if (MapIconRoot != null)
return;
var parent = GravityDisplay != null
? GravityDisplay.transform.parent
: transform;
var go = new GameObject("Map Viewport Icons", typeof(RectTransform));
go.transform.SetParent(parent, false);
MapIconRoot = go.GetComponent<RectTransform>();
MapIconRoot.anchorMin = Vector2.zero;
MapIconRoot.anchorMax = Vector2.one;
MapIconRoot.offsetMin = Vector2.zero;
MapIconRoot.offsetMax = Vector2.zero;
MapIconRoot.SetAsLastSibling();
}
private void SetMapIconsActive(bool active)
{
if (MapIconRoot != null)
MapIconRoot.gameObject.SetActive(active);
}
private AetheriaRuntimeViewportBounds ResolveViewportBounds()
{
var screenHeight = _size.y <= 0 ? Math.Max(1, Screen.height) : _size.y;
var screenWidth = _size.x <= 0 ? Math.Max(1, Screen.width) : _size.x;
var halfHeight = screenHeight * Scale * .5f;
var halfWidth = screenWidth * Scale * .5f;
return new AetheriaRuntimeViewportBounds
{
MinX = Position.x - halfWidth,
MinY = Position.y - halfHeight,
MaxX = Position.x + halfWidth,
MaxY = Position.y + halfHeight
};
}
private bool ResolveShowAsteroidsInMinimap()
{
try
{
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-map-renderer");
return _runtimeState.PlayerSettings.Latest()?.ShowAsteroidsInMinimap ?? false;
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria map graphics settings from Verse state: {ex.Message}");
return false;
}
}
private void ClearClientCaches()
{
ClearViewportCaches();
}
private void ClearViewportCaches()
{
_viewportDocuments?.Dispose();
_viewportDocuments = null;
}
private void OnDestroy()
{
ClearClientCaches();
TintCamera.transform.position = pos;
TintCamera.orthographicSize = _size.y * Scale * .5f;
InfluenceCamera.transform.position = pos;
InfluenceCamera.orthographicSize = _size.y * Scale * .5f;
GameManager.ZoneRenderer.SetIconSize(IconSize * Scale);
}
}

View file

@ -1,314 +1,69 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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 System.Collections;
using System.Collections.Generic;
using System.Linq;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
using GameCult.Mesh;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.UIElements;
public class MenuPanel : MonoBehaviour
{
private const string TabSurfaceId = "aetheria.runtime_menu.tabs";
private const string TabCommandPrefix = "aetheria.runtime_menu.tab.";
[Serializable]
private sealed class MenuTabBinding
{
public MenuTab Tab;
public GameObject TabContents;
public string Label;
public bool RequireDock;
}
public ActionGameManager GameManager;
public RectTransform TabButtons;
[SerializeField] private MenuTabBinding[] TabBindings = Array.Empty<MenuTabBinding>();
public Color ActiveTabColor;
public Color InactiveTabColor;
public event Action<MenuTab> TabChanged;
private readonly Dictionary<MenuTab, MenuTabBinding> _tabs = new Dictionary<MenuTab, MenuTabBinding>();
private MenuTabBinding _current;
private UIDocument _tabSurfaceDocument;
private readonly AetheriaEveUnitySurfaceChrome _tabSurfaceChrome = new AetheriaEveUnitySurfaceChrome();
private AetheriaClientState _runtimeState;
private Dictionary<MenuTab, MenuTabButton> _tabs = new Dictionary<MenuTab, MenuTabButton>();
private MenuTabButton _current;
public MenuTab CurrentTab { get; private set; }
public void ShowTab(MenuTab tab)
{
gameObject.SetActive(true);
if (!_tabs.TryGetValue(tab, out var next))
return;
if (_current == next)
{
RenderTabSurface();
return;
}
if (_current == _tabs[tab]) return;
if(_current != null)
{
_current.TabContents.SetActive(false);
_current.Text.color = InactiveTabColor;
}
CurrentTab = tab;
_current = next;
_current = _tabs[tab];
_current.TabContents.SetActive(true);
RenderTabSurface();
_current.Text.color = ActiveTabColor;
TabChanged?.Invoke(tab);
}
private void OnEnable()
{
if (TabButtons != null)
TabButtons.gameObject.SetActive(false);
RenderTabSurface();
foreach (var tabButton in _tabs.Values)
{
tabButton.gameObject.SetActive(!tabButton.RequireDock || GameManager.DockedEntity != null);
}
_tabs[MenuTab.Local].gameObject.SetActive((GameManager.DockedEntity as OrbitalEntity)?.Story!=null);
}
private void Awake()
{
foreach (var tabBinding in TabBindings)
foreach (var tabButton in TabButtons.GetComponentsInChildren<MenuTabButton>())
{
if (tabBinding?.TabContents == null)
continue;
tabBinding.TabContents.SetActive(false);
_tabs[tabBinding.Tab] = tabBinding;
tabButton.TabContents.SetActive(false);
tabButton.Text.color = InactiveTabColor;
_tabs.Add(tabButton.Tab, tabButton);
tabButton.Button.onClick.AddListener(() => ShowTab(tabButton.Tab));
}
}
private void OnDisable()
{
HideTabSurface();
}
private void OnDestroy()
{
if (_tabSurfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_tabSurfaceDocument);
_tabSurfaceDocument = null;
}
}
private void RenderTabSurface()
{
if (_tabs.Count == 0)
return;
if (TabButtons != null)
TabButtons.gameObject.SetActive(false);
_tabSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_tabSurfaceDocument,
"Aetheria Runtime Menu Tabs Surface",
BuildTabSurfaceDocument(
ToRuntimeTabKey(CurrentTab),
ResolveVisibleTabs(),
DateTime.UtcNow.ToString("O")),
HandleTabSurfaceCommand,
_tabSurfaceChrome);
}
private void HandleTabSurfaceCommand(EveSurfaceCommandRequest request)
{
if (!TryReadTabSurfaceCommand(request, out var tabKey))
{
Debug.LogWarning($"Unknown runtime menu tab command: {request?.Command}");
return;
}
foreach (var tab in _tabs.Keys)
{
if (string.Equals(tabKey, ToRuntimeTabKey(tab), StringComparison.Ordinal))
{
ShowTab(tab);
return;
}
}
Debug.LogWarning($"Unknown runtime menu tab command: {request?.Command}");
}
private void HideTabSurface()
{
if (_tabSurfaceDocument == null)
return;
AetheriaEveUnitySurfaceHost.Hide(_tabSurfaceDocument);
}
private MenuTabBinding[] ResolveVisibleTabs()
{
var isDocked = TryResolveCurrentDocking(out var docking) &&
docking.IsDocked;
return _tabs.Values
.Where(tabBinding => !tabBinding.RequireDock || isDocked)
.Where(tabBinding => tabBinding.Tab != MenuTab.Local || isDocked)
.OrderBy(tabBinding => (int)tabBinding.Tab)
.ToArray();
}
private bool TryResolveCurrentDocking(out AetheriaRuntimeCurrentDockingDocument docking)
{
docking = null;
try
{
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-runtime-menu-tabs");
docking = _runtimeState.CurrentDocking.Latest();
return docking != null;
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria runtime docking for menu tabs: {ex.Message}");
return false;
}
}
private static string GetTabLabel(MenuTabBinding tabBinding)
{
return string.IsNullOrWhiteSpace(tabBinding.Label)
? tabBinding.Tab.ToString()
: tabBinding.Label;
}
private static string ToRuntimeTabKey(MenuTab tab)
{
return NormalizeTabKey(tab.ToString());
}
private static string NormalizeTabKey(string tabKey)
{
return string.IsNullOrWhiteSpace(tabKey)
? "unknown"
: tabKey.Trim().ToLowerInvariant();
}
private static string TabCommandFor(string tabKey)
{
return $"{TabCommandPrefix}{NormalizeTabKey(tabKey)}";
}
private static bool TryReadTabSurfaceCommand(EveSurfaceCommandRequest request, out string tabKey)
{
tabKey = "";
if (request == null ||
!string.Equals(request.SurfaceId, TabSurfaceId, StringComparison.Ordinal))
return false;
var commandText = request.Operation?.OperationId ?? "";
if (!commandText.StartsWith(TabCommandPrefix, StringComparison.Ordinal))
return false;
tabKey = commandText.Substring(TabCommandPrefix.Length);
return !string.IsNullOrWhiteSpace(tabKey);
}
private static AetheriaRuntimeSurfaceDocument BuildTabSurfaceDocument(
string currentTabKey,
IEnumerable<MenuTabBinding> visibleTabs,
string updatedAtUtc)
{
var normalizedCurrent = NormalizeTabKey(currentTabKey);
var tabs = (visibleTabs ?? Array.Empty<MenuTabBinding>())
.Where(tab => tab != null)
.OrderBy(tab => (int)tab.Tab)
.Select(tab =>
{
var key = ToRuntimeTabKey(tab.Tab);
var label = GetTabLabel(tab);
return new
{
Key = key,
Label = label,
Selected = string.Equals(key, normalizedCurrent, StringComparison.Ordinal)
};
})
.ToArray();
return new AetheriaRuntimeSurfaceDocument(
providerId: "aetheria",
providerKind: "runtime.menu",
title: "Runtime Menu Tabs",
version: 1,
updatedAtUtc: updatedAtUtc ?? "",
surface: new AetheriaRuntimeSurfaceTree(
TabSurfaceId,
TabSurfaceNode(
$"{TabSurfaceId}.root",
"surface",
Array.Empty<(string Key, string Value)>(),
TabSurfaceText(
$"{TabSurfaceId}.current",
$"Current: {normalizedCurrent}"),
TabSurfaceButtonRow(
$"{TabSurfaceId}.tabs",
tabs
.Select(tab => TabSurfaceButton(
$"{TabSurfaceId}.{SafeSurfaceId(tab.Key)}",
tab.Selected ? $"{tab.Label} *" : tab.Label,
TabCommandFor(tab.Key)))
.ToArray())),
Array.Empty<AetheriaRuntimeSurfaceStyleToken>()),
commands: tabs
.Select(tab => new AetheriaRuntimeSurfaceCommandTemplate(
TabCommandFor(tab.Key),
tab.Label,
AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport))
.ToArray());
}
private static string SafeSurfaceId(string value)
{
if (string.IsNullOrWhiteSpace(value))
return "empty";
return new string(value
.Select(character => char.IsLetterOrDigit(character) ? char.ToLowerInvariant(character) : '-')
.ToArray()).Trim('-');
}
private static AetheriaRuntimeSurfaceComponent TabSurfaceText(string id, string value)
{
return TabSurfaceNode(id, "text", new[] { ("value", value ?? "") });
}
private static AetheriaRuntimeSurfaceComponent TabSurfaceButton(string id, string label, string command)
{
return TabSurfaceNode(id, "control.button", new[] { ("label", label ?? ""), ("command", command ?? "") });
}
private static AetheriaRuntimeSurfaceComponent TabSurfaceButtonRow(
string id,
params AetheriaRuntimeSurfaceComponent[] children)
{
return TabSurfaceNode(id, "row", Array.Empty<(string Key, string Value)>(), children);
}
private static AetheriaRuntimeSurfaceComponent TabSurfaceNode(
string id,
string kind,
IEnumerable<(string Key, string Value)> props,
params AetheriaRuntimeSurfaceComponent[] children)
{
return new AetheriaRuntimeSurfaceComponent(
id,
kind,
props.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal),
children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>());
}
// void Start()
// void Start()
// {
// ShowTab(MenuTab.Inventory);
// }
@ -321,4 +76,4 @@ public enum MenuTab
Trade,
Galaxy,
Local
}
}

View file

@ -0,0 +1,19 @@
/* 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 System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class MenuTabButton : MonoBehaviour
{
public GameObject TabContents;
public Button Button;
public MenuTab Tab;
public TextMeshProUGUI Text;
public bool RequireDock;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d90317f6ecd38754fad9aee92f46b126
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,22 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.PluginFields;
using GameCult.Mesh;
using MessagePack;
using TMPro;
using UniRx;
using UnityEngine;
using Unity.Mathematics;
using Random = UnityEngine.Random;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
using Random = UnityEngine.Random;
using float2 = Unity.Mathematics.float2;
public class SectorMap : MonoBehaviour
{
public Camera InfluenceCamera;
public AetheriaRenderSplatRasterizer InfluenceSplatRasterizer;
public Prototype InfluenceRendererPrototype;
public MeshRenderer SectorRenderer;
public Prototype ZonePrototype;
@ -35,7 +34,6 @@ public class SectorMap : MonoBehaviour
public Texture2D HomeIcon;
public Prototype LegendPrototype;
public float IconDistance = 1;
private AetheriaClientState _runtimeState;
public float IconBackgroundSize = 3;
public float LabelDistance = .4f;
public float LinkWidth;
@ -44,42 +42,32 @@ public class SectorMap : MonoBehaviour
public Color PlayerLocationLabelColor;
public float PlayerLocationIconSize = 1.25f;
public Subject<int> ZoneClicked = new Subject<int>();
public Subject<GalaxyZone> ZoneClicked = new Subject<GalaxyZone>();
private int _currentPlayerLocation = -1;
private readonly HashSet<int> _revealedZones = new HashSet<int>();
private readonly HashSet<(int, int)> _revealedLinks = new HashSet<(int, int)>();
private readonly Dictionary<int, (MeshRenderer influenceRenderer, RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)> _factionMaterials =
new Dictionary<int, (MeshRenderer influenceRenderer, RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)>();
private readonly Dictionary<int, SectorZoneUI> _zoneInstances = new Dictionary<int, SectorZoneUI>();
private readonly Queue<IEnumerable<int>> _queuedZoneReveals = new Queue<IEnumerable<int>>();
private readonly Dictionary<int, AetheriaRuntimeSectorMapZone> _zonesByIndex =
new Dictionary<int, AetheriaRuntimeSectorMapZone>();
private AetheriaRuntimeSectorMapDocument _sectorMap;
private bool _sectorMapLoaded;
private GalaxyZone _currentPlayerLocation;
private HashSet<GalaxyZone> _revealedZones = new HashSet<GalaxyZone>();
private HashSet<(GalaxyZone, GalaxyZone)> _revealedLinks = new HashSet<(GalaxyZone, GalaxyZone)>();
public bool TryMarkPlayerLocation(int zoneIndex)
private Dictionary<Faction, (MeshRenderer influenceRenderer, RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)> _factionMaterials =
new Dictionary<Faction, (MeshRenderer influenceRenderer, RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)>();
private Dictionary<GalaxyZone, SectorZoneUI> _zoneInstances = new Dictionary<GalaxyZone, SectorZoneUI>();
private Queue<IEnumerable<GalaxyZone>> _queuedZoneReveals = new Queue<IEnumerable<GalaxyZone>>();
public void MarkPlayerLocation(GalaxyZone zone)
{
EnsureSectorMapLoaded();
if (!_zonesByIndex.ContainsKey(zoneIndex))
return false;
MarkPlayerLocation(zoneIndex);
return true;
}
private void MarkPlayerLocation(int zoneIndex)
{
if (_currentPlayerLocation >= 0 && _zoneInstances.TryGetValue(_currentPlayerLocation, out var previous))
if (_currentPlayerLocation != null)
{
previous.Label.color = Color.white;
previous.Label.fontStyle = FontStyles.Normal;
previous.IconContainer.localScale = Vector3.one;
_zoneInstances[_currentPlayerLocation].Label.color = Color.white;
_zoneInstances[_currentPlayerLocation].Label.fontStyle = FontStyles.Normal;
_zoneInstances[_currentPlayerLocation].IconContainer.localScale = Vector3.one;
}
_currentPlayerLocation = zoneIndex;
if (_zoneInstances.TryGetValue(_currentPlayerLocation, out var zoneUI))
MarkPlayerLocation(zoneUI);
_currentPlayerLocation = zone;
if(_zoneInstances.ContainsKey(_currentPlayerLocation))
{
MarkPlayerLocation(_zoneInstances[_currentPlayerLocation]);
}
}
private void MarkPlayerLocation(SectorZoneUI zoneUI)
@ -89,409 +77,268 @@ public class SectorMap : MonoBehaviour
zoneUI.IconContainer.localScale = new Vector3(PlayerLocationIconSize, PlayerLocationIconSize, 1);
}
public void QueueZoneReveal(IEnumerable<int> zoneIndices)
public void QueueZoneReveal(IEnumerable<GalaxyZone> zones)
{
_queuedZoneReveals.Enqueue(zoneIndices ?? Array.Empty<int>());
_queuedZoneReveals.Enqueue(zones);
}
public void StartReveal(float linkDuration, float iconDuration)
{
EnsureSectorMapLoaded();
if (_queuedZoneReveals.Count > 0)
{
StartCoroutine(RevealZone(_queuedZoneReveals.Dequeue(), linkDuration, iconDuration));
}
}
public IEnumerator RevealZone(IEnumerable<int> zoneIndices, float linkDuration, float iconDuration)
public IEnumerator RevealZone(IEnumerable<GalaxyZone> zones, float linkDuration, float iconDuration)
{
var linksToReveal = new List<(float2 start, float2 end, Transform linkInstance, bool critical)>();
var zoneTransforms = new List<Transform>();
var zoneInstanceScale = ZonePrototype.transform.localScale;
foreach (var zoneIndex in zoneIndices ?? Array.Empty<int>())
foreach (var zone in zones)
{
if (!_zonesByIndex.TryGetValue(zoneIndex, out var zone) || _revealedZones.Contains(zoneIndex))
continue;
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
zoneInstance.Clickable.OnClick += (_, _, _, _) => ZoneClicked.OnNext(zone.ZoneIndex);
if(zone.ZoneIndex == _currentPlayerLocation)
MarkPlayerLocation(zoneInstance);
_zoneInstances[zone.ZoneIndex] = zoneInstance;
var zoneInstanceTransform = zoneInstance.transform;
zoneTransforms.Add(zoneInstanceTransform);
zoneInstanceTransform.localPosition = new Vector3((float)zone.X, (float)zone.Y);
if (zone.OwnerFactionIndex >= 0 && _factionMaterials.TryGetValue(zone.OwnerFactionIndex, out var ownerMaterials))
if (!_revealedZones.Contains(zone))
{
zoneInstance.Primary.sharedMaterial = ownerMaterials.primaryMaterial;
zoneInstance.Secondary.sharedMaterial = ownerMaterials.secondaryMaterial;
}
else
{
zoneInstance.Secondary.gameObject.SetActive(false);
}
foreach (var link in LinksForZone(zone.ZoneIndex))
{
var adjacentIndex = link.FromZoneIndex == zone.ZoneIndex ? link.ToZoneIndex : link.FromZoneIndex;
if (!_zonesByIndex.TryGetValue(adjacentIndex, out var adjacentZone) ||
!_revealedZones.Contains(adjacentIndex) ||
_revealedLinks.Contains((zone.ZoneIndex, adjacentIndex)) ||
_revealedLinks.Contains((adjacentIndex, zone.ZoneIndex)))
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
zoneInstance.Clickable.OnClick += (clickableCollider, data, ray, hit) => ZoneClicked.OnNext(zone);
if(zone == _currentPlayerLocation)
MarkPlayerLocation(zoneInstance);
_zoneInstances[zone] = zoneInstance;
var zoneInstanceTransform = zoneInstance.transform;
zoneTransforms.Add(zoneInstanceTransform);
zoneInstanceTransform.localPosition = new Vector3(zone.Position.x, zone.Position.y);
if(zone.Owner != null)
{
continue;
zoneInstance.Primary.sharedMaterial = _factionMaterials[zone.Owner].primaryMaterial;
zoneInstance.Secondary.sharedMaterial = _factionMaterials[zone.Owner].secondaryMaterial;
if(zone == ActionGameManager.CurrentGalaxy.HomeZones[zone.Owner])
zoneInstance.Secondary.transform.localScale = Vector3.one * 4;
}
else
{
zoneInstance.Secondary.gameObject.SetActive(false);
}
var linkInstance = LinkPrototype.Instantiate<Transform>();
var critical = zone.Entrance || zone.Exit || adjacentZone.Entrance || adjacentZone.Exit;
var start = Position(zone);
var end = Position(adjacentZone);
linksToReveal.Add((start, end, linkInstance, critical));
if (zone.OwnerFactionIndex >= 0 &&
zone.OwnerFactionIndex == adjacentZone.OwnerFactionIndex &&
_factionMaterials.TryGetValue(zone.OwnerFactionIndex, out var factionMaterials))
var isOnCriticalPath = ActionGameManager.CurrentGalaxy.ExitPath?.Contains(zone) ?? false;
foreach (var adjacentZone in zone.AdjacentZones)
{
linkInstance.GetComponent<MeshRenderer>().sharedMaterial = factionMaterials.linkMaterial;
// If the adjacent zone is in the set already revealed, then show the link
if (_revealedZones.Contains(adjacentZone) &&
!(_revealedLinks.Contains((zone, adjacentZone)) ||
_revealedLinks.Contains((adjacentZone, zone))))
{
var link = LinkPrototype.Instantiate<Transform>();
var critical = isOnCriticalPath && (ActionGameManager.CurrentGalaxy.ExitPath?.Contains(adjacentZone) ?? false);
linksToReveal.Add((zone.Position, adjacentZone.Position, link, critical));
if (zone.Owner != null && zone.Owner == adjacentZone.Owner)
link.GetComponent<MeshRenderer>().sharedMaterial = _factionMaterials[zone.Owner].linkMaterial;
var dir = normalize(zone.Position - adjacentZone.Position);
link.rotation = Quaternion.Euler(0,0,atan2(dir.y,dir.x) * Mathf.Rad2Deg);
placeLink(zone.Position, adjacentZone.Position, link, 0, critical);
}
}
_revealedZones.Add(zone);
// Determine center of mass for adjacent zone links, used for placement of label and icons
var linkDirection = normalize(zone.AdjacentZones
.Aggregate(float2.zero, (v, adjacentZone) => v + normalize(adjacentZone.Position - zone.Position)));
var zoneText = zoneInstance.Label;
zoneText.text = zone.Name;
var zoneTextTransform = zoneText.GetComponent<RectTransform>();
zoneTextTransform.pivot = new Vector2(sign(linkDirection.x)/2+.5f,sign(linkDirection.y)/2+.5f);
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1);
if (zone == ActionGameManager.CurrentGalaxy.Entrance)
{
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = EntranceIcon;
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
var dir = normalize(start - end);
linkInstance.rotation = Quaternion.Euler(0, 0, atan2(dir.y, dir.x) * Mathf.Rad2Deg);
placeLink(start, end, linkInstance, 0, critical);
_revealedLinks.Add((zone.ZoneIndex, adjacentIndex));
if (zone == ActionGameManager.CurrentGalaxy.Exit)
{
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = ExitIcon;
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
var homeMega = ActionGameManager.CurrentGalaxy.HomeZones.Keys
.FirstOrDefault(m => ActionGameManager.CurrentGalaxy.HomeZones[m] == zone);
if (homeMega != null)
{
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
backgroundInstance.material.SetColor("_Color", homeMega.SecondaryColor.ToColor());
iconInstance.material.mainTexture = HomeIcon;
iconInstance.material.SetColor("_Color", homeMega.PrimaryColor.ToColor());
var backgroundTransform = backgroundInstance.transform;
var iconTransform = iconInstance.transform;
backgroundTransform.SetParent(zoneInstanceTransform);
iconTransform.SetParent(zoneInstanceTransform);
backgroundTransform.localScale = Vector3.one * IconBackgroundSize;
iconTransform.localScale = Vector3.one;
backgroundTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance, .5f);
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
var bossMega = ActionGameManager.CurrentGalaxy.BossZones.Keys
.FirstOrDefault(m => ActionGameManager.CurrentGalaxy.BossZones[m] == zone);
if (bossMega != null)
{
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
backgroundInstance.material.SetColor("_Color", bossMega.SecondaryColor.ToColor());
iconInstance.material.mainTexture = BossIcon;
iconInstance.material.SetColor("_Color", bossMega.PrimaryColor.ToColor());
var backgroundTransform = backgroundInstance.transform;
var iconTransform = iconInstance.transform;
backgroundTransform.SetParent(zoneInstanceTransform);
iconTransform.SetParent(zoneInstanceTransform);
backgroundTransform.localScale = Vector3.one * IconBackgroundSize;
iconTransform.localScale = Vector3.one;
if (homeMega != null)
{
backgroundTransform.localPosition = new Vector3(linkDirection.x * IconDistance, linkDirection.y * IconDistance, .5f);
iconTransform.localPosition = new Vector3(linkDirection.x * IconDistance, linkDirection.y * IconDistance);
}
else
{
backgroundTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance, .5f);
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
}
}
_revealedZones.Add(zone.ZoneIndex);
var linkDirection = ResolveLabelDirection(zone);
var zoneText = zoneInstance.Label;
zoneText.text = zone.Name;
var zoneTextTransform = zoneText.GetComponent<RectTransform>();
zoneTextTransform.pivot = new Vector2(sign(linkDirection.x) / 2 + .5f, sign(linkDirection.y) / 2 + .5f);
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1);
if (zone.Entrance)
AddZoneIcon(zoneInstanceTransform, EntranceIcon, linkDirection, -1);
if (zone.Exit)
AddZoneIcon(zoneInstanceTransform, ExitIcon, linkDirection, zone.Entrance ? 1 : -1);
}
foreach (var tr in zoneTransforms) tr.gameObject.SetActive(false);
// Local function for animating the placement of a link
void placeLink(float2 start, float2 end, Transform link, float t, bool critical)
{
var pos = lerp(start, end, t / 2);
link.localPosition = new Vector3(pos.x, pos.y);
link.localScale = new Vector3(length(start - end) * t, critical ? CriticalLinkWidth : LinkWidth, 1);
var localScale = link.localScale;
localScale = new Vector3(length(start - end)*t, critical ? CriticalLinkWidth : LinkWidth, 1);
link.localScale = localScale;
}
var startTime = Time.time;
while (Time.time - startTime < linkDuration)
{
var t = (Time.time - startTime) / linkDuration;
foreach (var (start, end, link, critical) in linksToReveal)
placeLink(end, start, link, t, critical);
foreach (var (start, end, link, critical) in linksToReveal) placeLink(end, start, link, t, critical);
yield return null;
}
foreach (var (start, end, link, critical) in linksToReveal)
placeLink(start, end, link, 1, critical);
foreach (var tr in zoneTransforms)
tr.gameObject.SetActive(true);
foreach (var (start, end, link, critical) in linksToReveal) placeLink(start, end, link, 1, critical);
foreach (var tr in zoneTransforms) tr.gameObject.SetActive(true);
startTime = Time.time;
while (Time.time - startTime < iconDuration)
{
var t = (Time.time - startTime) / iconDuration;
foreach (var tr in zoneTransforms)
tr.localScale = zoneInstanceScale * IconScaleAnimation.Evaluate(t);
foreach (var tr in zoneTransforms) tr.localScale = zoneInstanceScale * IconScaleAnimation.Evaluate(t);
RenderInfluence();
yield return null;
}
foreach (var tr in zoneTransforms)
tr.localScale = zoneInstanceScale;
foreach (var tr in zoneTransforms) tr.localScale = zoneInstanceScale;
StartReveal(linkDuration, iconDuration);
}
public void Start()
{
EnsureSectorMapLoaded();
DisableLegacyInfluenceCamera();
}
private void EnsureSectorMapLoaded()
{
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-sector-map");
_sectorMap = _runtimeState.SectorMap.Latest();
if (_sectorMapLoaded)
return;
_sectorMapLoaded = true;
if (_sectorMap?.Zones == null || _sectorMap.Zones.Count == 0)
if (ActionGameManager.CurrentGalaxy == null)
{
gameObject.SetActive(false);
return;
}
_zonesByIndex.Clear();
foreach (var zone in _sectorMap.Zones)
_zonesByIndex[zone.ZoneIndex] = zone;
foreach (var factionIndex in ResolveFactionIndices())
AddFactionMaterials(factionIndex);
QueueZoneReveal(_sectorMap.DiscoveredZoneIndices);
if (_queuedZoneReveals.Count == 0)
QueueZoneReveal(_sectorMap.Zones.Select(zone => zone.ZoneIndex));
if (_sectorMap.CurrentZoneIndex >= 0)
TryMarkPlayerLocation(_sectorMap.CurrentZoneIndex);
}
private void AddFactionMaterials(int factionIndex)
{
if (_factionMaterials.ContainsKey(factionIndex))
return;
var primaryColor = ResolveFactionColor(factionIndex, secondary: false);
var secondaryColor = ResolveFactionColor(factionIndex, secondary: true);
var influenceTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf);
var influenceRenderer = InfluenceRendererPrototype.Instantiate<MeshRenderer>();
influenceRenderer.material.mainTexture = influenceTexture;
influenceRenderer.material.SetColor("_Color1", primaryColor);
influenceRenderer.material.SetColor("_Color2", secondaryColor);
influenceRenderer.material.SetFloat("_FillTilt", Random.value * PI);
var primary = Instantiate(ZonePrimaryMaterial);
primary.SetColor("_Color", primaryColor * MegaPrimaryBoost);
var secondary = Instantiate(ZoneSecondaryMaterial);
secondary.SetColor("_Color", secondaryColor * MegaSecondaryBoost);
var link = Instantiate(ZoneLinkMaterial);
link.SetColor("_Color", primaryColor * MegaLinkBoost);
_factionMaterials.Add(factionIndex, (influenceRenderer, influenceTexture, primary, secondary, link));
var legendElement = LegendPrototype.Instantiate<LegendElement>();
legendElement.Primary.color = primaryColor;
legendElement.Secondary.color = secondaryColor;
legendElement.Label.text = factionIndex < 0 ? "None" : $"F{factionIndex}";
}
private IEnumerable<int> ResolveFactionIndices()
{
return (_sectorMap?.Zones ?? Array.Empty<AetheriaRuntimeSectorMapZone>())
.SelectMany(zone => (zone.FactionIndices ?? Array.Empty<int>()).Append(zone.OwnerFactionIndex))
.Where(index => index >= 0)
.Distinct()
.OrderBy(index => index);
}
private Color ResolveFactionColor(int factionIndex, bool secondary)
{
var hue = frac((factionIndex + (secondary ? 0.37f : 0f)) * 0.173f);
return Color.HSVToRGB(hue, secondary ? 0.48f : 0.62f, secondary ? 0.72f : 0.88f);
}
private IEnumerable<AetheriaRuntimeSectorMapLink> LinksForZone(int zoneIndex)
{
return (_sectorMap?.Links ?? Array.Empty<AetheriaRuntimeSectorMapLink>())
.Where(link => link.FromZoneIndex == zoneIndex || link.ToZoneIndex == zoneIndex);
}
private float2 ResolveLabelDirection(AetheriaRuntimeSectorMapZone zone)
{
var direction = float2.zero;
foreach (var adjacentIndex in zone.AdjacentZoneIndices ?? Array.Empty<int>())
foreach (var mega in ActionGameManager.CurrentGalaxy.Factions)
{
if (_zonesByIndex.TryGetValue(adjacentIndex, out var adjacent))
direction += normalizesafe(Position(adjacent) - Position(zone));
var influenceTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf);
var influenceRenderer = InfluenceRendererPrototype.Instantiate<MeshRenderer>();
influenceRenderer.material.mainTexture = influenceTexture;
influenceRenderer.material.SetColor("_Color1", mega.PrimaryColor.ToColor());
influenceRenderer.material.SetColor("_Color2", mega.SecondaryColor.ToColor());
influenceRenderer.material.SetFloat("_FillTilt", Random.value * PI);
var primary = Instantiate(ZonePrimaryMaterial);
primary.SetColor("_Color", (mega.PrimaryColor * MegaPrimaryBoost).ToColor());
var secondary = Instantiate(ZoneSecondaryMaterial);
secondary.SetColor("_Color", (mega.SecondaryColor * MegaSecondaryBoost).ToColor());
var link = Instantiate(ZoneLinkMaterial);
link.SetColor("_Color", (mega.PrimaryColor * MegaLinkBoost).ToColor());
_factionMaterials.Add(mega, (influenceRenderer, influenceTexture, primary, secondary, link));
var legendElement = LegendPrototype.Instantiate<LegendElement>();
legendElement.Primary.color = mega.PrimaryColor.ToColor();
legendElement.Secondary.color = mega.SecondaryColor.ToColor();
legendElement.Label.text = mega.ShortName;
}
return lengthsq(direction) <= 0 ? new float2(0, 1) : normalize(direction);
}
private void AddZoneIcon(
Transform zoneInstanceTransform,
Texture2D icon,
float2 linkDirection,
int side)
{
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = icon;
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(
side * -linkDirection.x * IconDistance,
side * -linkDirection.y * IconDistance);
SectorRenderer.material.SetFloat("CloudAmplitude", ActionGameManager.CurrentGalaxy.Background.CloudAmplitude);
SectorRenderer.material.SetFloat("CloudExponent", ActionGameManager.CurrentGalaxy.Background.CloudExponent);
SectorRenderer.material.SetFloat("NoisePosition", ActionGameManager.CurrentGalaxy.Background.NoisePosition);
SectorRenderer.material.SetFloat("NoiseAmplitude", ActionGameManager.CurrentGalaxy.Background.NoiseAmplitude);
SectorRenderer.material.SetFloat("NoiseOffset", ActionGameManager.CurrentGalaxy.Background.NoiseOffset);
SectorRenderer.material.SetFloat("NoiseGain", ActionGameManager.CurrentGalaxy.Background.NoiseGain);
SectorRenderer.material.SetFloat("NoiseLacunarity", ActionGameManager.CurrentGalaxy.Background.NoiseLacunarity);
SectorRenderer.material.SetFloat("NoiseFrequency", ActionGameManager.CurrentGalaxy.Background.NoiseFrequency);
}
private void RenderInfluence()
{
DisableLegacyInfluenceCamera();
foreach (var pair in _factionMaterials)
// Render Influence Textures
foreach (var mega in ActionGameManager.CurrentGalaxy.Factions)
{
var document = BuildInfluenceSplatDocument(pair.Key);
ResolveInfluenceSplatRasterizer().RenderLayerToTarget(
document,
pair.Value.influence,
0,
0,
Color.clear);
}
}
private AetheriaRenderSplatRasterizer ResolveInfluenceSplatRasterizer()
{
if (InfluenceSplatRasterizer != null)
return InfluenceSplatRasterizer;
InfluenceSplatRasterizer = GetComponent<AetheriaRenderSplatRasterizer>();
if (InfluenceSplatRasterizer == null)
InfluenceSplatRasterizer = gameObject.AddComponent<AetheriaRenderSplatRasterizer>();
return InfluenceSplatRasterizer;
}
private EveFieldsSplatsDocument BuildInfluenceSplatDocument(int factionIndex)
{
var zones = (_sectorMap?.Zones ?? Array.Empty<AetheriaRuntimeSectorMapZone>()).ToArray();
var minX = zones.Length > 0 ? zones.Min(zone => zone.X) : -1;
var maxX = zones.Length > 0 ? zones.Max(zone => zone.X) : 1;
var minY = zones.Length > 0 ? zones.Min(zone => zone.Y) : -1;
var maxY = zones.Length > 0 ? zones.Max(zone => zone.Y) : 1;
var padding = Math.Max(IconBackgroundSize * 2, 4);
var centerX = new List<double>();
var centerY = new List<double>();
var halfExtentX = new List<double>();
var halfExtentY = new List<double>();
var rotationCos = new List<double>();
var rotationSin = new List<double>();
var channel = new List<int>();
var falloff = new List<int>();
var valueR = new List<double>();
var valueG = new List<double>();
var valueB = new List<double>();
var valueA = new List<double>();
var sourceKey = new List<string>();
var layerIndex = new List<int>();
var sourceKind = new List<int>();
var frequencyX = new List<double>();
var frequencyY = new List<double>();
var phaseX = new List<double>();
var phaseY = new List<double>();
var animationSpeed = new List<double>();
var sourceFlags = new List<double>();
foreach (var zone in zones)
{
if (!_zoneInstances.ContainsKey(zone.ZoneIndex))
continue;
var influence = ResolveZoneInfluence(zone, factionIndex);
if (Math.Abs(influence) <= 0.0001f)
continue;
centerX.Add(zone.X);
centerY.Add(zone.Y);
halfExtentX.Add(Math.Max(IconBackgroundSize, 1));
halfExtentY.Add(Math.Max(IconBackgroundSize, 1));
rotationCos.Add(1);
rotationSin.Add(0);
channel.Add(AetheriaRuntimeRenderSplatChannels.Influence);
falloff.Add(AetheriaRuntimeRenderSplatFalloffs.Smooth);
valueR.Add(influence);
valueG.Add(influence);
valueB.Add(influence);
valueA.Add(1);
sourceKey.Add($"sector-zone:{zone.ZoneIndex}:faction:{factionIndex}");
layerIndex.Add(0);
sourceKind.Add(AetheriaRuntimeRenderSplatSourceKinds.Constant);
frequencyX.Add(0);
frequencyY.Add(0);
phaseX.Add(0);
phaseY.Add(0);
animationSpeed.Add(0);
sourceFlags.Add(0);
}
return new EveFieldsSplatsDocument
{
Schema = AetheriaRuntimeDaemonSchemas.RenderSplatsViewport,
Viewport = new EveFieldsViewport
foreach (var zone in ActionGameManager.CurrentGalaxy.Zones)
{
MinX = minX - padding,
MinY = minY - padding,
MaxX = maxX + padding,
MaxY = maxY + padding
},
Layers = new[]
{
new EveFieldsSplatLayer
if(_zoneInstances.ContainsKey(zone))
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.Influence,
DisplayName = "Sector Influence",
Channel = AetheriaRuntimeRenderSplatChannels.Influence,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "R16_SFloat"
var instance = _zoneInstances[zone];
var influence = 0f;
if (zone.Factions.Length > 0)
{
if (zone.Factions.Contains(mega))
{
influence = 10;
if (zone.Owner != mega)
influence *= .5f;
}
else influence = -10;
}
instance.Influence.material.SetFloat("_Depth", influence);
}
},
Splats = new EveFieldsSplatSoa
{
Count = centerX.Count,
CenterX = centerX,
CenterY = centerY,
HalfExtentX = halfExtentX,
HalfExtentY = halfExtentY,
RotationCos = rotationCos,
RotationSin = rotationSin,
Channel = channel,
Falloff = falloff,
ValueR = valueR,
ValueG = valueG,
ValueB = valueB,
ValueA = valueA,
SourceKey = sourceKey,
LayerIndex = layerIndex,
SourceKind = sourceKind,
FrequencyX = frequencyX,
FrequencyY = frequencyY,
PhaseX = phaseX,
PhaseY = phaseY,
AnimationSpeed = animationSpeed,
SourceFlags = sourceFlags
}
};
}
private static float ResolveZoneInfluence(AetheriaRuntimeSectorMapZone zone, int factionIndex)
{
if (zone.FactionIndices?.Count <= 0)
return 0f;
if (!zone.FactionIndices.Contains(factionIndex))
return -10f;
return zone.OwnerFactionIndex == factionIndex ? 10f : 5f;
}
private void DisableLegacyInfluenceCamera()
{
if (InfluenceCamera == null)
return;
InfluenceCamera.targetTexture = null;
InfluenceCamera.gameObject.SetActive(false);
}
private static float2 Position(AetheriaRuntimeSectorMapZone zone)
{
return new float2((float)zone.X, (float)zone.Y);
InfluenceCamera.targetTexture = _factionMaterials[mega].influence;
InfluenceCamera.Render();
}
}
}

View file

@ -1,15 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
using GameCult.Mesh;
using System.Linq;
using UniRx;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
@ -17,8 +12,10 @@ using float2 = Unity.Mathematics.float2;
public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IScrollHandler
{
public ClickRaycaster Raycaster;
public PropertiesPanel Properties;
public Canvas Canvas;
public SectorMap Map;
public ActionGameManager GameManager;
public Camera SectorCamera;
public MeshRenderer SectorBackgroundRenderer;
public float ZoomSpeed;
@ -36,48 +33,77 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
private Transform _sectorBackgroundTransform;
private Transform _sectorCameraTransform;
private UnityEngine.UI.Image _outputImage;
private Image _outputImage;
private RenderTexture _outputTexture;
private int2 _size;
private bool _init;
private float _aspectRatio;
private float _sectorBackgroundDepth;
private float _sectorCameraDepth;
private UIDocument _zoneDetailsSurfaceDocument;
private AetheriaClientState _runtimeState;
private readonly AetheriaEveUnitySurfaceChrome _zoneDetailsSurfaceChrome = new AetheriaEveUnitySurfaceChrome
{
RootAlignItems = Align.FlexEnd,
RootPaddingTop = 24f,
RootPaddingRight = 24f,
Width = 360f,
MinWidth = 0f,
MaxWidth = 420f,
PaddingLeft = 18f,
PaddingRight = 18f,
PaddingTop = 18f,
PaddingBottom = 18f
};
private float2 _position = float2(0.5f);
private float _viewSize = .5f;
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-sector-renderer");
void Start()
{
_outputImage = GetComponent<UnityEngine.UI.Image>();
_outputImage = GetComponent<Image>();
_sectorBackgroundTransform = SectorBackgroundRenderer.transform;
_sectorBackgroundDepth = _sectorBackgroundTransform.position.z;
_sectorCameraTransform = SectorCamera.transform;
_sectorCameraDepth = _sectorCameraTransform.position.z;
Raycaster.OnClickMiss += data =>
{
HideZoneDetailsSurface();
Properties.gameObject.SetActive(false);
};
Map.ZoneClicked.Subscribe(zone =>
{
RenderZoneDetailsSurface(zone);
Properties.gameObject.SetActive(true);
Properties.Clear();
Properties.Title.text = zone.Name;
Properties.AddProperty("Owner", () => zone.Owner?.Name ?? "None");
var otherFactions = zone.Factions
.Where(f => f.ID != zone.Owner?.ID)
.Select(f=>f.Name).ToArray();
if (otherFactions.Length > 0)
Properties.AddProperty("Factions Present", () => string.Join(", ", otherFactions));
var density = saturate(ActionGameManager.CurrentGalaxy.Background.CloudDensity(zone.Position)/2);
var radius = GameManager.Settings.ZoneSettings.ZoneRadius.Evaluate(density);
var mass = GameManager.Settings.ZoneSettings.ZoneMass.Evaluate(density);
Properties.AddProperty("Mass", () => ActionGameManager.PlayerSettings.Format(mass));
Properties.AddProperty("Radius", () => ActionGameManager.PlayerSettings.Format(radius));
if (zone.PackedContents == null)
{
Properties.AddProperty(() => "Has not been visited");
}
else
{
var planetCount = zone.PackedContents.Planets.Count(body => body is PlanetData).ToString();
Properties.AddProperty("Planets", () => planetCount);
var beltCount = zone.PackedContents.Planets.Count(body => body is AsteroidBeltData).ToString();
Properties.AddProperty("Asteroid Belts", () => beltCount);
var giantCount = zone.PackedContents.Planets.Count(body => body is GasGiantData && !(body is SunData)).ToString();
Properties.AddProperty("Gas Giants", () => giantCount);
var starCount = zone.PackedContents.Planets.Count(body => body is SunData).ToString();
Properties.AddProperty("Stars", () => starCount);
var stationCount = zone.PackedContents.Entities
.Count(entity => ((HullData) entity.Hull.Data.Value).HullType == HullType.Station)
.ToString();
Properties.AddProperty("Stations", () => stationCount);
var turretCount = zone.PackedContents.Entities
.Count(entity => ((HullData) entity.Hull.Data.Value).HullType == HullType.Turret)
.ToString();
Properties.AddProperty("Turrets", () => turretCount);
var shipCount = zone.PackedContents.Entities
.Count(entity => ((HullData) entity.Hull.Data.Value).HullType == HullType.Ship)
.ToString();
Properties.AddProperty("Ships", () => shipCount);
}
});
// PathAnimationButton.onClick.AddListener(() =>
@ -86,93 +112,48 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
// });
}
private void RenderZoneDetailsSurface(int zoneIndex)
{
var surface = ResolveZoneDetailsSurface(zoneIndex);
if (surface == null)
return;
_zoneDetailsSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
transform,
_zoneDetailsSurfaceDocument,
"Aetheria Sector Zone Details Surface",
surface,
HandleZoneDetailsSurfaceCommand,
_zoneDetailsSurfaceChrome);
}
private void HandleZoneDetailsSurfaceCommand(EveSurfaceCommandRequest request)
{
if (!AetheriaRuntimeZoneDetailsSurfaceCommands.TryRead(request, out var command))
{
Debug.LogWarning($"Unknown sector-map zone details command: {request?.Command}");
return;
}
if (command.Kind == AetheriaRuntimeZoneDetailsCommandKind.Close)
{
HideZoneDetailsSurface();
return;
}
Debug.LogWarning($"Unknown sector-map zone details command: {request?.Command}");
}
private void HideZoneDetailsSurface()
{
if (_zoneDetailsSurfaceDocument == null)
return;
AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument);
}
private AetheriaRuntimeSurfaceDocument ResolveZoneDetailsSurface(int zoneIndex)
{
if (zoneIndex < 0)
return null;
try
{
return RuntimeState.ZoneDetailsSurface(zoneIndex).Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria sector zone details surface from managed Verse state: {ex.Message}");
return null;
}
}
// private IEnumerator AnimatePath()
// {
// var pathZones = ActionGameManager.CurrentSector.ExitPath;
// LegendPanel.SetActive(false);
// PathAnimationButton.gameObject.SetActive(false);
//
// var revealCount = ActionGameManager.CurrentSector.Entrance.Distance[ActionGameManager.CurrentSector.Exit];
// Map.StartReveal(
// PathAnimationDuration / revealCount * (LinkAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)),
// PathAnimationDuration / revealCount * (IconAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)));
// MainCamera.enabled = false;
// SectorCamera.targetTexture = null;
// Canvas.gameObject.SetActive(false);
// SectorCamera.gameObject.SetActive(true);
//
// var pathAnimationLerp = 0f;
// while (pathAnimationLerp < 1)
// {
// var currentTargetZone = pathZones[(int) (pathZones.Length * pathAnimationLerp)];
// _position = lerp(_position, currentTargetZone.Position, PathAnimationDamping);
// pathAnimationLerp += Time.deltaTime / (PathAnimationDuration * PathAnimationDurationPadding);
// UpdateCamera();
// yield return null;
// }
//
// LegendPanel.SetActive(true);
// PathAnimationButton.gameObject.SetActive(true);
// }
private void OnEnable()
{
_init = true;
SectorCamera.gameObject.SetActive(true);
var currentZone = ResolveCurrentZone();
_position = currentZone == null
? float2.zero
: new float2((float)currentZone.PositionX, (float)currentZone.PositionY);
_position = GameManager.Zone.GalaxyZone.Position;
_viewSize = .25f;
Map.StartReveal(LinkAnimationDuration, IconAnimationDuration);
if (currentZone != null)
Map.TryMarkPlayerLocation(currentZone.ZoneIndex);
}
private AetheriaRuntimeCurrentZoneDocument ResolveCurrentZone()
{
try
{
return RuntimeState.CurrentZone.Latest();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria sector current zone from managed Verse state: {ex.Message}");
return null;
}
Map.MarkPlayerLocation(GameManager.CurrentEntity.Zone.GalaxyZone);
}
private void OnDisable()
{
HideZoneDetailsSurface();
if (_outputTexture != null)
{
_outputTexture.Release();
@ -181,15 +162,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
SectorCamera.gameObject.SetActive(false);
}
private void OnDestroy()
{
if (_zoneDetailsSurfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_zoneDetailsSurfaceDocument);
_zoneDetailsSurfaceDocument = null;
}
}
void LateUpdate()
{
var size = int2(Screen.width, Screen.height);
@ -201,7 +173,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
{
_outputTexture.Release();
}
_outputTexture = new RenderTexture(_size.x, _size.y, 16, RenderTextureFormat.Default);
_outputTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
SectorCamera.targetTexture = _outputTexture;
_outputImage.material.SetTexture("_DetailTex", _outputTexture);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,472 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Contexts;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class TradeMenuDebug : MonoBehaviour
{
public ActionGameManager GameManager;
public ContextMenu ContextMenu;
public ConfirmationDialog Dialog;
public Button NewFilterButton;
public Prototype FilterPrototype;
public SizeFilter MinimumSizeFilter;
public SizeFilter MaximumSizeFilter;
public PropertiesPanel Properties;
public Spreadsheet Spreadsheet;
public TextMeshProUGUI TargetCargoLabel;
public Button FoldoutButton;
private EquippedCargoBay _targetCargo;
private (ItemFilter filter, HardpointType type) _hardpointFilter;
private (ItemFilter filter, SimpleCommodityCategory type) _commodityFilter;
private (ItemFilter filter, CompoundCommodityCategory type) _compoundCommodityFilter;
private List<(ItemFilter filter, Type type)> _behaviorFilters = new List<(ItemFilter filter, Type type)>();
private void OnEnable()
{
_targetCargo = GameManager.DockingBay;
TargetCargoLabel.text = "Docking Bay";
Properties.GameManager = GameManager;
MinimumSizeFilter.Width.onEndEdit.AddListener(_ => Populate());
MinimumSizeFilter.Height.onEndEdit.AddListener(_ => Populate());
MaximumSizeFilter.Width.onEndEdit.AddListener(_ => Populate());
MaximumSizeFilter.Height.onEndEdit.AddListener(_ => Populate());
NewFilterButton.onClick.AddListener(() =>
{
ContextMenu.Clear();
IEnumerable<HardpointType> hardpointTypes = (HardpointType[]) Enum.GetValues(typeof(HardpointType));
if (_hardpointFilter.filter != null)
hardpointTypes = hardpointTypes.Where(x => x != _hardpointFilter.type);
IEnumerable<SimpleCommodityCategory> commodityTypes = (SimpleCommodityCategory[]) Enum.GetValues(typeof(SimpleCommodityCategory));
if (_commodityFilter.filter != null)
commodityTypes = commodityTypes.Where(x => x != _commodityFilter.type);
IEnumerable<CompoundCommodityCategory> compoundCommodityTypes = (CompoundCommodityCategory[]) Enum.GetValues(typeof(CompoundCommodityCategory));
if (_compoundCommodityFilter.filter != null)
compoundCommodityTypes = compoundCommodityTypes.Where(x => x != _compoundCommodityFilter.type);
ContextMenu.AddDropdown("Gear Type", hardpointTypes
.Select<HardpointType, (string, Action, bool)>(x => (Enum.GetName(typeof(HardpointType), x), () =>
{
if (_hardpointFilter.filter == null)
{
_hardpointFilter.filter = FilterPrototype.Instantiate<ItemFilter>();
_hardpointFilter.filter.OnDisable += () =>
{
_hardpointFilter.filter = null;
Populate();
};
}
if(_commodityFilter.filter != null)
{
_commodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_commodityFilter.filter = null;
}
if(_compoundCommodityFilter.filter != null)
{
_compoundCommodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_compoundCommodityFilter.filter = null;
}
_hardpointFilter.filter.Label.text = $"Hardpoint: {Enum.GetName(typeof(HardpointType), x)}";
_hardpointFilter.type = x;
Populate();
}, true)));
ContextMenu.AddDropdown("Simple Commodity", commodityTypes
.Select<SimpleCommodityCategory, (string, Action, bool)>(x => (Enum.GetName(typeof(SimpleCommodityCategory), x), () =>
{
if (_commodityFilter.filter == null)
{
_commodityFilter.filter = FilterPrototype.Instantiate<ItemFilter>();
_commodityFilter.filter.OnDisable += () =>
{
_commodityFilter.filter = null;
Populate();
};
}
if(_hardpointFilter.filter != null)
{
_hardpointFilter.filter.GetComponent<Prototype>().ReturnToPool();
_hardpointFilter.filter = null;
}
if(_compoundCommodityFilter.filter != null)
{
_compoundCommodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_compoundCommodityFilter.filter = null;
}
_commodityFilter.filter.Label.text = $"Hardpoint: {Enum.GetName(typeof(SimpleCommodityCategory), x)}";
_commodityFilter.type = x;
Populate();
}, true)));
ContextMenu.AddDropdown("Compound Commodity", compoundCommodityTypes
.Select<CompoundCommodityCategory, (string, Action, bool)>(x => (Enum.GetName(typeof(CompoundCommodityCategory), x), () =>
{
if (_compoundCommodityFilter.filter == null)
{
_compoundCommodityFilter.filter = FilterPrototype.Instantiate<ItemFilter>();
_compoundCommodityFilter.filter.OnDisable += () =>
{
_compoundCommodityFilter.filter = null;
Populate();
};
}
if(_hardpointFilter.filter != null)
{
_hardpointFilter.filter.GetComponent<Prototype>().ReturnToPool();
_hardpointFilter.filter = null;
}
if(_commodityFilter.filter != null)
{
_commodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_commodityFilter.filter = null;
}
_compoundCommodityFilter.filter.Label.text = $"Hardpoint: {Enum.GetName(typeof(CompoundCommodityCategory), x)}";
_compoundCommodityFilter.type = x;
Populate();
}, true)));
ContextMenu.AddDropdown("Item Behavior", typeof(BehaviorData).GetAllChildClasses()
.Where(x=> x.GetCustomAttribute<RuntimeInspectable>() != null && _behaviorFilters.All(f => f.type != x))
.Select<Type, (string, Action, bool)>(x=> (x.Name.FormatTypeName(), () =>
{
var matchingType = _behaviorFilters.FirstOrDefault(y => y.type.IsAssignableFrom(x) || x.IsAssignableFrom(y.type));
if (matchingType.filter != null) matchingType.filter.DisableButton.onClick.Invoke();
var filter = FilterPrototype.Instantiate<ItemFilter>();
filter.Label.text = x.Name.FormatTypeName();
filter.OnDisable += () =>
{
_behaviorFilters.Remove((filter, x));
Populate();
};
_behaviorFilters.Add((filter, x));
Populate();
}, true)));
if(!MinimumSizeFilter.gameObject.activeSelf)
ContextMenu.AddOption("Minimum Size",
() =>
{
MinimumSizeFilter.gameObject.SetActive(true);
MinimumSizeFilter.OnDisable += () => Populate();
});
if(!MaximumSizeFilter.gameObject.activeSelf)
ContextMenu.AddOption("Maximum Size",
() =>
{
MaximumSizeFilter.gameObject.SetActive(true);
MaximumSizeFilter.OnDisable += () => Populate();
});
ContextMenu.Show();
});
Populate();
}
void Populate()
{
var columns = new List<(string name, int size, Func<ItemData, Func<string>> output, Func<ItemData, IComparable> sortKey)>();
columns.Add(("Name", 3,
data => () => data.Name,
data => data.Name));
if(_hardpointFilter.filter==null)
columns.Add(("Type", 2,
data => () =>
{
if (data is SimpleCommodityData s) return Enum.GetName(typeof(SimpleCommodityCategory), s.Category);
if(data is CompoundCommodityData c) return Enum.GetName(typeof(CompoundCommodityCategory), c.Category);
if(data is EquippableItemData e) return Enum.GetName(typeof(HardpointType), e.HardpointType);
return "None";
},
data =>
{
if (data is SimpleCommodityData s) return (int) s.Category;
var offset = Enum.GetValues(typeof(SimpleCommodityCategory)).Length;
if(data is CompoundCommodityData c) return (int) c.Category + offset;
offset += Enum.GetValues(typeof(CompoundCommodityCategory)).Length;
if(data is EquippableItemData e) return (int) e.HardpointType + offset;
return 0;
}));
columns.Add(("Mass", 1,
data => () => ActionGameManager.PlayerSettings.Format(data.Mass),
data => data.Mass));
columns.Add(("Price", 1,
data => () => data.Price.ToString("N0"),
data => data.Price));
columns.Add(("Size", 1,
data => () => $"{data.Shape.Width}x{data.Shape.Height}",
data => data.Shape.Width*data.Shape.Height));
var items = GameManager.ItemManager.ItemData.GetAll<ItemData>().Where(i=>i.Price!=0);
if (MinimumSizeFilter.gameObject.activeSelf)
items = items.Where(i =>
!(MinimumSizeFilter.Width.text.Length > 0 && i.Shape.Width < int.Parse(MinimumSizeFilter.Width.text) ||
MinimumSizeFilter.Height.text.Length > 0 && i.Shape.Height < int.Parse(MinimumSizeFilter.Height.text)));
if (MaximumSizeFilter.gameObject.activeSelf)
items = items.Where(i =>
!(MaximumSizeFilter.Width.text.Length > 0 && i.Shape.Width > int.Parse(MaximumSizeFilter.Width.text) ||
MaximumSizeFilter.Height.text.Length > 0 && i.Shape.Height > int.Parse(MaximumSizeFilter.Height.text)));
if(_commodityFilter.filter != null)
items = items.Where(i => i is SimpleCommodityData s && s.Category == _commodityFilter.type);
if(_compoundCommodityFilter.filter != null)
items = items.Where(i => i is CompoundCommodityData c && c.Category == _compoundCommodityFilter.type);
if (_hardpointFilter.filter != null)
items = items.Where(i => i is EquippableItemData e && e.HardpointType == _hardpointFilter.type);
foreach (var (_, type) in _behaviorFilters)
{
items = items.Where(i => i is EquippableItemData e && e.Behaviors.Any(b => type.IsInstanceOfType(b)));
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
{
var fieldType = field.FieldType;
if (fieldType == typeof(float))
columns.Add((field.Name, 1, data =>
{
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
return () => ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior));
}, data =>
{
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
return (float) field.GetValue(behavior);
}));
else if (fieldType == typeof(int))
columns.Add((field.Name, 1, data =>
{
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
return () => ((int) field.GetValue(behavior)).ToString();
}, data =>
{
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
return (int) field.GetValue(behavior);
}));
else if (fieldType == typeof(PerformanceStat))
{
columns.Add((field.Name, 1, data =>
{
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
return () => ActionGameManager.PlayerSettings.Format(((PerformanceStat) field.GetValue(behavior)).Max);
}, data =>
{
var behavior = ((EquippableItemData) data).Behaviors.FirstOrDefault(b => type.IsInstanceOfType(b));
return ((PerformanceStat) field.GetValue(behavior)).Max;
}));
}
}
}
columns.Add(("Owned", 1,
data => () =>
{
if (data is HullData)
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true}).ToString();
if(data is SimpleCommodityData)
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0).ToString();
},
data =>
{
if (data is HullData)
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true});
if(data is SimpleCommodityData)
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0;
}));
Spreadsheet.ShowData(
columns.Select(x => x.name).ToArray(),
columns.Select(x => x.size).ToArray(),
items.Select(i => new SpreadsheetEntryRow
{
Columns = columns.Select(x => new SpreadsheetEntryColumn
{
Output = x.output(i),
SortKey = x.sortKey(i)
}).ToArray(),
OnClick = () =>
{
Properties.Inspect(i);
},
OnDoubleClick = () =>
{
switch (i)
{
case HullData h:
Buy(h);
break;
case CraftedItemData c:
Buy(c,1);
break;
case SimpleCommodityData s:
Buy(s, 1);
break;
}
Populate();
},
OnRightClick = () =>
{
if (!(i is HullData))
{
ContextMenu.Clear();
ContextMenu.AddOption("Buy Quantity",
() =>
{
int quantity = 1;
Dialog.Clear();
Dialog.Title.text = $"Buying {i.Name}";
Dialog.AddField("Quantity", () => quantity, q => quantity = min(q, GameManager.Credits/i.Price));
Dialog.Show(() =>
{
switch (i)
{
case CraftedItemData c:
Buy(c,quantity);
break;
case SimpleCommodityData s:
Buy(s, quantity);
break;
}
Populate();
});
Dialog.MoveToCursor();
});
ContextMenu.Show();
}
}
}));
}
private void Buy(HullData data)
{
if (data.Price < GameManager.Credits)
{
var hull = GameManager.ItemManager.CreateInstance(data) as EquippableItem;
Entity entity;
if(data.HullType==HullType.Ship)
entity = new Ship(GameManager.ItemManager, GameManager.Zone, hull, GameManager.Settings.GameplaySettings.DefaultEntitySettings) {IsPlayerShip = true};
else entity = new OrbitalEntity(GameManager.ItemManager, GameManager.Zone, hull, Guid.Empty, GameManager.Settings.GameplaySettings.DefaultEntitySettings);
entity.SetParent(GameManager.DockedEntity);
GameManager.Credits -= data.Price;
}
else
{
Dialog.Clear();
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
Dialog.Show();
Dialog.MoveToCursor();
}
}
private void Buy(CraftedItemData data, int quantity)
{
for (int i = 0; i < quantity; i++)
{
if (data.Price < GameManager.Credits)
{
if (_targetCargo.TryStore(GameManager.ItemManager.CreateInstance(data)))
{
GameManager.Credits -= data.Price;
}
else
{
Dialog.Clear();
Dialog.Title.text = "Unable to buy: Insufficient Cargo Space!";
Dialog.Show();
Dialog.MoveToCursor();
return;
}
}
else
{
Dialog.Clear();
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
Dialog.Show();
Dialog.MoveToCursor();
return;
}
}
}
private void Buy(SimpleCommodityData data, int quantity)
{
// Up-rounded integer division from https://stackoverflow.com/a/503201
int lots = (quantity - 1) / data.MaxStack + 1;
int remaining = quantity;
for (int i = 0; i < lots; i++)
{
int q = min(remaining, data.MaxStack);
if (q * data.Price < GameManager.Credits)
{
if (_targetCargo.TryStore(GameManager.ItemManager.CreateInstance(data, q)))
{
GameManager.Credits -= q * data.Price;
remaining -= q;
}
else
{
Dialog.Clear();
Dialog.Title.text = "Unable to buy: Insufficient Cargo Space!";
Dialog.Show();
Dialog.MoveToCursor();
return;
}
}
else
{
Dialog.Clear();
Dialog.Title.text = "Unable to buy: Insufficient Credits!";
Dialog.Show();
Dialog.MoveToCursor();
return;
}
}
}
void Start()
{
FoldoutButton.onClick.AddListener(() =>
{
ContextMenu.Clear();
if(_targetCargo != GameManager.DockingBay)
ContextMenu.AddOption("Docking Bay",
() =>
{
_targetCargo = GameManager.DockingBay;
TargetCargoLabel.text = "Docking Bay";
});
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(e => e is Ship {IsPlayerShip: true}))
{
foreach (var bay in ship.CargoBays.Select((bay, index) => (bay, index)))
ContextMenu.AddOption($"{ship.Name} Bay {bay.index}",
() =>
{
_targetCargo = bay.bay;
TargetCargoLabel.text = $"{ship.Name} Bay {bay.index}";
});
}
});
}
void Update()
{
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6eed32eb39c04a31b81e8a55685b222c
timeCreated: 1616191013

View file

@ -0,0 +1,65 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UniRx;
using UnityEngine;
using UnityEngine.EventSystems;
public class WeaponGroupAssignment : MonoBehaviour
{
public RectTransform Container;
public WeaponGroupElement GroupPrefab;
public Color ActiveColor;
public Color InactiveColor;
Subject<(PointerEventData pointerEventData, int group)> _onBeginDrag;
Subject<(PointerEventData pointerEventData, int group)> _onDrag;
Subject<(PointerEventData pointerEventData, int group)> _onEndDrag;
public List<WeaponGroupElement> Groups { get; } = new List<WeaponGroupElement>();
public void Inspect(EquippedItem item)
{
var weapon = item.GetBehavior<Weapon>();
if (weapon == null) throw new ArgumentException($"Attempted to inspect weapon groups on item \"{item.Data.Name}\" but no weapon is present!");
var groupCount = ActionGameManager.Instance.Settings.GameplaySettings.WeaponGroupCount;
for (int i = 0; i < groupCount; i++)
{
var i1 = i;
bool groupContainsItem() => item.Entity.WeaponGroups[i1].items.Contains(item);
var group = Instantiate(GroupPrefab, Container);
Groups.Add(group);
group.Label.text = $"G{i+1}";
group.Label.color = groupContainsItem() ? ActiveColor : InactiveColor;
group.Button.onClick.AddListener(() =>
{
if (groupContainsItem())
{
item.Entity.WeaponGroups[i1].items.Remove(item);
item.Entity.WeaponGroups[i1].weapons.Remove(weapon);
group.Label.color = InactiveColor;
}
else
{
item.Entity.WeaponGroups[i1].items.Add(item);
item.Entity.WeaponGroups[i1].weapons.Add(weapon);
group.Label.color = ActiveColor;
}
});
group.BeginDragTrigger.OnBeginDragAsObservable()
.Subscribe(data => _onBeginDrag?.OnNext((data, i1)));
group.DragTrigger.OnDragAsObservable()
.Subscribe(data => _onDrag?.OnNext((data, i1)));
group.EndDragTrigger.OnEndDragAsObservable()
.Subscribe(data => _onEndDrag?.OnNext((data, i1)));
}
}
public UniRx.IObservable<(PointerEventData pointerEventData, int group)> OnBeginDragAsObservable() =>
_onBeginDrag ?? (_onBeginDrag = new Subject<(PointerEventData pointerEventData, int group)>());
public UniRx.IObservable<(PointerEventData pointerEventData, int group)> OnDragAsObservable() =>
_onDrag ?? (_onDrag = new Subject<(PointerEventData pointerEventData, int group)>());
public UniRx.IObservable<(PointerEventData pointerEventData, int group)> OnEndDragAsObservable() =>
_onEndDrag ?? (_onEndDrag = new Subject<(PointerEventData pointerEventData, int group)>());
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9b213fc96d20d848819b8159412680c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.UI;
public class WeaponGroupElement : MonoBehaviour
{
public TextMeshProUGUI Label;
public Button Button;
public ObservableBeginDragTrigger BeginDragTrigger;
public ObservableDragTrigger DragTrigger;
public ObservableEndDragTrigger EndDragTrigger;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 27f5673ad060b834489cad765159cb84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: