Integrate CultMesh UI and URP cleanup
This commit is contained in:
parent
932cc9f906
commit
4d7bb65868
131 changed files with 7209 additions and 5084 deletions
|
|
@ -9,6 +9,7 @@ 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;
|
||||
|
|
@ -21,17 +22,14 @@ public class InventoryMenu : MonoBehaviour
|
|||
public ConfirmationDialog Dialog;
|
||||
// public ClickCatcher Background;
|
||||
|
||||
private int2 _selectedPosition;
|
||||
private InventoryPanel _selectedPanel;
|
||||
private ItemInstance _selectedItem;
|
||||
private EquippedItem _selectedEquippedItem;
|
||||
private int2[] _selectedCells;
|
||||
private AetheriaRuntimeCurrentEntityDocument _shipSettingsCurrentEntity;
|
||||
private UIDocument _shipSettingsSurfaceDocument;
|
||||
private UIDocument _cargoItemDetailsSurfaceDocument;
|
||||
private UIDocument _equippedItemDetailsSurfaceDocument;
|
||||
private AetheriaUnityActionBarPresentation _actionBarPresentation;
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
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);
|
||||
|
|
@ -55,10 +53,12 @@ public class InventoryMenu : MonoBehaviour
|
|||
_actionBarPresentation = actionBarPresentation;
|
||||
}
|
||||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
|
||||
{
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
_presentationEntityIndex = presentationEntityIndex;
|
||||
}
|
||||
|
||||
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-inventory-menu");
|
||||
// private int2 _dragCellOffset;
|
||||
// private ItemRotation _originalRotation;
|
||||
// //private Shape _previousFakeOccupancy;
|
||||
|
|
@ -108,74 +108,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
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)
|
||||
{
|
||||
HideCargoItemDetailsSurface();
|
||||
HideEquippedItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
|
||||
RequestCargoItemTransfer(cargoEvent.CargoBay, otherPanel, item);
|
||||
// TODO: SFX: Equip
|
||||
// else
|
||||
// TODO: SFX: Fail
|
||||
}
|
||||
else
|
||||
{
|
||||
HideCurrentShipSettingsSurface();
|
||||
HideCargoItemDetailsSurface();
|
||||
HideEquippedItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
|
||||
_selectedItem = item;
|
||||
_selectedCells = GetSelectedCells(item, _selectedPosition);
|
||||
ApplySelectedCellHighlight();
|
||||
RenderCargoItemDetailsSurface(item);
|
||||
// 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)
|
||||
{
|
||||
HideCargoItemDetailsSurface();
|
||||
HideEquippedItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
|
||||
RequestEquippedItemTransfer(entityEvent.Entity, item, otherPanel);
|
||||
// TODO: SFX: Unequip
|
||||
// else
|
||||
// TODO: SFX: Fail
|
||||
}
|
||||
else
|
||||
{
|
||||
HideCurrentShipSettingsSurface();
|
||||
HideCargoItemDetailsSurface();
|
||||
ClearSelectedItemSelection();
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = item.Position;
|
||||
_selectedItem = item.EquippableItem;
|
||||
_selectedEquippedItem = item;
|
||||
_selectedCells = GetSelectedCells(item.EquippableItem, _selectedPosition);
|
||||
ApplySelectedCellHighlight();
|
||||
RenderEquippedItemDetailsSurface(item);
|
||||
// TODO: SFX: Success
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
panel.OnBackgroundClick.Subscribe(data =>
|
||||
{
|
||||
if (!TryReadCurrentEntity(out var currentEntity)) return;
|
||||
|
|
@ -499,122 +431,9 @@ public class InventoryMenu : MonoBehaviour
|
|||
item.Entity.WeaponGroups[groupIndex].items.Contains(item);
|
||||
}
|
||||
|
||||
private void RequestCargoItemTransfer(EquippedCargoBay origin, InventoryPanel destination, ItemInstance item)
|
||||
{
|
||||
if (destination.DisplayedEntity != null && item is EquippableItem equippableItem)
|
||||
{
|
||||
RequestCargoItemEquip(origin, destination.DisplayedEntity, equippableItem);
|
||||
return;
|
||||
}
|
||||
|
||||
if (destination.DisplayedCargo != null)
|
||||
RequestCargoItemTransfer(origin, destination.DisplayedCargo, item);
|
||||
}
|
||||
|
||||
private void ClearSelectedItemSelection()
|
||||
{
|
||||
ClearSelectedCellHighlight();
|
||||
_selectedPanel = null;
|
||||
_selectedItem = null;
|
||||
_selectedEquippedItem = null;
|
||||
_selectedCells = null;
|
||||
_selectedPosition = default;
|
||||
}
|
||||
|
||||
private void RequestEquippedItemTransfer(Entity origin, EquippedItem item, InventoryPanel destination)
|
||||
{
|
||||
if (destination.DisplayedCargo != null)
|
||||
RequestEquippedItemStore(item, destination.DisplayedCargo);
|
||||
}
|
||||
|
||||
private void RequestCargoItemTransfer(
|
||||
EquippedCargoBay origin,
|
||||
EquippedCargoBay destination,
|
||||
ItemInstance item)
|
||||
{
|
||||
if (!TryResolveCargoBay(origin, out var originEntityKey, out var originCargoIndex) ||
|
||||
!TryResolveCargoBay(destination, out var destinationEntityKey, out var destinationCargoIndex) ||
|
||||
item == null ||
|
||||
string.IsNullOrWhiteSpace(item.ItemKey) ||
|
||||
!origin.Cargo.TryGetValue(item, out var originPosition) ||
|
||||
!TryValidateTypedCargoSlot(originEntityKey, originCargoIndex, item, originPosition, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var quantity = item is SimpleCommodity commodity ? commodity.Quantity : 1;
|
||||
if (quantity <= 0)
|
||||
return;
|
||||
|
||||
TrySubmitOperation(
|
||||
operations => operations.TransferCargoItem(
|
||||
originEntityKey,
|
||||
originCargoIndex,
|
||||
destinationEntityKey,
|
||||
destinationCargoIndex,
|
||||
item.ItemKey,
|
||||
quantity,
|
||||
originPosition.x,
|
||||
originPosition.y,
|
||||
default,
|
||||
default,
|
||||
false),
|
||||
"cargo transfer");
|
||||
}
|
||||
|
||||
private void RequestCargoItemEquip(
|
||||
EquippedCargoBay origin,
|
||||
Entity destination,
|
||||
EquippableItem item)
|
||||
{
|
||||
if (!TryResolveCargoBay(origin, out var originEntityKey, out var originCargoIndex) ||
|
||||
!TryResolveEntityRecordKey(destination, out var destinationEntityKey) ||
|
||||
item == null ||
|
||||
string.IsNullOrWhiteSpace(item.ItemKey) ||
|
||||
!origin.Cargo.TryGetValue(item, out var originPosition) ||
|
||||
!TryValidateTypedCargoSlot(originEntityKey, originCargoIndex, item, originPosition, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrySubmitOperation(
|
||||
operations => operations.EquipItem(
|
||||
"cargo",
|
||||
originEntityKey,
|
||||
originCargoIndex,
|
||||
destinationEntityKey,
|
||||
item.ItemKey,
|
||||
originPosition.x,
|
||||
originPosition.y,
|
||||
default,
|
||||
default,
|
||||
false),
|
||||
"cargo equip");
|
||||
}
|
||||
|
||||
private void RequestEquippedItemStore(
|
||||
EquippedItem item,
|
||||
EquippedCargoBay destination)
|
||||
{
|
||||
if (!TryResolveEquippedItem(item, out var originEntityKey, out var equipmentIndex) ||
|
||||
!TryResolveCargoBay(destination, out var destinationEntityKey, out var destinationCargoIndex) ||
|
||||
item?.EquippableItem == null ||
|
||||
!TryValidateTypedEquipmentSlot(originEntityKey, equipmentIndex, item))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrySubmitOperation(
|
||||
operations => operations.StoreItem(
|
||||
originEntityKey,
|
||||
equipmentIndex,
|
||||
destinationEntityKey,
|
||||
destinationCargoIndex,
|
||||
item.EquippableItem.ItemKey,
|
||||
default,
|
||||
default,
|
||||
false),
|
||||
"equipment store");
|
||||
}
|
||||
|
||||
private void RequestEntityShutdownPerformance(string targetEntityKey, float shutdownPerformance)
|
||||
|
|
@ -678,17 +497,17 @@ public class InventoryMenu : MonoBehaviour
|
|||
"weapon-group membership");
|
||||
}
|
||||
|
||||
private bool TryResolveEntityRecordKey(Entity entity, out string recordKey)
|
||||
private bool TryGetRecordKeyForPresentationEntity(Entity entity, out string recordKey)
|
||||
{
|
||||
recordKey = "";
|
||||
return _observedEntityIndex != null &&
|
||||
_observedEntityIndex.TryResolveEntityRecordKey(entity, out recordKey);
|
||||
return _presentationEntityIndex != null &&
|
||||
_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(entity, out recordKey);
|
||||
}
|
||||
|
||||
private bool IsCurrentEntity(Entity entity)
|
||||
{
|
||||
if (entity == null ||
|
||||
!TryResolveEntityRecordKey(entity, out var entityKey) ||
|
||||
!TryGetRecordKeyForPresentationEntity(entity, out var entityKey) ||
|
||||
string.IsNullOrWhiteSpace(entityKey) ||
|
||||
!TryResolveCurrentEntityKey(out var currentEntityKey))
|
||||
{
|
||||
|
|
@ -732,9 +551,9 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
currentEntity = null;
|
||||
var currentEntityKey = CurrentEntitySnapshot()?.EntityKey ?? "";
|
||||
return _observedEntityIndex != null &&
|
||||
return _presentationEntityIndex != null &&
|
||||
!string.IsNullOrWhiteSpace(currentEntityKey) &&
|
||||
_observedEntityIndex.TryResolveEntityByRecordKey(currentEntityKey, out currentEntity);
|
||||
_presentationEntityIndex.TryGetPresentationEntityByRecordKey(currentEntityKey, out currentEntity);
|
||||
}
|
||||
|
||||
private bool TryResolveCurrentDockingBay(out EquippedDockingBay dockingBay)
|
||||
|
|
@ -744,8 +563,8 @@ public class InventoryMenu : MonoBehaviour
|
|||
if (refit?.IsDocked != true ||
|
||||
refit.DockingBayIndex < 0 ||
|
||||
string.IsNullOrWhiteSpace(refit.DockParentEntityKey) ||
|
||||
_observedEntityIndex == null ||
|
||||
!_observedEntityIndex.TryResolveDockingBayByRecordKey(
|
||||
_presentationEntityIndex == null ||
|
||||
!_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
|
||||
refit.DockParentEntityKey,
|
||||
refit.DockingBayIndex,
|
||||
out dockingBay))
|
||||
|
|
@ -756,18 +575,13 @@ public class InventoryMenu : MonoBehaviour
|
|||
return dockingBay != null;
|
||||
}
|
||||
|
||||
private bool TryResolveCargoBay(EquippedCargoBay cargoBay, out string entityKey, out int cargoIndex)
|
||||
{
|
||||
return TryResolveEquippedItem(cargoBay, out entityKey, out cargoIndex);
|
||||
}
|
||||
|
||||
private bool TryResolveEquippedItem(EquippedItem item, out string entityKey, out int equipmentIndex)
|
||||
{
|
||||
entityKey = "";
|
||||
equipmentIndex = -1;
|
||||
var entity = item?.Entity;
|
||||
if (entity?.Equipment == null ||
|
||||
!TryResolveEntityRecordKey(entity, out entityKey))
|
||||
!TryGetRecordKeyForPresentationEntity(entity, out entityKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -776,97 +590,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
return equipmentIndex >= 0;
|
||||
}
|
||||
|
||||
private bool TryResolveTypedInventoryRows(
|
||||
string entityKey,
|
||||
out IReadOnlyList<AetheriaRuntimeRtsInventoryItem> equipment,
|
||||
out IReadOnlyList<AetheriaRuntimeRtsInventoryItem> cargo)
|
||||
{
|
||||
equipment = Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
cargo = Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
if (string.IsNullOrWhiteSpace(entityKey))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var current = CurrentEntitySnapshot();
|
||||
if (current != null && string.Equals(current.EntityKey, entityKey, StringComparison.Ordinal))
|
||||
{
|
||||
equipment = current.Equipment ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
cargo = current.Cargo ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
return true;
|
||||
}
|
||||
|
||||
var refit = StationRefitSnapshot();
|
||||
var entityIndex = -1;
|
||||
if (refit != null)
|
||||
{
|
||||
if (string.Equals(refit.DockParentEntityKey, entityKey, StringComparison.Ordinal))
|
||||
entityIndex = refit.DockParentEntityIndex;
|
||||
else
|
||||
entityIndex = (refit.AvailableEntities ?? Array.Empty<AetheriaRuntimeStationRefitEntityOption>())
|
||||
.FirstOrDefault(option => string.Equals(option.EntityKey, entityKey, StringComparison.Ordinal))
|
||||
?.EntityIndex ?? -1;
|
||||
}
|
||||
|
||||
if (entityIndex < 0)
|
||||
return false;
|
||||
|
||||
var inventory = InventorySnapshot(entityIndex);
|
||||
if (inventory == null || !string.Equals(inventory.EntityKey, entityKey, StringComparison.Ordinal))
|
||||
return false;
|
||||
|
||||
equipment = inventory.Equipment ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
cargo = inventory.Cargo ?? Array.Empty<AetheriaRuntimeRtsInventoryItem>();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to validate Aetheria typed inventory document for {entityKey}: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryValidateTypedCargoSlot(
|
||||
string entityKey,
|
||||
int cargoIndex,
|
||||
ItemInstance item,
|
||||
int2 originPosition,
|
||||
bool hasOriginPosition)
|
||||
{
|
||||
if (item == null ||
|
||||
string.IsNullOrWhiteSpace(item.ItemKey) ||
|
||||
!TryResolveTypedInventoryRows(entityKey, out _, out var cargo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return cargo.Any(row =>
|
||||
string.Equals(row.Source, "cargo", StringComparison.Ordinal) &&
|
||||
row.SourceIndex == cargoIndex &&
|
||||
string.Equals(row.ItemKey, item.ItemKey, StringComparison.Ordinal) &&
|
||||
(!hasOriginPosition || (row.X == originPosition.x && row.Y == originPosition.y)));
|
||||
}
|
||||
|
||||
private bool TryValidateTypedEquipmentSlot(
|
||||
string entityKey,
|
||||
int equipmentIndex,
|
||||
EquippedItem item)
|
||||
{
|
||||
if (item?.EquippableItem == null ||
|
||||
string.IsNullOrWhiteSpace(item.EquippableItem.ItemKey) ||
|
||||
!TryResolveTypedInventoryRows(entityKey, out var equipment, out _))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return equipment.Any(row =>
|
||||
string.Equals(row.Source, "equipment", StringComparison.Ordinal) &&
|
||||
row.SourceIndex == equipmentIndex &&
|
||||
row.X == item.Position.x &&
|
||||
row.Y == item.Position.y &&
|
||||
string.Equals(row.ItemKey, item.EquippableItem.ItemKey, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private bool TrySubmitOperation(
|
||||
Action<AetheriaControl> submit,
|
||||
string label)
|
||||
|
|
@ -890,7 +613,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentEntityState("unity-inventory-menu");
|
||||
return RuntimeState.CurrentEntity.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -903,7 +626,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentStationRefit("unity-inventory-menu");
|
||||
return RuntimeState.StationRefit.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -912,19 +635,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private AetheriaRuntimeInventoryDocument InventorySnapshot(int entityIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentInventory(entityIndex, "unity-inventory-menu");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria typed inventory document for entity {entityIndex}: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// if (Keyboard.current.qKey.wasPressedThisFrame && _dragItem != null)
|
||||
|
|
@ -937,41 +647,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
// }
|
||||
}
|
||||
|
||||
private void ClearSelectedCellHighlight()
|
||||
{
|
||||
if (_selectedPanel == null || _selectedCells == null) return;
|
||||
|
||||
foreach (var v in _selectedCells)
|
||||
{
|
||||
if (_selectedPanel.CellInstances.ContainsKey(v))
|
||||
_selectedPanel.CellInstances[v].Icon.color = _selectedPanel.GetColor(v);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplySelectedCellHighlight()
|
||||
{
|
||||
if (_selectedPanel == null || _selectedCells == null) return;
|
||||
|
||||
foreach (var v in _selectedCells)
|
||||
{
|
||||
if (_selectedPanel.CellInstances.ContainsKey(v))
|
||||
_selectedPanel.CellInstances[v].Icon.color = _selectedPanel.GetColor(v, true);
|
||||
}
|
||||
}
|
||||
|
||||
private int2[] GetSelectedCells(ItemInstance item, int2 position)
|
||||
{
|
||||
var typedItem = FindTypedInventoryItem(item);
|
||||
if (typedItem != null && typedItem.ShapeCells.Count > 0)
|
||||
{
|
||||
return typedItem.ShapeCells
|
||||
.Select(cell => RotateTypedShapeCell(cell, typedItem, item.Rotation) + position)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return Array.Empty<int2>();
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogItem FindTypedInventoryItem(ItemInstance item)
|
||||
{
|
||||
return CatalogSnapshot()?.FindItem(item, x => x.ItemKey);
|
||||
|
|
@ -981,7 +656,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-inventory-menu");
|
||||
return RuntimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -994,7 +669,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-inventory-menu");
|
||||
return RuntimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1042,20 +717,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
return $"{FormatValue(value - 273.15f)} C";
|
||||
}
|
||||
|
||||
private static int2 RotateTypedShapeCell(
|
||||
AetheriaRuntimeShapeCell cell,
|
||||
AetheriaRuntimeCatalogItem item,
|
||||
ItemRotation rotation)
|
||||
{
|
||||
return rotation switch
|
||||
{
|
||||
ItemRotation.Clockwise => new int2(cell.Y, item.ShapeWidth - 1 - cell.X),
|
||||
ItemRotation.Reversed => new int2(item.ShapeWidth - 1 - cell.X, item.ShapeHeight - 1 - cell.Y),
|
||||
ItemRotation.CounterClockwise => new int2(item.ShapeHeight - 1 - cell.Y, cell.X),
|
||||
_ => new int2(cell.X, cell.Y)
|
||||
};
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_shipSettingsSurfaceDocument != null)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -5,6 +5,7 @@ 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;
|
||||
|
|
@ -20,16 +21,17 @@ public class LocalMenu : MonoBehaviour
|
|||
public ChoicePrefab ChoicePrefab;
|
||||
|
||||
private string _currentPath;
|
||||
private LocationStory _currentLocation;
|
||||
private LocationStory _currentLocalInkLocation;
|
||||
private Story _activeStory;
|
||||
private readonly List<ActiveStoryChoice> _activeChoices = new List<ActiveStoryChoice>();
|
||||
private UIDocument _surfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _surfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
|
||||
private AetheriaClientState _runtimeState;
|
||||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
public void SetPresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
|
||||
{
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
_presentationEntityIndex = presentationEntityIndex;
|
||||
}
|
||||
|
||||
private sealed class ActiveStoryChoice
|
||||
|
|
@ -48,13 +50,13 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!TryResolveDockedLocalStory(out _currentLocation))
|
||||
if (!TryResolveDockedLocalInkStory(out _currentLocalInkLocation))
|
||||
{
|
||||
HideStorySurface();
|
||||
return;
|
||||
}
|
||||
|
||||
_activeStory = _currentLocation.Story;
|
||||
_activeStory = _currentLocalInkLocation.Story;
|
||||
Continue();
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +86,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 == _currentLocation.Story)
|
||||
if (_activeStory == _currentLocalInkLocation.Story)
|
||||
{
|
||||
// END inside location-based story thread, restart the story
|
||||
_activeStory.ResetState();
|
||||
|
|
@ -93,7 +95,7 @@ public class LocalMenu : MonoBehaviour
|
|||
else
|
||||
{
|
||||
// END inside quest content, switch back to location thread and present choices
|
||||
_activeStory = _currentLocation.Story;
|
||||
_activeStory = _currentLocalInkLocation.Story;
|
||||
Continue();
|
||||
}
|
||||
}
|
||||
|
|
@ -103,10 +105,10 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
void PresentCurrentChoices()
|
||||
{
|
||||
Debug.Log($"Current Path: \"{_currentPath}\" in {(_activeStory == _currentLocation.Story ? "Location Story" : "Quest Story")}");
|
||||
if(!string.IsNullOrEmpty(_currentPath) && _currentLocation.KnotQuests.ContainsKey(_currentPath))
|
||||
Debug.Log($"Current Path: \"{_currentPath}\" in {(_activeStory == _currentLocalInkLocation.Story ? "Location Story" : "Quest Story")}");
|
||||
if(!string.IsNullOrEmpty(_currentPath) && _currentLocalInkLocation.KnotQuests.ContainsKey(_currentPath))
|
||||
{
|
||||
foreach (var quest in _currentLocation.KnotQuests[_currentPath])
|
||||
foreach (var quest in _currentLocalInkLocation.KnotQuests[_currentPath])
|
||||
{
|
||||
if (quest.Story == _activeStory) continue; // Don't repeat choices for active injected branch
|
||||
|
||||
|
|
@ -188,23 +190,26 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private string ResolveLocationLabel()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocation?.Name))
|
||||
return _currentLocation.Name;
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocation?.FileName))
|
||||
return _currentLocation.FileName;
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocalInkLocation?.Name))
|
||||
return _currentLocalInkLocation.Name;
|
||||
if (!string.IsNullOrWhiteSpace(_currentLocalInkLocation?.FileName))
|
||||
return _currentLocalInkLocation.FileName;
|
||||
return "Local";
|
||||
}
|
||||
|
||||
private bool TryResolveDockedLocalStory(out LocationStory story)
|
||||
private bool TryResolveDockedLocalInkStory(out LocationStory story)
|
||||
{
|
||||
story = null;
|
||||
var docking = CurrentDockingSnapshot();
|
||||
if (_observedEntityIndex == null ||
|
||||
// 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 ||
|
||||
!_observedEntityIndex.TryResolveDockingBayByRecordKey(
|
||||
!_presentationEntityIndex.TryGetPresentationDockingBayByRecordKey(
|
||||
docking.DockParentEntityKey,
|
||||
docking.DockingBayIndex,
|
||||
out var dockingBay) ||
|
||||
|
|
@ -217,11 +222,12 @@ public class LocalMenu : MonoBehaviour
|
|||
return true;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
|
||||
private AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-local-menu");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-local-menu");
|
||||
return _runtimeState.CurrentDocking.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ 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;
|
||||
|
|
@ -33,6 +34,7 @@ public class MapRenderer : MonoBehaviour
|
|||
public RawImage RtsIconPrototype;
|
||||
public float Scale;
|
||||
public float2 Position;
|
||||
private AetheriaClientState _runtimeState;
|
||||
public float IconSize = 1f/128;
|
||||
|
||||
private RectTransform _rect;
|
||||
|
|
@ -307,9 +309,8 @@ public class MapRenderer : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings("unity-map-renderer")
|
||||
?.ShowAsteroidsInMinimap ?? false;
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-map-renderer");
|
||||
return _runtimeState.PlayerSettings.Latest()?.ShowAsteroidsInMinimap ?? false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ public class MenuPanel : MonoBehaviour
|
|||
private MenuTabBinding _current;
|
||||
private UIDocument _tabSurfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _tabSurfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaClientState _runtimeState;
|
||||
|
||||
public MenuTab CurrentTab { get; private set; }
|
||||
|
||||
|
|
@ -157,12 +159,13 @@ public class MenuPanel : MonoBehaviour
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static bool TryResolveCurrentDocking(out AetheriaRuntimeCurrentDockingDocument docking)
|
||||
private bool TryResolveCurrentDocking(out AetheriaRuntimeCurrentDockingDocument docking)
|
||||
{
|
||||
docking = null;
|
||||
try
|
||||
{
|
||||
docking = AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-runtime-menu-tabs");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-runtime-menu-tabs");
|
||||
docking = _runtimeState.CurrentDocking.Latest();
|
||||
return docking != null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
|
@ -33,6 +34,7 @@ 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;
|
||||
|
|
@ -219,8 +221,8 @@ public class SectorMap : MonoBehaviour
|
|||
|
||||
private void EnsureSectorMapLoaded()
|
||||
{
|
||||
_sectorMap = AetheriaUnityRuntimeClientProvider
|
||||
.CurrentSectorMap("unity-sector-map");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-sector-map");
|
||||
_sectorMap = _runtimeState.SectorMap.Latest();
|
||||
|
||||
if (_sectorMapLoaded)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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 UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
|
@ -45,6 +44,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
private float _sectorBackgroundDepth;
|
||||
private float _sectorCameraDepth;
|
||||
private UIDocument _zoneDetailsSurfaceDocument;
|
||||
private AetheriaClientState _runtimeState;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _zoneDetailsSurfaceChrome = new AetheriaEveUnitySurfaceChrome
|
||||
{
|
||||
RootAlignItems = Align.FlexEnd,
|
||||
|
|
@ -61,6 +61,8 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
|
||||
private float2 _position = float2(0.5f);
|
||||
private float _viewSize = .5f;
|
||||
|
||||
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-sector-renderer");
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
|
@ -86,32 +88,15 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
|
||||
private void RenderZoneDetailsSurface(int zoneIndex)
|
||||
{
|
||||
var sectorZone = ResolveSectorZone(zoneIndex);
|
||||
var zoneDetails = ResolveZoneDetails(zoneIndex);
|
||||
var ownerFactionIndex = sectorZone?.OwnerFactionIndex ?? -1;
|
||||
var otherFactions = (sectorZone?.FactionIndices ?? Array.Empty<int>())
|
||||
.Where(index => index >= 0 && index != ownerFactionIndex)
|
||||
.Distinct()
|
||||
.Select(FormatFaction)
|
||||
.ToArray();
|
||||
var zoneFacts = AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(
|
||||
zoneDetails,
|
||||
ResolveHullType);
|
||||
var surface = ResolveZoneDetailsSurface(zoneIndex);
|
||||
if (surface == null)
|
||||
return;
|
||||
|
||||
_zoneDetailsSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
transform,
|
||||
_zoneDetailsSurfaceDocument,
|
||||
"Aetheria Sector Zone Details Surface",
|
||||
AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(
|
||||
ResolveZoneName(sectorZone, zoneDetails),
|
||||
ownerFactionIndex >= 0 ? FormatFaction(ownerFactionIndex) : "None",
|
||||
FormatValue((float)zoneFacts.Mass),
|
||||
FormatValue((float)zoneFacts.Radius),
|
||||
otherFactions,
|
||||
zoneFacts.Bodies,
|
||||
zoneFacts.Entities,
|
||||
zoneFacts.HasContents,
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
surface,
|
||||
HandleZoneDetailsSurfaceCommand,
|
||||
_zoneDetailsSurfaceChrome);
|
||||
}
|
||||
|
|
@ -141,105 +126,22 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument);
|
||||
}
|
||||
|
||||
private string ResolveZoneName(
|
||||
AetheriaRuntimeSectorMapZone sectorZone,
|
||||
AetheriaRuntimeZoneDetailsDocument zoneDetails)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(zoneDetails?.ZoneName))
|
||||
return zoneDetails.ZoneName;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sectorZone?.Name))
|
||||
return sectorZone.Name;
|
||||
|
||||
return sectorZone == null ? "Unknown" : $"Zone {sectorZone.ZoneIndex}";
|
||||
}
|
||||
|
||||
private AetheriaRuntimeSectorMapZone ResolveSectorZone(int zoneIndex)
|
||||
private AetheriaRuntimeSurfaceDocument ResolveZoneDetailsSurface(int zoneIndex)
|
||||
{
|
||||
if (zoneIndex < 0)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
var sectorMap = AetheriaUnityRuntimeClientProvider.CurrentSectorMap("unity-sector-renderer");
|
||||
return (sectorMap?.Zones ?? Array.Empty<AetheriaRuntimeSectorMapZone>())
|
||||
.FirstOrDefault(zone => zone.ZoneIndex == zoneIndex);
|
||||
return RuntimeState.ZoneDetailsSurface(zoneIndex).Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector map zone from local Verse state: {ex.Message}");
|
||||
Debug.LogWarning($"Failed to read Aetheria sector zone details surface from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatFaction(int factionIndex)
|
||||
{
|
||||
return factionIndex < 0 ? "None" : $"Faction {factionIndex}";
|
||||
}
|
||||
|
||||
private AetheriaRuntimeZoneDetailsDocument ResolveZoneDetails(int zoneIndex)
|
||||
{
|
||||
if (zoneIndex < 0)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentZoneDetails(zoneIndex, "unity-sector-renderer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector zone details from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private string ResolveHullType(string hullItemKey)
|
||||
{
|
||||
var typedHull = ResolveCatalog()?.FindItem(hullItemKey ?? "");
|
||||
return typedHull?.HullType ?? "";
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-sector-renderer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector catalog from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private AetheriaRuntimePlayerSettingsDocument ResolvePlayerSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-sector-renderer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria sector player settings from local Verse state: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private string FormatValue(float value)
|
||||
{
|
||||
var digits = ResolvePlayerSettings()?.SignificantDigits ?? 3;
|
||||
var magnitude = value == 0f ? 0 : (int)Math.Floor(Math.Log10(Math.Abs(value))) + 1;
|
||||
digits -= magnitude;
|
||||
if (digits < 0)
|
||||
digits = 0;
|
||||
|
||||
var formatted = value.ToString($"N{digits}");
|
||||
var decimalSeparator = Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
|
||||
return formatted.Contains(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)
|
||||
? formatted.TrimEnd('0').TrimEnd(decimalSeparator)
|
||||
: formatted;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_init = true;
|
||||
|
|
@ -259,7 +161,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentZoneState("unity-sector-renderer");
|
||||
return RuntimeState.CurrentZone.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -299,7 +201,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
|
|||
{
|
||||
_outputTexture.Release();
|
||||
}
|
||||
_outputTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
|
||||
_outputTexture = new RenderTexture(_size.x, _size.y, 16, RenderTextureFormat.Default);
|
||||
SectorCamera.targetTexture = _outputTexture;
|
||||
_outputImage.material.SetTexture("_DetailTex", _outputTexture);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -28,6 +29,7 @@ public class TradeMenu : MonoBehaviour
|
|||
private string _targetCargoEntityKey = "";
|
||||
private int _targetCargoIndex = -1;
|
||||
private string _targetCargoLabel = "Docking Bay";
|
||||
private AetheriaClientState _runtimeState;
|
||||
private (ItemFilter filter, HardpointType type) _hardpointFilter;
|
||||
private (ItemFilter filter, SimpleCommodityCategory type) _commodityFilter;
|
||||
private (ItemFilter filter, CompoundCommodityCategory type) _compoundCommodityFilter;
|
||||
|
|
@ -46,6 +48,8 @@ public class TradeMenu : MonoBehaviour
|
|||
private AetheriaRuntimeTradeFilterSurfaceModel _filterSurfaceModel;
|
||||
private Action[] _rowActionCallbacks = Array.Empty<Action>();
|
||||
private AetheriaRuntimeTradeRowActionSurfaceModel _rowActionSurfaceModel;
|
||||
|
||||
private AetheriaClientState RuntimeState => _runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-trade");
|
||||
|
||||
public EquippedCargoBay Inventory { get; set; }
|
||||
|
||||
|
|
@ -504,7 +508,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentStationRefit("unity-trade");
|
||||
return RuntimeState.StationRefit.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -518,7 +522,7 @@ public class TradeMenu : MonoBehaviour
|
|||
docking = null;
|
||||
try
|
||||
{
|
||||
docking = AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-trade");
|
||||
docking = RuntimeState.CurrentDocking.Latest();
|
||||
return docking != null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -577,7 +581,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-trade");
|
||||
return RuntimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -590,7 +594,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-trade");
|
||||
return RuntimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue