Integrate CultMesh UI and URP cleanup
This commit is contained in:
parent
932cc9f906
commit
4d7bb65868
131 changed files with 7209 additions and 5084 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
|
|
@ -52,6 +53,7 @@ public class ActionBarSlot : MonoBehaviour
|
|||
|
||||
public abstract class ActionBarBinding
|
||||
{
|
||||
private static AetheriaClientState s_runtimeState;
|
||||
public Entity Entity { get; }
|
||||
private readonly Func<AetheriaControl> _resolveControl;
|
||||
protected ActionBarSlot Slot { get; }
|
||||
|
|
@ -97,9 +99,8 @@ public abstract class ActionBarBinding
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentCatalog()
|
||||
.FindItem(item, x => x.ItemKey);
|
||||
s_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-action-bar");
|
||||
return s_runtimeState.Catalog.Latest()?.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@
|
|||
using System;
|
||||
using Cinemachine;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
|
@ -29,13 +30,17 @@ public class ActionGameManager : MonoBehaviour
|
|||
private AetheriaUnityGameplayLoopShell _gameplayLoopShell;
|
||||
private AetheriaUnityGameplayBootShell _gameplayBootShell;
|
||||
private AetheriaUnityGameplaySceneWiring _sceneWiring;
|
||||
private AetheriaClientState _gameplayState;
|
||||
private AetheriaClientState GameplayState =>
|
||||
_gameplayState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-action-game-manager");
|
||||
|
||||
private AetheriaUnityPilotCommandSender PilotCommands =>
|
||||
_pilotCommands ??= new AetheriaUnityPilotCommandSender(
|
||||
() => AetheriaUnityRuntimeClientProvider.Control("unity-pilot-commands"),
|
||||
() => Time.unscaledTime);
|
||||
private AetheriaUnityObservedEntityRestorer ObservedEntityRestorer =>
|
||||
_observedEntityRestorer ??= new AetheriaUnityObservedEntityRestorer(
|
||||
_observedEntityIndex,
|
||||
_presentationEntityIndex,
|
||||
ItemManager,
|
||||
EntityBlueprintMaterializer.MaterializeObservedEntity,
|
||||
_loadoutItemFactory.CreateLoadoutItem,
|
||||
|
|
@ -81,16 +86,16 @@ public class ActionGameManager : MonoBehaviour
|
|||
private AetheriaUnityPilotOperationController PilotOperationController =>
|
||||
_pilotOperationController ??= new AetheriaUnityPilotOperationController(
|
||||
() => PilotCommands,
|
||||
_observedEntityIndex,
|
||||
_presentationEntityIndex,
|
||||
() => _viewDirection,
|
||||
() => CurrentEntity);
|
||||
private AetheriaUnityObservedFrameApplier ObservedFrameApplier =>
|
||||
_observedFrameApplier ??= new AetheriaUnityObservedFrameApplier(
|
||||
ResolveDaemonObserver,
|
||||
ResolveObservedGalaxyZone,
|
||||
ObservedZoneContextFactory.ResolveGalaxyZone,
|
||||
() => Zone,
|
||||
zone => Zone = zone,
|
||||
_observedEntityIndex,
|
||||
_presentationEntityIndex,
|
||||
ObservedEntityRestorer,
|
||||
ObservedZoneContextFactory,
|
||||
() => ZoneRenderer,
|
||||
|
|
@ -200,7 +205,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
TargetShieldsFill = TargetShieldsFill,
|
||||
MainMenu = MainMenu
|
||||
};
|
||||
private readonly AetheriaUnityObservedEntityIndex _observedEntityIndex = new AetheriaUnityObservedEntityIndex();
|
||||
private readonly AetheriaUnityPresentationEntityIndex _presentationEntityIndex = new AetheriaUnityPresentationEntityIndex();
|
||||
private static RuntimePlayerSettings RuntimePlayerSettings
|
||||
=> AetheriaUnityRuntimeClientProvider.PlayerSettings;
|
||||
|
||||
|
|
@ -211,9 +216,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
public float TargetSpottedBlinkOffset = -.25f;
|
||||
|
||||
[Header("Postprocessing")]
|
||||
public PostProcessVolume DeathPost;
|
||||
public PostProcessVolume HeatstrokePost;
|
||||
public PostProcessVolume SevereHeatstrokePost;
|
||||
public Volume DeathPost;
|
||||
public Volume HeatstrokePost;
|
||||
public Volume SevereHeatstrokePost;
|
||||
|
||||
[Header("Scene Links")]
|
||||
public GameObject UiRoot;
|
||||
|
|
@ -303,7 +308,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
SceneWiring.ConfigureTargetPresentation(
|
||||
_targetPresentation,
|
||||
boot.RuntimeCatalog,
|
||||
_observedEntityIndex);
|
||||
_presentationEntityIndex);
|
||||
SceneWiring.ConfigureInventoryDragSession(_dragSession);
|
||||
SceneWiring.ConfigureActionBarPresentation(
|
||||
_actionBarPresentation,
|
||||
|
|
@ -313,7 +318,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
() => CurrentEntity,
|
||||
() => AetheriaUnityRuntimeClientProvider.Control("unity-action-bar"));
|
||||
SceneWiring.ConfigureRuntimeInputScreenShell(MenuShell);
|
||||
SceneWiring.ConfigureObservedEntityIndex(_observedEntityIndex);
|
||||
SceneWiring.ConfigurePresentationEntityIndex(_presentationEntityIndex);
|
||||
|
||||
// TODO: Process Stories
|
||||
|
||||
|
|
@ -347,7 +352,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
return false;
|
||||
}
|
||||
|
||||
if (_observedEntityIndex.TryResolveEntityRecordKey(CurrentEntity, out var currentEntityKey) &&
|
||||
if (_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(CurrentEntity, out var currentEntityKey) &&
|
||||
!string.IsNullOrWhiteSpace(docking.CurrentEntityKey) &&
|
||||
!string.Equals(docking.CurrentEntityKey, currentEntityKey, StringComparison.Ordinal))
|
||||
{
|
||||
|
|
@ -369,23 +374,23 @@ public class ActionGameManager : MonoBehaviour
|
|||
return null;
|
||||
}
|
||||
|
||||
if (_observedEntityIndex.TryResolveEntityRecordKey(currentEntity, out var currentEntityKey) &&
|
||||
if (_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(currentEntity, out var currentEntityKey) &&
|
||||
!string.IsNullOrWhiteSpace(docking.CurrentEntityKey) &&
|
||||
!string.Equals(docking.CurrentEntityKey, currentEntityKey, StringComparison.Ordinal))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _observedEntityIndex.TryResolveEntityByRecordKey(docking.DockParentEntityKey, out var dockParent)
|
||||
return _presentationEntityIndex.TryGetPresentationEntityByRecordKey(docking.DockParentEntityKey, out var dockParent)
|
||||
? dockParent
|
||||
: null;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
|
||||
private AetheriaRuntimeCurrentDockingDocument CurrentDockingSnapshot()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentDockingState("unity-action-game-manager");
|
||||
return GameplayState.CurrentDocking.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -394,20 +399,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private GalaxyZone ResolveObservedGalaxyZone(int daemonZoneIndex)
|
||||
{
|
||||
if (daemonZoneIndex < 0 || ObservedGalaxy?.Zones == null)
|
||||
return null;
|
||||
|
||||
foreach (var zone in ObservedGalaxy.Zones)
|
||||
{
|
||||
if (zone != null && zone.ZoneIndex == daemonZoneIndex)
|
||||
return zone;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// public void ToggleEditMode()
|
||||
// {
|
||||
// _editMode = !_editMode;
|
||||
|
|
|
|||
271
Assets/Scripts/Gameplay/AetheriaSceneRenderSplatSource.cs
Normal file
271
Assets/Scripts/Gameplay/AetheriaSceneRenderSplatSource.cs
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string documentName = "Scene Mock";
|
||||
|
||||
[SerializeField]
|
||||
private AetheriaSceneRenderSplat[] splats =
|
||||
{
|
||||
AetheriaSceneRenderSplat.Animated(
|
||||
AetheriaRuntimeRenderSplatLayerKeys.FogSurfaceHeight,
|
||||
"scene.fog_surface",
|
||||
Vector2.zero,
|
||||
new Vector2(512, 512),
|
||||
Color.white,
|
||||
4,
|
||||
4,
|
||||
0.015f),
|
||||
AetheriaSceneRenderSplat.Animated(
|
||||
AetheriaRuntimeRenderSplatLayerKeys.FogPatchHeight,
|
||||
"scene.fog_patch_height",
|
||||
Vector2.zero,
|
||||
new Vector2(512, 512),
|
||||
Color.white,
|
||||
9,
|
||||
9,
|
||||
0.02f),
|
||||
AetheriaSceneRenderSplat.Animated(
|
||||
AetheriaRuntimeRenderSplatLayerKeys.FogPatch,
|
||||
"scene.fog_patch",
|
||||
Vector2.zero,
|
||||
new Vector2(512, 512),
|
||||
Color.white,
|
||||
6,
|
||||
6,
|
||||
0.01f)
|
||||
};
|
||||
|
||||
[SerializeField]
|
||||
private AetheriaSceneRenderSplatFixture[] fixtures = Array.Empty<AetheriaSceneRenderSplatFixture>();
|
||||
|
||||
public AetheriaRuntimeRenderSplatsViewportDocument BuildDocument(AetheriaRuntimeRtsViewportBounds viewport)
|
||||
{
|
||||
viewport ??= new AetheriaRuntimeRtsViewportBounds();
|
||||
var normalizedViewport = Normalize(viewport);
|
||||
var layers = BuildLayers();
|
||||
var layerIndices = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
for (var index = 0; index < layers.Length; index++)
|
||||
layerIndices[layers[index].LayerKey] = index;
|
||||
|
||||
var builder = new Builder();
|
||||
foreach (var splat in splats ?? Array.Empty<AetheriaSceneRenderSplat>())
|
||||
splat.AddTo(builder, layerIndices);
|
||||
foreach (var fixture in fixtures ?? Array.Empty<AetheriaSceneRenderSplatFixture>())
|
||||
fixture.AddTo(builder, layerIndices);
|
||||
|
||||
return new AetheriaRuntimeRenderSplatsViewportDocument
|
||||
{
|
||||
PublishedAtUtc = DateTimeOffset.UtcNow.ToString("O"),
|
||||
SimulationTimeSeconds = Application.isPlaying ? Time.timeAsDouble : 0,
|
||||
RunId = "scene",
|
||||
ZoneName = string.IsNullOrWhiteSpace(documentName) ? gameObject.scene.name : documentName,
|
||||
Viewport = normalizedViewport,
|
||||
Layers = layers,
|
||||
Splats = builder.Build()
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRtsViewportBounds Normalize(AetheriaRuntimeRtsViewportBounds viewport)
|
||||
{
|
||||
return new AetheriaRuntimeRtsViewportBounds
|
||||
{
|
||||
MinX = Math.Min(viewport.MinX, viewport.MaxX),
|
||||
MinY = Math.Min(viewport.MinY, viewport.MaxY),
|
||||
MaxX = Math.Max(viewport.MinX, viewport.MaxX),
|
||||
MaxY = Math.Max(viewport.MinY, viewport.MaxY)
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRenderSplatLayerDefinition[] BuildLayers()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.GravityHeight, "Gravity Height", AetheriaRuntimeRenderSplatChannels.Gravity),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.GravityWave, "Gravity Wave", AetheriaRuntimeRenderSplatChannels.GravityWave),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.Visibility, "Visibility Mask", AetheriaRuntimeRenderSplatChannels.Visibility, AetheriaRuntimeRenderSplatBlendModes.Max),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.FogSurfaceHeight, "Fog Surface Height", AetheriaRuntimeRenderSplatChannels.Tint),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.FogPatchHeight, "Fog Patch Height", AetheriaRuntimeRenderSplatChannels.Tint),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.FogPatch, "Fog Patch", AetheriaRuntimeRenderSplatChannels.Tint, AetheriaRuntimeRenderSplatBlendModes.Max),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.FogTint, "Fog Tint", AetheriaRuntimeRenderSplatChannels.Tint, graphicsFormat: "B10G11R11_UFloatPack32"),
|
||||
Layer(AetheriaRuntimeRenderSplatLayerKeys.Influence, "Influence", AetheriaRuntimeRenderSplatChannels.Influence)
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRenderSplatLayerDefinition Layer(
|
||||
string key,
|
||||
string displayName,
|
||||
int channel,
|
||||
string blendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
|
||||
string graphicsFormat = "R16_SFloat")
|
||||
{
|
||||
return new AetheriaRuntimeRenderSplatLayerDefinition
|
||||
{
|
||||
LayerKey = key,
|
||||
DisplayName = displayName,
|
||||
Channel = channel,
|
||||
BlendMode = blendMode,
|
||||
GraphicsFormat = graphicsFormat
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class Builder
|
||||
{
|
||||
private readonly List<double> _centerX = new List<double>();
|
||||
private readonly List<double> _centerY = new List<double>();
|
||||
private readonly List<double> _halfExtentX = new List<double>();
|
||||
private readonly List<double> _halfExtentY = new List<double>();
|
||||
private readonly List<double> _rotationCos = new List<double>();
|
||||
private readonly List<double> _rotationSin = new List<double>();
|
||||
private readonly List<int> _channel = new List<int>();
|
||||
private readonly List<int> _falloff = new List<int>();
|
||||
private readonly List<double> _valueR = new List<double>();
|
||||
private readonly List<double> _valueG = new List<double>();
|
||||
private readonly List<double> _valueB = new List<double>();
|
||||
private readonly List<double> _valueA = new List<double>();
|
||||
private readonly List<string> _sourceKey = new List<string>();
|
||||
private readonly List<int> _layerIndex = new List<int>();
|
||||
private readonly List<int> _sourceKind = new List<int>();
|
||||
private readonly List<double> _frequencyX = new List<double>();
|
||||
private readonly List<double> _frequencyY = new List<double>();
|
||||
private readonly List<double> _phaseX = new List<double>();
|
||||
private readonly List<double> _phaseY = new List<double>();
|
||||
private readonly List<double> _animationSpeed = new List<double>();
|
||||
private readonly List<double> _sourceFlags = new List<double>();
|
||||
|
||||
public void Add(AetheriaSceneRenderSplat splat, int layerIndex)
|
||||
{
|
||||
var rotationRadians = splat.RotationDegrees * Mathf.Deg2Rad;
|
||||
_layerIndex.Add(layerIndex);
|
||||
_centerX.Add(splat.Center.x);
|
||||
_centerY.Add(splat.Center.y);
|
||||
_halfExtentX.Add(Math.Max(0, splat.HalfExtent.x));
|
||||
_halfExtentY.Add(Math.Max(0, splat.HalfExtent.y));
|
||||
_rotationCos.Add(Math.Cos(rotationRadians));
|
||||
_rotationSin.Add(Math.Sin(rotationRadians));
|
||||
_channel.Add(splat.Channel);
|
||||
_falloff.Add(splat.Falloff);
|
||||
_valueR.Add(splat.Value.r);
|
||||
_valueG.Add(splat.Value.g);
|
||||
_valueB.Add(splat.Value.b);
|
||||
_valueA.Add(splat.Value.a);
|
||||
_sourceKey.Add(splat.SourceKey ?? "");
|
||||
_sourceKind.Add(splat.SourceKind);
|
||||
_frequencyX.Add(splat.Frequency.x);
|
||||
_frequencyY.Add(splat.Frequency.y);
|
||||
_phaseX.Add(splat.Phase.x);
|
||||
_phaseY.Add(splat.Phase.y);
|
||||
_animationSpeed.Add(splat.AnimationSpeed);
|
||||
_sourceFlags.Add(splat.SourceFlags);
|
||||
}
|
||||
|
||||
public AetheriaRuntimeRenderSplatSoa Build()
|
||||
{
|
||||
return new AetheriaRuntimeRenderSplatSoa
|
||||
{
|
||||
Count = _centerX.Count,
|
||||
CenterX = _centerX.ToArray(),
|
||||
CenterY = _centerY.ToArray(),
|
||||
HalfExtentX = _halfExtentX.ToArray(),
|
||||
HalfExtentY = _halfExtentY.ToArray(),
|
||||
RotationCos = _rotationCos.ToArray(),
|
||||
RotationSin = _rotationSin.ToArray(),
|
||||
Channel = _channel.ToArray(),
|
||||
Falloff = _falloff.ToArray(),
|
||||
ValueR = _valueR.ToArray(),
|
||||
ValueG = _valueG.ToArray(),
|
||||
ValueB = _valueB.ToArray(),
|
||||
ValueA = _valueA.ToArray(),
|
||||
SourceKey = _sourceKey.ToArray(),
|
||||
LayerIndex = _layerIndex.ToArray(),
|
||||
SourceKind = _sourceKind.ToArray(),
|
||||
FrequencyX = _frequencyX.ToArray(),
|
||||
FrequencyY = _frequencyY.ToArray(),
|
||||
PhaseX = _phaseX.ToArray(),
|
||||
PhaseY = _phaseY.ToArray(),
|
||||
AnimationSpeed = _animationSpeed.ToArray(),
|
||||
SourceFlags = _sourceFlags.ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class AetheriaSceneRenderSplat
|
||||
{
|
||||
public string LayerKey = AetheriaRuntimeRenderSplatLayerKeys.FogTint;
|
||||
public string SourceKey = "";
|
||||
public Vector2 Center;
|
||||
public Vector2 HalfExtent = Vector2.one * 32;
|
||||
public float RotationDegrees;
|
||||
public int Channel = AetheriaRuntimeRenderSplatChannels.Tint;
|
||||
public int Falloff = AetheriaRuntimeRenderSplatFalloffs.Smooth;
|
||||
public Color Value = Color.white;
|
||||
public int SourceKind = AetheriaRuntimeRenderSplatSourceKinds.Constant;
|
||||
public Vector2 Frequency = Vector2.one;
|
||||
public Vector2 Phase;
|
||||
public float AnimationSpeed;
|
||||
public float SourceFlags;
|
||||
|
||||
public static AetheriaSceneRenderSplat Animated(
|
||||
string layerKey,
|
||||
string sourceKey,
|
||||
Vector2 center,
|
||||
Vector2 halfExtent,
|
||||
Color value,
|
||||
float frequencyX,
|
||||
float frequencyY,
|
||||
float animationSpeed)
|
||||
{
|
||||
return new AetheriaSceneRenderSplat
|
||||
{
|
||||
LayerKey = layerKey,
|
||||
SourceKey = sourceKey,
|
||||
Center = center,
|
||||
HalfExtent = halfExtent,
|
||||
Channel = AetheriaRuntimeRenderSplatChannels.Tint,
|
||||
Falloff = AetheriaRuntimeRenderSplatFalloffs.Solid,
|
||||
Value = value,
|
||||
SourceKind = AetheriaRuntimeRenderSplatSourceKinds.AnimatedSimplexNoise,
|
||||
Frequency = new Vector2(frequencyX, frequencyY),
|
||||
AnimationSpeed = animationSpeed,
|
||||
SourceFlags = 1
|
||||
};
|
||||
}
|
||||
|
||||
public void AddTo(AetheriaSceneRenderSplatSource.Builder builder, IReadOnlyDictionary<string, int> layerIndices)
|
||||
{
|
||||
if (builder == null || !layerIndices.TryGetValue(LayerKey ?? "", out var layerIndex))
|
||||
return;
|
||||
|
||||
builder.Add(this, layerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class AetheriaSceneRenderSplatFixture
|
||||
{
|
||||
public Transform Transform;
|
||||
public AetheriaSceneRenderSplat Splat = new AetheriaSceneRenderSplat();
|
||||
|
||||
public void AddTo(AetheriaSceneRenderSplatSource.Builder builder, IReadOnlyDictionary<string, int> layerIndices)
|
||||
{
|
||||
if (Transform == null || Splat == null)
|
||||
return;
|
||||
|
||||
var previousCenter = Splat.Center;
|
||||
Splat.Center = new Vector2(Transform.position.x, Transform.position.z);
|
||||
try
|
||||
{
|
||||
Splat.AddTo(builder, layerIndices);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Splat.Center = previousCenter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c9073f8e2eb4b52b9a11ec60dcfc451
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -7,13 +7,13 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using UnityEngine.Rendering;
|
||||
using float3 = Unity.Mathematics.float3;
|
||||
|
||||
public sealed class AetheriaUnityCurrentEntityBinder
|
||||
{
|
||||
public ZoneRenderer ZoneRenderer { get; set; }
|
||||
public PostProcessVolume DeathPost { get; set; }
|
||||
public Volume DeathPost { get; set; }
|
||||
public CanvasGroup GameplayUI { get; set; }
|
||||
public AetheriaUnityCurrentEntityPresentation CurrentEntityPresentation { get; set; }
|
||||
public AetheriaUnityTargetPresentation TargetPresentation { get; set; }
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ public sealed class AetheriaUnityDaemonRenderDocuments : IDisposable
|
|||
if (state == null)
|
||||
throw new ArgumentNullException(nameof(state));
|
||||
|
||||
_frame = state.ReactiveDaemonFrame();
|
||||
_soaView = state.ReactiveDaemonSoaView();
|
||||
_zoneRender = state.ReactiveZoneRender();
|
||||
_frame = state.DaemonFrame.Reactive();
|
||||
_soaView = state.DaemonSoaView.Reactive();
|
||||
_zoneRender = state.ZoneRender.Reactive();
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonRenderView Current =>
|
||||
|
|
|
|||
23
Assets/Scripts/Gameplay/AetheriaUnityEveRuntimeHooks.cs
Normal file
23
Assets/Scripts/Gameplay/AetheriaUnityEveRuntimeHooks.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using UnityEngine;
|
||||
|
||||
public static class AetheriaUnityEveRuntimeHooks
|
||||
{
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void Install()
|
||||
{
|
||||
AetheriaEveRuntimeUnityHooks.ResolveStateBoot =
|
||||
overridePath => AetheriaRuntimeStateBoot.Inspect(
|
||||
AetheriaUnityRuntimePaths.GameDataDirectory,
|
||||
overridePath ?? "");
|
||||
AetheriaEveRuntimeUnityHooks.RuntimeState =
|
||||
(stateBoot, runtimeId) => AetheriaUnityRuntimeClientProvider.RuntimeState(stateBoot, runtimeId);
|
||||
AetheriaEveRuntimeUnityHooks.Control =
|
||||
(stateBoot, runtimeId) => AetheriaUnityRuntimeClientProvider.Control(stateBoot, runtimeId);
|
||||
AetheriaEveRuntimeUnityHooks.Ui =
|
||||
(stateBoot, runtimeId) => AetheriaUnityRuntimeClientProvider.Ui(stateBoot, runtimeId);
|
||||
AetheriaEveRuntimeUnityHooks.StateRefResolver =
|
||||
(stateBoot, runtimeId) => AetheriaUnityRuntimeClientProvider.EveSurfaceStateRefResolver(stateBoot, runtimeId);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Gameplay/AetheriaUnityEveRuntimeHooks.cs.meta
Normal file
11
Assets/Scripts/Gameplay/AetheriaUnityEveRuntimeHooks.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 72069f7b0885490fb690dc771e422aac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
|
||||
public sealed class AetheriaUnityGameplayBootShell
|
||||
{
|
||||
|
|
@ -34,10 +35,11 @@ public sealed class AetheriaUnityGameplayBootShell
|
|||
$"Aetheria runtime state file is missing at {stateBoot.StateFilePath}; gameplay requires an authoritative daemon mirror.");
|
||||
}
|
||||
|
||||
var runtimeCatalog = AetheriaUnityRuntimeClientProvider.CurrentCatalog(stateBoot, stateBoot.RuntimeId);
|
||||
var runtimeState = AetheriaUnityRuntimeClientProvider.RuntimeState(stateBoot, stateBoot.RuntimeId);
|
||||
var runtimeCatalog = runtimeState.Catalog.Latest();
|
||||
if (runtimeCatalog == null)
|
||||
throw new InvalidOperationException("Aetheria typed runtime catalog is required before gameplay boot.");
|
||||
var sectorMap = AetheriaUnityRuntimeClientProvider.CurrentSectorMap(stateBoot, stateBoot.RuntimeId);
|
||||
var sectorMap = runtimeState.SectorMap.Latest();
|
||||
if (sectorMap == null)
|
||||
throw new InvalidOperationException("Aetheria typed sector map is required before gameplay boot.");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
using System;
|
||||
using Cinemachine;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public sealed class AetheriaUnityGameplaySceneWiring
|
||||
|
|
@ -34,6 +34,17 @@ public sealed class AetheriaUnityGameplaySceneWiring
|
|||
public Sprite NoShieldIcon { get; set; }
|
||||
public Prototype HostileTargetIndicator { get; set; }
|
||||
public Prototype FriendlyTargetIndicator { get; set; }
|
||||
|
||||
private AetheriaClientState _targetPresentationState;
|
||||
|
||||
private AetheriaClientState TargetPresentationState
|
||||
{
|
||||
get
|
||||
{
|
||||
_targetPresentationState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-target-presentation");
|
||||
return _targetPresentationState;
|
||||
}
|
||||
}
|
||||
public PlaceUIElementWorldspace ViewDot { get; set; }
|
||||
public PlaceUIElementWorldspace TargetIndicator { get; set; }
|
||||
public Image TargetHitpointsFill { get; set; }
|
||||
|
|
@ -78,7 +89,7 @@ public sealed class AetheriaUnityGameplaySceneWiring
|
|||
public void ConfigureTargetPresentation(
|
||||
AetheriaUnityTargetPresentation presentation,
|
||||
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
|
||||
AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
AetheriaUnityPresentationEntityIndex presentationEntityIndex)
|
||||
{
|
||||
if (presentation == null)
|
||||
return;
|
||||
|
|
@ -94,18 +105,18 @@ public sealed class AetheriaUnityGameplaySceneWiring
|
|||
presentation.VisibilityToTargetFill = VisibilityToTargetFill;
|
||||
presentation.TargetShieldsFill = TargetShieldsFill;
|
||||
presentation.ResolveEntity = daemonEntityIndex =>
|
||||
observedEntityIndex != null &&
|
||||
observedEntityIndex.TryResolveEntityByDaemonIndex(daemonEntityIndex, out var entity)
|
||||
presentationEntityIndex != null &&
|
||||
presentationEntityIndex.TryGetPresentationEntityByDaemonIndex(daemonEntityIndex, out var entity)
|
||||
? entity
|
||||
: null;
|
||||
presentation.ResolveZoneContacts = ReadZoneContacts;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeZoneContactsDocument ReadZoneContacts()
|
||||
private AetheriaRuntimeZoneContactsDocument ReadZoneContacts()
|
||||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentZoneContacts("unity-target-presentation");
|
||||
return TargetPresentationState.ZoneContacts.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -143,12 +154,12 @@ public sealed class AetheriaUnityGameplaySceneWiring
|
|||
MainMenu?.SetRuntimeInputScreenShell(menuShell.CanOpenRuntimeInputScreen, menuShell.ShowRuntimeInputScreen);
|
||||
}
|
||||
|
||||
public void ConfigureObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
public void ConfigurePresentationEntityIndex(AetheriaUnityPresentationEntityIndex presentationEntityIndex)
|
||||
{
|
||||
Inventory?.SetObservedEntityIndex(observedEntityIndex);
|
||||
ShipPanel?.SetObservedEntityIndex(observedEntityIndex);
|
||||
TargetShipPanel?.SetObservedEntityIndex(observedEntityIndex);
|
||||
Inventory?.SetPresentationEntityIndex(presentationEntityIndex);
|
||||
ShipPanel?.SetPresentationEntityIndex(presentationEntityIndex);
|
||||
TargetShipPanel?.SetPresentationEntityIndex(presentationEntityIndex);
|
||||
foreach (var localMenu in UnityEngine.Object.FindObjectsByType<LocalMenu>(FindObjectsSortMode.None))
|
||||
localMenu.SetObservedEntityIndex(observedEntityIndex);
|
||||
localMenu.SetPresentationEntityIndex(presentationEntityIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1561fad48f5f1aa43a9070d788f6eaa7
|
||||
|
|
@ -8,14 +8,14 @@ using GameCult.Aetheria.State.Verse;
|
|||
|
||||
public sealed class AetheriaUnityObservedEntityRestorer
|
||||
{
|
||||
private readonly AetheriaUnityObservedEntityIndex _entityIndex;
|
||||
private readonly AetheriaUnityPresentationEntityIndex _entityIndex;
|
||||
private readonly ItemManager _itemManager;
|
||||
private readonly Func<AetheriaRuntimeEntitySnapshot, bool, EntityConstructionBlueprint> _createBlueprint;
|
||||
private readonly Func<AetheriaRuntimeLoadoutItemSnapshot, ItemInstance> _createLoadoutItem;
|
||||
private readonly Action<string> _logWarning;
|
||||
|
||||
public AetheriaUnityObservedEntityRestorer(
|
||||
AetheriaUnityObservedEntityIndex entityIndex,
|
||||
AetheriaUnityPresentationEntityIndex entityIndex,
|
||||
ItemManager itemManager,
|
||||
Func<AetheriaRuntimeEntitySnapshot, bool, EntityConstructionBlueprint> createBlueprint,
|
||||
Func<AetheriaRuntimeLoadoutItemSnapshot, ItemInstance> createLoadoutItem,
|
||||
|
|
@ -53,7 +53,7 @@ public sealed class AetheriaUnityObservedEntityRestorer
|
|||
}
|
||||
|
||||
ApplyInPlace(entitySnapshots);
|
||||
if (_entityIndex.TryResolveEntityByRecordKey(currentEntityKey, out var resolvedCurrentEntity) &&
|
||||
if (_entityIndex.TryGetPresentationEntityByRecordKey(currentEntityKey, out var resolvedCurrentEntity) &&
|
||||
currentEntity != resolvedCurrentEntity)
|
||||
{
|
||||
reboundCurrentEntity = resolvedCurrentEntity;
|
||||
|
|
@ -107,7 +107,7 @@ public sealed class AetheriaUnityObservedEntityRestorer
|
|||
{
|
||||
foreach (var entitySnapshot in entitySnapshots)
|
||||
{
|
||||
if (!_entityIndex.TryResolveEntityByRecordKey(entitySnapshot.RecordKey, out var entity))
|
||||
if (!_entityIndex.TryGetPresentationEntityByRecordKey(entitySnapshot.RecordKey, out var entity))
|
||||
continue;
|
||||
|
||||
ApplyPoseAndSimpleRuntimeState(entity, entitySnapshot);
|
||||
|
|
@ -115,7 +115,7 @@ public sealed class AetheriaUnityObservedEntityRestorer
|
|||
if (entity.Settings != null)
|
||||
entity.Settings.ShutdownPerformance = (float)entitySnapshot.ShutdownPerformance;
|
||||
entity.RestoreThermalExposure((float)entitySnapshot.Heatstroke, (float)entitySnapshot.Hypothermia);
|
||||
RestoreRuntimeBehaviorState(entity, entitySnapshot, _entityIndex.EntitiesByRecordKey);
|
||||
RestoreRuntimeBehaviorState(entity, entitySnapshot, _entityIndex.PresentationEntitiesByRecordKey);
|
||||
}
|
||||
|
||||
_entityIndex.RefreshDaemonIndex();
|
||||
|
|
@ -123,6 +123,7 @@ public sealed class AetheriaUnityObservedEntityRestorer
|
|||
|
||||
private static void ApplyPoseAndSimpleRuntimeState(Entity entity, AetheriaRuntimeEntitySnapshot entitySnapshot)
|
||||
{
|
||||
entity.DaemonRecordKey = entitySnapshot.RecordKey ?? "";
|
||||
entity.DaemonEntityIndex = entitySnapshot.EntityIndex;
|
||||
entity.Name = entitySnapshot.Name ?? "";
|
||||
entity.CultPosition = new CultMath.float3((float)entitySnapshot.PositionX, (float)entitySnapshot.PositionY, (float)entitySnapshot.PositionZ);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public sealed class AetheriaUnityObservedFrameApplier
|
|||
private readonly Func<int, GalaxyZone> _resolveObservedZone;
|
||||
private readonly Func<Zone> _getZone;
|
||||
private readonly Action<Zone> _setZone;
|
||||
private readonly AetheriaUnityObservedEntityIndex _entityIndex;
|
||||
private readonly AetheriaUnityPresentationEntityIndex _entityIndex;
|
||||
private readonly AetheriaUnityObservedEntityRestorer _entityRestorer;
|
||||
private readonly AetheriaUnityObservedZoneContextFactory _zoneContextFactory;
|
||||
private readonly Func<ZoneRenderer> _resolveZoneRenderer;
|
||||
|
|
@ -31,7 +31,7 @@ public sealed class AetheriaUnityObservedFrameApplier
|
|||
Func<int, GalaxyZone> resolveObservedZone,
|
||||
Func<Zone> getZone,
|
||||
Action<Zone> setZone,
|
||||
AetheriaUnityObservedEntityIndex entityIndex,
|
||||
AetheriaUnityPresentationEntityIndex entityIndex,
|
||||
AetheriaUnityObservedEntityRestorer entityRestorer,
|
||||
AetheriaUnityObservedZoneContextFactory zoneContextFactory,
|
||||
Func<ZoneRenderer> resolveZoneRenderer,
|
||||
|
|
@ -146,8 +146,8 @@ public sealed class AetheriaUnityObservedFrameApplier
|
|||
}
|
||||
|
||||
_entityRestorer.Replace(entitySnapshots, currentEntityKey, _getZone());
|
||||
zoneRenderer?.LoadDaemonZoneView(_entityIndex.EntitiesByDaemonIndex, render);
|
||||
if (_entityIndex.TryResolveEntityByRecordKey(currentEntityKey, out var currentEntity))
|
||||
zoneRenderer?.LoadDaemonZoneView(_entityIndex.PresentationEntitiesByDaemonIndex, render);
|
||||
if (_entityIndex.TryGetPresentationEntityByRecordKey(currentEntityKey, out var currentEntity))
|
||||
_restoreCurrentEntityBinding(currentEntity);
|
||||
zoneRenderer?.RestoreDroppedPickupsFromZoneRender(render);
|
||||
_lastAppliedZoneRenderFrameId = render.FrameId;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,15 @@ public sealed class AetheriaUnityObservedZoneContextFactory
|
|||
return observedZoneContext;
|
||||
}
|
||||
|
||||
public GalaxyZone ResolveGalaxyZone(int daemonZoneIndex)
|
||||
{
|
||||
if (daemonZoneIndex < 0)
|
||||
return null;
|
||||
|
||||
_observedGalaxy ??= _resolveObservedGalaxy();
|
||||
return _observedGalaxy?.Zones?.FirstOrDefault(zone => zone != null && zone.ZoneIndex == daemonZoneIndex);
|
||||
}
|
||||
|
||||
private static ZoneConstructionBlueprint CreateZoneConstructionBlueprint(AetheriaRuntimeZoneRenderDocument render)
|
||||
{
|
||||
var blueprint = new ZoneConstructionBlueprint
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System;
|
|||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using UnityEngine.Rendering;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public sealed class AetheriaUnityPilotFrameController
|
||||
|
|
@ -23,8 +23,8 @@ public sealed class AetheriaUnityPilotFrameController
|
|||
public AetheriaInput Input { get; set; }
|
||||
public AetheriaUnityTargetPresentation TargetPresentation { get; set; }
|
||||
public AetheriaUnityPilotCommandSender PilotCommands { get; set; }
|
||||
public PostProcessVolume HeatstrokePost { get; set; }
|
||||
public PostProcessVolume SevereHeatstrokePost { get; set; }
|
||||
public Volume HeatstrokePost { get; set; }
|
||||
public Volume SevereHeatstrokePost { get; set; }
|
||||
public float2 Sensitivity { get; set; }
|
||||
|
||||
public void Tick(Entity currentEntity, float deltaTime, float timeSeconds)
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@ using Unity.Mathematics;
|
|||
public sealed class AetheriaUnityPilotOperationController
|
||||
{
|
||||
private readonly Func<AetheriaUnityPilotCommandSender> _resolvePilotCommands;
|
||||
private readonly AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private readonly AetheriaUnityPresentationEntityIndex _presentationEntityIndex;
|
||||
private readonly Func<float3> _resolveViewDirection;
|
||||
private readonly Func<Entity> _resolveCurrentEntity;
|
||||
|
||||
public AetheriaUnityPilotOperationController(
|
||||
Func<AetheriaUnityPilotCommandSender> resolvePilotCommands,
|
||||
AetheriaUnityObservedEntityIndex observedEntityIndex,
|
||||
AetheriaUnityPresentationEntityIndex presentationEntityIndex,
|
||||
Func<float3> resolveViewDirection,
|
||||
Func<Entity> resolveCurrentEntity)
|
||||
{
|
||||
_resolvePilotCommands = resolvePilotCommands ?? throw new ArgumentNullException(nameof(resolvePilotCommands));
|
||||
_observedEntityIndex = observedEntityIndex ?? throw new ArgumentNullException(nameof(observedEntityIndex));
|
||||
_presentationEntityIndex = presentationEntityIndex ?? throw new ArgumentNullException(nameof(presentationEntityIndex));
|
||||
_resolveViewDirection = resolveViewDirection ?? (() => default);
|
||||
_resolveCurrentEntity = resolveCurrentEntity ?? (() => null);
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public sealed class AetheriaUnityPilotOperationController
|
|||
return;
|
||||
}
|
||||
|
||||
if (!_observedEntityIndex.TryResolveEntityRecordKey(target, out var targetEntityKey) ||
|
||||
if (!_presentationEntityIndex.TryGetRecordKeyForPresentationEntity(target, out var targetEntityKey) ||
|
||||
string.IsNullOrWhiteSpace(targetEntityKey))
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public sealed class AetheriaUnityObservedEntityIndex
|
||||
public sealed class AetheriaUnityPresentationEntityIndex
|
||||
{
|
||||
private readonly Dictionary<string, Entity> _entitiesByRecordKey = new Dictionary<string, Entity>(StringComparer.Ordinal);
|
||||
private readonly Dictionary<int, Entity> _entitiesByDaemonIndex = new Dictionary<int, Entity>();
|
||||
|
||||
public IReadOnlyDictionary<string, Entity> EntitiesByRecordKey => _entitiesByRecordKey;
|
||||
public IReadOnlyDictionary<string, Entity> PresentationEntitiesByRecordKey => _entitiesByRecordKey;
|
||||
|
||||
public IReadOnlyDictionary<int, Entity> EntitiesByDaemonIndex => _entitiesByDaemonIndex;
|
||||
public IReadOnlyDictionary<int, Entity> PresentationEntitiesByDaemonIndex => _entitiesByDaemonIndex;
|
||||
|
||||
public int Count => _entitiesByRecordKey.Count;
|
||||
|
||||
|
|
@ -26,7 +26,10 @@ public sealed class AetheriaUnityObservedEntityIndex
|
|||
foreach (var pair in entitiesByRecordKey)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(pair.Key) && pair.Value != null)
|
||||
{
|
||||
pair.Value.DaemonRecordKey = pair.Key;
|
||||
_entitiesByRecordKey[pair.Key] = pair.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -38,12 +41,20 @@ public sealed class AetheriaUnityObservedEntityIndex
|
|||
RebuildDaemonIndex();
|
||||
}
|
||||
|
||||
public bool TryResolveEntityRecordKey(Entity entity, out string recordKey)
|
||||
public bool TryGetRecordKeyForPresentationEntity(Entity entity, out string recordKey)
|
||||
{
|
||||
recordKey = "";
|
||||
if (entity == null)
|
||||
return false;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(entity.DaemonRecordKey) &&
|
||||
_entitiesByRecordKey.TryGetValue(entity.DaemonRecordKey, out var indexedEntity) &&
|
||||
ReferenceEquals(indexedEntity, entity))
|
||||
{
|
||||
recordKey = entity.DaemonRecordKey;
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var pair in _entitiesByRecordKey)
|
||||
{
|
||||
if (ReferenceEquals(pair.Value, entity))
|
||||
|
|
@ -56,26 +67,26 @@ public sealed class AetheriaUnityObservedEntityIndex
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool TryResolveEntityByRecordKey(string recordKey, out Entity entity)
|
||||
public bool TryGetPresentationEntityByRecordKey(string recordKey, out Entity entity)
|
||||
{
|
||||
entity = null;
|
||||
return !string.IsNullOrWhiteSpace(recordKey) &&
|
||||
_entitiesByRecordKey.TryGetValue(recordKey, out entity);
|
||||
}
|
||||
|
||||
public bool TryResolveEntityByDaemonIndex(int daemonEntityIndex, out Entity entity)
|
||||
public bool TryGetPresentationEntityByDaemonIndex(int daemonEntityIndex, out Entity entity)
|
||||
{
|
||||
return _entitiesByDaemonIndex.TryGetValue(daemonEntityIndex, out entity);
|
||||
}
|
||||
|
||||
public bool TryResolveDockingBayByRecordKey(
|
||||
public bool TryGetPresentationDockingBayByRecordKey(
|
||||
string parentRecordKey,
|
||||
int dockingBayIndex,
|
||||
out EquippedDockingBay dockingBay)
|
||||
{
|
||||
dockingBay = null;
|
||||
if (dockingBayIndex < 0 ||
|
||||
!TryResolveEntityByRecordKey(parentRecordKey, out var parent) ||
|
||||
!TryGetPresentationEntityByRecordKey(parentRecordKey, out var parent) ||
|
||||
parent?.DockingBays == null ||
|
||||
dockingBayIndex >= parent.DockingBays.Count)
|
||||
{
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1561fad48f5f1aa43a9070d788f6eaa7
|
||||
|
|
@ -27,6 +27,8 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
|||
|
||||
private float _nextRefreshTime;
|
||||
private AetheriaUnityRtsViewportDocuments _viewportDocuments;
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument _fallbackRenderSplatsViewport;
|
||||
private string _lastWarningMessage = "";
|
||||
|
||||
public RenderTexture TargetTexture
|
||||
{
|
||||
|
|
@ -39,6 +41,15 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public AetheriaRuntimeRenderSplatsViewportDocument CurrentDocument =>
|
||||
_viewportDocuments?.CurrentRenderSplatsViewport ?? _fallbackRenderSplatsViewport;
|
||||
|
||||
public bool RenderInLateUpdate
|
||||
{
|
||||
get => renderInLateUpdate;
|
||||
set => renderInLateUpdate = value;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
rasterizer = GetComponent<AetheriaRenderSplatRasterizer>();
|
||||
|
|
@ -63,7 +74,7 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
|||
return false;
|
||||
|
||||
RefreshDocument(false);
|
||||
var document = _viewportDocuments?.CurrentRenderSplatsViewport;
|
||||
var document = _viewportDocuments?.CurrentRenderSplatsViewport ?? _fallbackRenderSplatsViewport;
|
||||
if (document == null)
|
||||
return false;
|
||||
|
||||
|
|
@ -118,13 +129,36 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
|||
.RenderSplatViewportDocuments(viewport, "unity-render-splat-viewport");
|
||||
ClearViewportDocument();
|
||||
_viewportDocuments = nextDocuments;
|
||||
_fallbackRenderSplatsViewport = null;
|
||||
_lastWarningMessage = "";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria render splats from local Verse state: {ex.Message}");
|
||||
ClearViewportDocument();
|
||||
_fallbackRenderSplatsViewport = EmptyRenderSplatsViewport(viewport);
|
||||
WarnOnce($"Failed to read Aetheria render splats from local Verse state: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void WarnOnce(string message)
|
||||
{
|
||||
if (string.Equals(_lastWarningMessage, message, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
_lastWarningMessage = message;
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRenderSplatsViewportDocument EmptyRenderSplatsViewport(
|
||||
AetheriaRuntimeRtsViewportBounds viewport)
|
||||
{
|
||||
return new AetheriaRuntimeRenderSplatsViewportDocument
|
||||
{
|
||||
PublishedAtUtc = DateTimeOffset.UtcNow.ToString("O"),
|
||||
Viewport = viewport ?? new AetheriaRuntimeRtsViewportBounds()
|
||||
};
|
||||
}
|
||||
|
||||
private AetheriaRuntimeRtsViewportBounds ResolveViewportBounds()
|
||||
{
|
||||
var halfSize = size * 0.5f;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
|
|||
throw new ArgumentNullException(nameof(viewport));
|
||||
|
||||
Viewport = viewport;
|
||||
_contacts = bindContacts ? state.ReactiveZoneContacts() : null;
|
||||
_objectsViewport = bindObjects ? state.ReactiveObjectsViewport(viewport) : null;
|
||||
_renderSplatsViewport = bindRenderSplats ? state.ReactiveRenderSplatsViewport(viewport) : null;
|
||||
_contacts = bindContacts ? state.ZoneContacts.Reactive() : null;
|
||||
_objectsViewport = bindObjects ? state.ObjectsViewport(viewport).Reactive() : null;
|
||||
_renderSplatsViewport = bindRenderSplats ? state.RenderSplatsViewport(viewport).Reactive() : null;
|
||||
}
|
||||
|
||||
public AetheriaRuntimeRtsViewportBounds Viewport { get; }
|
||||
|
|
|
|||
|
|
@ -77,104 +77,6 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return RuntimeClient(stateBoot, runtimeId).State;
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeCurrentDockingDocument CurrentDockingState(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentDockingState();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeCurrentDockingDocument CurrentDockingState(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).CurrentDockingState();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeCatalogSnapshot CurrentCatalog(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentCatalog();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeCatalogSnapshot CurrentCatalog(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).CurrentCatalog();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimePlayerSettingsDocument CurrentPlayerSettings(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentPlayerSettings();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimePlayerSettingsDocument CurrentPlayerSettings(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).CurrentPlayerSettings();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeCurrentEntityDocument CurrentEntityState(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentEntityState();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeCurrentZoneDocument CurrentZoneState(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentZoneState();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeZoneContactsDocument CurrentZoneContacts(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentZoneContacts();
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> ReactiveZoneContacts(
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).ReactiveZoneContacts();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeStationRefitDocument CurrentStationRefit(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentStationRefit();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeSectorMapDocument CurrentSectorMap(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentSectorMap();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeSectorMapDocument CurrentSectorMap(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).CurrentSectorMap();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeZoneDetailsDocument CurrentZoneDetails(int zoneIndex, string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentZoneDetails(zoneIndex);
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeInventoryDocument CurrentInventory(int entityIndex, string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentInventory(entityIndex);
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<AetheriaRuntimeObjectsViewportDocument> ReactiveObjectsViewport(
|
||||
AetheriaRuntimeRtsViewportBounds viewport,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).ReactiveObjectsViewport(viewport);
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<AetheriaRuntimeRenderSplatsViewportDocument> ReactiveRenderSplatsViewport(
|
||||
AetheriaRuntimeRtsViewportBounds viewport,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).ReactiveRenderSplatsViewport(viewport);
|
||||
}
|
||||
|
||||
public static AetheriaUnityRtsViewportDocuments MapViewportDocuments(
|
||||
AetheriaRuntimeRtsViewportBounds viewport,
|
||||
string runtimeId = "")
|
||||
|
|
@ -196,18 +98,6 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return AetheriaUnityRtsViewportDocuments.OpenRenderSplats(RuntimeState(runtimeId), viewport);
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeDaemonFrameDocument CurrentDaemonFrame(string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(runtimeId).CurrentDaemonFrame();
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeDaemonFrameDocument CurrentDaemonFrame(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).CurrentDaemonFrame();
|
||||
}
|
||||
|
||||
public static AetheriaUnityDaemonRenderDocuments DaemonRenderDocuments(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
|
|
@ -215,13 +105,6 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return AetheriaUnityDaemonRenderDocuments.Open(RuntimeState(stateBoot, runtimeId));
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeVerseHostSettingsDocument CurrentVerseHostSettings(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).CurrentVerseHostSettings();
|
||||
}
|
||||
|
||||
public static AetheriaControl Control(string runtimeId = "")
|
||||
{
|
||||
return RuntimeClient(runtimeId).Control;
|
||||
|
|
@ -277,7 +160,7 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
{
|
||||
try
|
||||
{
|
||||
var stored = CurrentPlayerSettings();
|
||||
var stored = RuntimeState().PlayerSettings.Latest();
|
||||
if (stored == null)
|
||||
return;
|
||||
|
||||
|
|
|
|||
8
Assets/Scripts/Rendering.meta
Normal file
8
Assets/Scripts/Rendering.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b3c453d425710cb47bfcde9c9acf3b15
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Assets/Scripts/Rendering/AetheriaStardustRendererFeature.cs
Normal file
59
Assets/Scripts/Rendering/AetheriaStardustRendererFeature.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.RenderGraphModule;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
public sealed class AetheriaStardustRendererFeature : ScriptableRendererFeature
|
||||
{
|
||||
private StardustPass _pass;
|
||||
|
||||
public override void Create()
|
||||
{
|
||||
_pass = new StardustPass
|
||||
{
|
||||
renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing
|
||||
};
|
||||
}
|
||||
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
if (_pass == null)
|
||||
Create();
|
||||
|
||||
renderer.EnqueuePass(_pass);
|
||||
}
|
||||
|
||||
private sealed class StardustPass : ScriptableRenderPass
|
||||
{
|
||||
private sealed class PassData
|
||||
{
|
||||
internal Camera Camera;
|
||||
internal TextureHandle ColorTarget;
|
||||
internal TextureHandle DepthTarget;
|
||||
}
|
||||
|
||||
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
|
||||
{
|
||||
var cameraData = frameData.Get<UniversalCameraData>();
|
||||
var resourceData = frameData.Get<UniversalResourceData>();
|
||||
var colorTarget = resourceData.activeColorTexture;
|
||||
if (!colorTarget.IsValid())
|
||||
return;
|
||||
|
||||
using var builder = renderGraph.AddUnsafePass<PassData>("Aetheria Stardust", out var passData);
|
||||
passData.Camera = cameraData.camera;
|
||||
passData.ColorTarget = colorTarget;
|
||||
passData.DepthTarget = resourceData.activeDepthTexture;
|
||||
|
||||
builder.UseTexture(passData.ColorTarget, AccessFlags.ReadWrite);
|
||||
if (passData.DepthTarget.IsValid())
|
||||
builder.UseTexture(passData.DepthTarget, AccessFlags.Read);
|
||||
|
||||
builder.AllowPassCulling(false);
|
||||
builder.SetRenderFunc(static (PassData data, UnsafeGraphContext context) =>
|
||||
{
|
||||
Stardust.RenderForCamera(context.cmd, data.Camera, data.ColorTarget, data.DepthTarget);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ed96b0a823f44f9afc6c62a94ddc98d
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.RenderGraphModule;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
public sealed class AetheriaVolumeCloudRendererFeature : ScriptableRendererFeature
|
||||
{
|
||||
private VolumeCloudPass _pass;
|
||||
|
||||
public override void Create()
|
||||
{
|
||||
_pass = new VolumeCloudPass
|
||||
{
|
||||
renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing
|
||||
};
|
||||
_pass.ConfigureInput(ScriptableRenderPassInput.Depth);
|
||||
}
|
||||
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
if (_pass == null)
|
||||
Create();
|
||||
|
||||
renderer.EnqueuePass(_pass);
|
||||
}
|
||||
|
||||
private sealed class VolumeCloudPass : ScriptableRenderPass
|
||||
{
|
||||
private sealed class PassData
|
||||
{
|
||||
internal Camera Camera;
|
||||
internal VolumeCloudRenderer Renderer;
|
||||
internal TextureHandle ColorTarget;
|
||||
internal TextureHandle DepthTarget;
|
||||
}
|
||||
|
||||
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
|
||||
{
|
||||
var cameraData = frameData.Get<UniversalCameraData>();
|
||||
if (!VolumeCloudRenderer.TryGetRenderer(cameraData.camera, out var renderer))
|
||||
return;
|
||||
|
||||
var resourceData = frameData.Get<UniversalResourceData>();
|
||||
var colorTarget = resourceData.activeColorTexture;
|
||||
if (!colorTarget.IsValid())
|
||||
return;
|
||||
|
||||
using var builder = renderGraph.AddUnsafePass<PassData>("Aetheria Volume Clouds", out var passData);
|
||||
passData.Camera = cameraData.camera;
|
||||
passData.Renderer = renderer;
|
||||
passData.ColorTarget = colorTarget;
|
||||
passData.DepthTarget = resourceData.activeDepthTexture;
|
||||
|
||||
builder.UseTexture(passData.ColorTarget, AccessFlags.ReadWrite);
|
||||
if (passData.DepthTarget.IsValid())
|
||||
builder.UseTexture(passData.DepthTarget, AccessFlags.Read);
|
||||
|
||||
builder.AllowPassCulling(false);
|
||||
builder.SetRenderFunc(static (PassData data, UnsafeGraphContext context) =>
|
||||
{
|
||||
data.Renderer.RenderClouds(context.cmd, data.Camera, data.ColorTarget, data.DepthTarget);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3a9355da1f1b4fd489be0de05ebd165b
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.RenderGraphModule;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
public sealed class AetheriaVolumeSamplingRendererFeature : ScriptableRendererFeature
|
||||
{
|
||||
private VolumeSamplingPass _pass;
|
||||
|
||||
public override void Create()
|
||||
{
|
||||
_pass = new VolumeSamplingPass
|
||||
{
|
||||
renderPassEvent = RenderPassEvent.BeforeRendering
|
||||
};
|
||||
}
|
||||
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
if (_pass == null)
|
||||
Create();
|
||||
|
||||
renderer.EnqueuePass(_pass);
|
||||
}
|
||||
|
||||
private sealed class VolumeSamplingPass : ScriptableRenderPass
|
||||
{
|
||||
private sealed class PassData
|
||||
{
|
||||
internal UnityEngine.Camera Camera;
|
||||
}
|
||||
|
||||
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
|
||||
{
|
||||
using var builder = renderGraph.AddUnsafePass<PassData>("Aetheria Volume Sampling", out var passData);
|
||||
var cameraData = frameData.Get<UniversalCameraData>();
|
||||
passData.Camera = cameraData.camera;
|
||||
builder.AllowPassCulling(false);
|
||||
builder.SetRenderFunc(static (PassData data, UnsafeGraphContext context) =>
|
||||
{
|
||||
VolumeSampling.RenderForCamera(data.Camera);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24eee20c9f0bf4148804bc31f1be1482
|
||||
|
|
@ -43,6 +43,7 @@ public abstract class Entity
|
|||
public Faction Faction;
|
||||
public EquippableItem Hull;
|
||||
public EquippedItem EquippedHull;
|
||||
public string DaemonRecordKey = "";
|
||||
public int DaemonEntityIndex = -1;
|
||||
|
||||
public float3 Position;
|
||||
|
|
|
|||
|
|
@ -188,11 +188,11 @@ public class DaemonRuntimeDocumentTests
|
|||
MaxX = 100,
|
||||
MaxY = 100
|
||||
};
|
||||
var currentCatalog = client.State.CurrentCatalog();
|
||||
var currentPlayerSettings = client.State.CurrentPlayerSettings();
|
||||
var currentFrame = client.State.CurrentDaemonFrame();
|
||||
var currentEntityState = client.State.CurrentEntityState();
|
||||
var currentObjectsViewport = client.State.CurrentObjectsViewport(viewport);
|
||||
var currentCatalog = client.State.Catalog.Latest();
|
||||
var currentPlayerSettings = client.State.PlayerSettings.Latest();
|
||||
var currentFrame = client.State.DaemonFrame.Latest();
|
||||
var currentEntityState = client.State.CurrentEntity.Latest();
|
||||
var currentObjectsViewport = client.State.ObjectsViewport(viewport).Latest();
|
||||
var objectsViewport = ReadLatest(client.State.ObjectsViewport(viewport));
|
||||
var zoneDetails = ReadLatest(client.State.ZoneDetails(0));
|
||||
var inventory = ReadLatest(client.State.Inventory(0));
|
||||
|
|
@ -206,35 +206,35 @@ public class DaemonRuntimeDocumentTests
|
|||
.ReactiveAsync()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
using var zoneRenderReactive = client.State.ReactiveZoneRender();
|
||||
using var zoneRenderReactive = client.State.ZoneRender.Reactive();
|
||||
var observedAuthoritativeFrame = ReadLatest(client.State.DaemonFrame);
|
||||
using var catalogReactive = client.State.ReactiveCatalogSnapshot();
|
||||
using var daemonFrameReactive = client.State.ReactiveDaemonFrame();
|
||||
using var daemonSoaViewReactive = client.State.ReactiveDaemonSoaView();
|
||||
using var catalogReactive = client.State.Catalog.Reactive();
|
||||
using var daemonFrameReactive = client.State.DaemonFrame.Reactive();
|
||||
using var daemonSoaViewReactive = client.State.DaemonSoaView.Reactive();
|
||||
Assert.IsTrue(AetheriaRuntimeDaemonRenderView.TryCreateCurrent(
|
||||
daemonFrameReactive,
|
||||
daemonSoaViewReactive,
|
||||
zoneRenderReactive,
|
||||
out var observed));
|
||||
using var loadoutTemplatesReactive = client.State.ReactiveLoadoutTemplates();
|
||||
using var sectorMapReactive = client.State.ReactiveSectorMap();
|
||||
using var playerSettingsReactive = client.State.ReactivePlayerSettingsDocument();
|
||||
using var verseHostSettingsReactive = client.State.ReactiveVerseHostSettings();
|
||||
using var zoneContactsReactive = client.State.ReactiveZoneContacts();
|
||||
using var currentZoneReactive = client.State.ReactiveCurrentZone();
|
||||
using var currentEntityDocumentReactive = client.State.ReactiveCurrentEntity();
|
||||
using var currentDockingReactive = client.State.ReactiveCurrentDocking();
|
||||
using var stationRefitReactive = client.State.ReactiveStationRefit();
|
||||
using var zoneDetailsReactive = client.State.ReactiveZoneDetails(0);
|
||||
using var selectedObjectReactive = client.State.ReactiveSelectedObject(0);
|
||||
using var inventoryReactive = client.State.ReactiveInventory(0);
|
||||
using var mapViewportReactive = client.State.ReactiveRtsViewport(viewport);
|
||||
using var objectsViewportReactive = client.State.ReactiveObjectsViewport(viewport);
|
||||
using var gravityViewportReactive = client.State.ReactiveGravityViewport(viewport);
|
||||
using var renderSplatsViewportReactive = client.State.ReactiveRenderSplatsViewport(viewport);
|
||||
using var playerHudCatalog = client.State.ReactiveCatalogSnapshot();
|
||||
using var playerHudSettings = client.State.ReactivePlayerSettingsDocument();
|
||||
using var playerHudEntity = client.State.ReactiveCurrentEntity();
|
||||
using var loadoutTemplatesReactive = client.State.LoadoutTemplates.Reactive();
|
||||
using var sectorMapReactive = client.State.SectorMap.Reactive();
|
||||
using var playerSettingsReactive = client.State.PlayerSettings.Reactive();
|
||||
using var verseHostSettingsReactive = client.State.VerseHostSettings.Reactive();
|
||||
using var zoneContactsReactive = client.State.ZoneContacts.Reactive();
|
||||
using var currentZoneReactive = client.State.CurrentZone.Reactive();
|
||||
using var currentEntityDocumentReactive = client.State.CurrentEntity.Reactive();
|
||||
using var currentDockingReactive = client.State.CurrentDocking.Reactive();
|
||||
using var stationRefitReactive = client.State.StationRefit.Reactive();
|
||||
using var zoneDetailsReactive = client.State.ZoneDetails(0).Reactive();
|
||||
using var selectedObjectReactive = client.State.SelectedObject(0).Reactive();
|
||||
using var inventoryReactive = client.State.Inventory(0).Reactive();
|
||||
using var mapViewportReactive = client.State.RtsViewport(viewport).Reactive();
|
||||
using var objectsViewportReactive = client.State.ObjectsViewport(viewport).Reactive();
|
||||
using var gravityViewportReactive = client.State.GravityViewport(viewport).Reactive();
|
||||
using var renderSplatsViewportReactive = client.State.RenderSplatsViewport(viewport).Reactive();
|
||||
using var playerHudCatalog = client.State.Catalog.Reactive();
|
||||
using var playerHudSettings = client.State.PlayerSettings.Reactive();
|
||||
using var playerHudEntity = client.State.CurrentEntity.Reactive();
|
||||
var gameSurface = ReadLatest(client.State.GameSurface);
|
||||
var gameTuiSurface = ReadLatest(client.State.GameTuiSurface);
|
||||
var editorSurface = ReadLatest(client.State.EditorSurface);
|
||||
|
|
@ -247,7 +247,7 @@ public class DaemonRuntimeDocumentTests
|
|||
var stationRefit = ReadLatest(client.State.StationRefit);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityDocumentReactive.Current.EntityKey);
|
||||
Assert.AreEqual(currentDocking.CurrentEntityKey, currentDockingReactive.Current.CurrentEntityKey);
|
||||
Assert.AreEqual(stationRefit.StationEntityKey, stationRefitReactive.Current.StationEntityKey);
|
||||
Assert.AreEqual(stationRefit.CurrentEntityKey, stationRefitReactive.Current.CurrentEntityKey);
|
||||
using var reactiveGameSurface = client.State.GameSurface.Reactive();
|
||||
using var reactiveGameTuiSurface = client.State.GameTuiSurface.Reactive();
|
||||
using var reactiveEditorSurface = client.State.EditorSurface.Reactive();
|
||||
|
|
@ -268,7 +268,7 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.AreEqual(AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId, reactiveEditorSurface.Current.Surface.Id);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId, reactiveEditorTuiSurface.Current.Surface.Id);
|
||||
Assert.AreEqual(currentDocking.CurrentEntityKey, currentDockingReactive.Current.CurrentEntityKey);
|
||||
Assert.AreEqual(stationRefit.StationEntityKey, stationRefitReactive.Current.StationEntityKey);
|
||||
Assert.AreEqual(stationRefit.CurrentEntityKey, stationRefitReactive.Current.CurrentEntityKey);
|
||||
Assert.IsNotNull(ReadLatest(client.State.PlayerSettings));
|
||||
Assert.IsNotNull(ReadLatest(client.State.VerseHostSettings));
|
||||
Assert.IsNotNull(ReadLatest(client.State.ZoneContacts));
|
||||
|
|
@ -301,7 +301,7 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.AreSame(catalog, catalogReactive.Current);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, daemonFrameReactive.Current.Schema);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.SoaView, daemonSoaViewReactive.Current.Schema);
|
||||
Assert.AreEqual(AetheriaRuntimeLoadoutTemplatesDocument.SchemaId, loadoutTemplatesReactive.Current.Schema);
|
||||
Assert.AreEqual(typeof(AetheriaRuntimeLoadoutTemplatesDocument), client.State.LoadoutTemplates.DocumentType);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.SectorMap, sectorMapReactive.Current.Schema);
|
||||
Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettingsReactive.Current.Schema);
|
||||
Assert.AreEqual(AetheriaRuntimeVerseHostSettingsDocument.SchemaId, verseHostSettings.Schema);
|
||||
|
|
@ -395,19 +395,19 @@ public class DaemonRuntimeDocumentTests
|
|||
.GetResult();
|
||||
|
||||
var aetheria = verse.Aetheria();
|
||||
var currentEntity = ReadLatest(aetheria.Document<AetheriaRuntimeCurrentEntityDocument>());
|
||||
var currentEntity = ReadLatest(aetheria.CurrentEntity);
|
||||
var latestFrameDocument = verse.Document<AetheriaRuntimeDaemonFrameDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest);
|
||||
using var latestFrameReactive = latestFrameDocument.Reactive();
|
||||
|
||||
Assert.AreEqual("aetheria.current.entity", aetheria.Current.Entity.DocumentId);
|
||||
Assert.AreEqual("aetheria.current.entity", aetheria.CurrentEntity.DocumentId);
|
||||
Assert.AreEqual("zone.0.entity.0", currentEntity.EntityKey);
|
||||
Assert.AreEqual("Player", currentEntity.Entity?.DisplayName);
|
||||
Assert.AreEqual(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(), latestFrameDocument.DocumentId);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, latestFrameReactive.Current.Schema);
|
||||
Assert.AreEqual(8, latestFrameReactive.Current.FrameId);
|
||||
Assert.IsTrue(latestFrameDocument.CanSet);
|
||||
Assert.IsTrue(aetheria.Current.Entity.Sources.Any(source =>
|
||||
Assert.IsTrue(aetheria.CurrentEntity.Sources.Any(source =>
|
||||
source.SourceId == AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()));
|
||||
}
|
||||
|
||||
|
|
@ -599,16 +599,16 @@ public class DaemonRuntimeDocumentTests
|
|||
var unityEditorSurfaceState = ReadLatest(client.State.EditorSurface);
|
||||
var unityEditorTuiSurfaceState = ReadLatest(client.State.EditorTuiSurface);
|
||||
var surfaceResolver = client.State.CreateEveSurfaceCultMeshStateRefResolver();
|
||||
var unityGameSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var unityGameSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
unityGameSurfaceState,
|
||||
surfaceResolver);
|
||||
var unityGameTuiSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var unityGameTuiSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
unityGameTuiSurfaceState,
|
||||
surfaceResolver);
|
||||
var unityEditorSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var unityEditorSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
unityEditorSurfaceState,
|
||||
surfaceResolver);
|
||||
var unityEditorTuiSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var unityEditorTuiSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
unityEditorTuiSurfaceState,
|
||||
surfaceResolver);
|
||||
|
||||
|
|
@ -628,7 +628,7 @@ public class DaemonRuntimeDocumentTests
|
|||
command.Command == "aetheria.daemon.commands.TransferCargoItem"));
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId, unityEditorTuiSurface.Surface.Id);
|
||||
Assert.AreEqual("editor.daemon", unityEditorTuiSurface.ProviderKind);
|
||||
var genericGameSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var genericGameSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
ReadLatest(client.State.GameSurface),
|
||||
surfaceResolver);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, genericGameSurface.Surface.Id);
|
||||
|
|
@ -651,18 +651,18 @@ public class DaemonRuntimeDocumentTests
|
|||
"value",
|
||||
AetheriaRuntimeDaemonStateRefs.CurrentTargetName,
|
||||
AetheriaRuntimeDaemonSchemas.Frame));
|
||||
var genericGameTuiSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var genericGameTuiSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
ReadLatest(client.State.GameTuiSurface),
|
||||
surfaceResolver);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonGameSurfaceBuilder.TuiSurfaceId, genericGameTuiSurface.Surface.Id);
|
||||
var genericEditorTuiSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
var genericEditorTuiSurface = AetheriaRuntimeSurfaceDocuments.ToEveSurfaceDocument(
|
||||
ReadLatest(client.State.EditorTuiSurface),
|
||||
surfaceResolver);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId, genericEditorTuiSurface.Surface.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EveSurfaceAdapterResolvesDaemonStateRefsBeforeLowering()
|
||||
public void RuntimeSurfaceDocumentsResolveDaemonStateRefsBeforeLowering()
|
||||
{
|
||||
var surface = new EveSurfaceDocument(
|
||||
"surface-state",
|
||||
|
|
@ -690,7 +690,7 @@ public class DaemonRuntimeDocumentTests
|
|||
var resolver = CultMesh.StateRefResolver(
|
||||
"aetheria.tests.refs",
|
||||
(stateRef, _context) => stateRef == AetheriaRuntimeDaemonStateRefs.CurrentTargetName ? "Live Target" : "");
|
||||
var resolved = AetheriaRuntimeEveSurfaceAdapter.ResolveStateRefs(surface, resolver);
|
||||
var resolved = AetheriaRuntimeSurfaceDocuments.ResolveStateRefs(surface, resolver);
|
||||
|
||||
Assert.IsTrue(ContainsEveSurfaceMetric(resolved.Surface.Root, "Target", "Live Target"));
|
||||
Assert.IsTrue(ContainsEveSurfaceProp(
|
||||
|
|
@ -700,7 +700,7 @@ public class DaemonRuntimeDocumentTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void EveSurfaceAdapterResolvesTypedPointerPropsBeforeLowering()
|
||||
public void RuntimeSurfaceDocumentsResolveTypedPointerPropsBeforeLowering()
|
||||
{
|
||||
var surface = new EveSurfaceDocument(
|
||||
"surface-state",
|
||||
|
|
@ -729,7 +729,7 @@ public class DaemonRuntimeDocumentTests
|
|||
var resolver = CultMesh.StateRefResolver(
|
||||
"aetheria.tests.refs",
|
||||
(stateRef, _context) => stateRef == AetheriaRuntimeDaemonStateRefs.CurrentTargetName ? "Live Target" : "");
|
||||
var resolved = AetheriaRuntimeEveSurfaceAdapter.ResolveStateRefs(surface, resolver);
|
||||
var resolved = AetheriaRuntimeSurfaceDocuments.ResolveStateRefs(surface, resolver);
|
||||
|
||||
Assert.IsTrue(ContainsEveSurfaceProp(resolved.Surface.Root, "description", "Live Target"));
|
||||
Assert.IsTrue(ContainsEveSurfaceProp(resolved.Surface.Root, "descriptionRef", AetheriaRuntimeDaemonStateRefs.CurrentTargetName));
|
||||
|
|
@ -2207,9 +2207,9 @@ public class DaemonRuntimeDocumentTests
|
|||
.OpenAsync(statePath, "unity-observer-test", pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
using var observedFrame = client.State.ReactiveDaemonFrame();
|
||||
using var observedSoaView = client.State.ReactiveDaemonSoaView();
|
||||
using var observedZoneRender = client.State.ReactiveZoneRender();
|
||||
using var observedFrame = client.State.DaemonFrame.Reactive();
|
||||
using var observedSoaView = client.State.DaemonSoaView.Reactive();
|
||||
using var observedZoneRender = client.State.ZoneRender.Reactive();
|
||||
Assert.IsTrue(AetheriaRuntimeDaemonRenderView.TryCreateCurrent(
|
||||
observedFrame,
|
||||
observedSoaView,
|
||||
|
|
@ -2265,9 +2265,9 @@ public class DaemonRuntimeDocumentTests
|
|||
.OpenAsync(statePath, "unity-reactive-observer-test", pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
using var observedFrame = client.State.ReactiveDaemonFrame();
|
||||
using var observedSoaView = client.State.ReactiveDaemonSoaView();
|
||||
using var observedZoneRender = client.State.ReactiveZoneRender();
|
||||
using var observedFrame = client.State.DaemonFrame.Reactive();
|
||||
using var observedSoaView = client.State.DaemonSoaView.Reactive();
|
||||
using var observedZoneRender = client.State.ZoneRender.Reactive();
|
||||
var observed = AetheriaRuntimeDaemonRenderView.TryCreateCurrent(
|
||||
observedFrame,
|
||||
observedSoaView,
|
||||
|
|
@ -2312,9 +2312,9 @@ public class DaemonRuntimeDocumentTests
|
|||
.OpenAsync(statePath, "unity-frame-only-observer-test", pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
using var observedFrame = client.State.ReactiveDaemonFrame();
|
||||
using var observedSoaView = client.State.ReactiveDaemonSoaView();
|
||||
using var observedZoneRender = client.State.ReactiveZoneRender();
|
||||
using var observedFrame = client.State.DaemonFrame.Reactive();
|
||||
using var observedSoaView = client.State.DaemonSoaView.Reactive();
|
||||
using var observedZoneRender = client.State.ZoneRender.Reactive();
|
||||
Assert.IsTrue(AetheriaRuntimeDaemonRenderView.TryCreateCurrent(
|
||||
observedFrame,
|
||||
observedSoaView,
|
||||
|
|
@ -2375,7 +2375,7 @@ public class DaemonRuntimeDocumentTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void CommandClientSendsCommandAgainstDaemonFrame
|
||||
public void CommandClientSendsCommandAgainstDaemonFrame()
|
||||
{
|
||||
var statePath = Path.Combine(
|
||||
Path.GetTempPath(),
|
||||
|
|
|
|||
|
|
@ -82,12 +82,12 @@ public class StarbridgePlayerSeatDocumentTests
|
|||
var handle = client.Document<AetheriaRuntimeStarbridgePlayerSeatDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgePlayerSeat(seat.SeatId));
|
||||
using var reactive = handle.Reactive();
|
||||
using var aetheriaSeat = client.State.ReactiveStarbridgePlayerSeat(seat.SeatId);
|
||||
using var aetheriaSeat = client.Aetheria().StarbridgePlayerSeat(seat.SeatId).Reactive();
|
||||
|
||||
Assert.AreEqual("seat-support", handle.Latest().SeatId);
|
||||
Assert.AreEqual(
|
||||
"seat-support",
|
||||
ReadLatest(client.State.StarbridgePlayerSeat(seat.SeatId)).SeatId);
|
||||
ReadLatest(client.Aetheria().StarbridgePlayerSeat(seat.SeatId)).SeatId);
|
||||
Assert.AreEqual("item:cockpit:support", reactive.Current.CockpitItemKey);
|
||||
Assert.AreEqual("item:cockpit:support", aetheriaSeat.Current.CockpitItemKey);
|
||||
Assert.AreEqual("entity:pod:support", reactive.Current.EscapePodEntityKey);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,29 @@
|
|||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"ConcurrentCollections.dll",
|
||||
"GameCult.Caching.MessagePack.dll",
|
||||
"GameCult.Caching.dll",
|
||||
"GameCult.Logging.dll",
|
||||
"GameCult.Mesh.dll",
|
||||
"GameCult.Networking.dll",
|
||||
"Isopoh.Cryptography.Argon2.dll",
|
||||
"Isopoh.Cryptography.Blake2b.dll",
|
||||
"Isopoh.Cryptography.SecureArray.dll",
|
||||
"LiteNetLib.dll",
|
||||
"Microsoft.Bcl.AsyncInterfaces.dll",
|
||||
"Microsoft.Bcl.TimeProvider.dll",
|
||||
"Microsoft.NET.StringTools.dll",
|
||||
"MessagePack.Annotations.dll",
|
||||
"MessagePack.CultMesh.dll",
|
||||
"R3.dll",
|
||||
"System.Collections.Immutable.dll",
|
||||
"System.ComponentModel.Annotations.dll",
|
||||
"System.IO.Pipelines.dll",
|
||||
"System.Text.Encodings.Web.dll",
|
||||
"System.Text.Json.dll",
|
||||
"System.Threading.Channels.dll",
|
||||
"System.Threading.Tasks.Extensions.dll",
|
||||
"nunit.framework.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -69,6 +70,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
private SchematicDisplayItem[] _schematicItems;
|
||||
private AetherDrive _aetherDrive;
|
||||
private AetheriaRuntimeDaemonRenderSettings? _renderSettings;
|
||||
private AetheriaClientState _runtimeState;
|
||||
|
||||
private bool _enemy;
|
||||
private Entity _player;
|
||||
|
|
@ -92,6 +94,15 @@ public class SchematicDisplay : MonoBehaviour
|
|||
_renderSettings = renderSettings;
|
||||
}
|
||||
|
||||
private AetheriaClientState RuntimeState
|
||||
{
|
||||
get
|
||||
{
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-schematic-display");
|
||||
return _runtimeState;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowShip(Entity entity, Entity player = null)
|
||||
{
|
||||
_enemy = player != null;
|
||||
|
|
@ -318,7 +329,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentCatalog("unity-schematic-display");
|
||||
return RuntimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -332,7 +343,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider.CurrentPlayerSettings("unity-schematic-display");
|
||||
return RuntimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -346,9 +357,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentEntityState("unity-schematic-display")
|
||||
?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();
|
||||
return RuntimeState.CurrentEntity.Latest()?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
|
@ -18,6 +19,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
private string _captureActionName = "";
|
||||
private int _captureBindingIndex = -1;
|
||||
private string _captureBindingLabel = "";
|
||||
private AetheriaClientState _runtimeState;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _surfaceChrome = new AetheriaEveUnitySurfaceChrome
|
||||
{
|
||||
RootAlignItems = Align.Center,
|
||||
|
|
@ -368,8 +370,10 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings(RequireLocalStateBoot(), "unity-input-screen");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState(
|
||||
RequireLocalStateBoot(),
|
||||
"unity-input-screen");
|
||||
return _runtimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UIElements;
|
||||
using UiButton = UnityEngine.UIElements.Button;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
|
|
@ -15,37 +18,46 @@ public class MainMenu : MonoBehaviour
|
|||
public GameSettings Settings;
|
||||
public ConfirmationDialog Dialog;
|
||||
public bool InGame;
|
||||
public float FadeTime = 0.5f;
|
||||
public float FadeDistance = 512f;
|
||||
public float FadeAlphaExponent = 2f;
|
||||
public float FadePositionExponent = 2f;
|
||||
public float HoverSpacing = 8f;
|
||||
public float HoverAnimationDuration = 0.16f;
|
||||
|
||||
private UIDocument _menuSurfaceDocument;
|
||||
private UIDocument _currentMenuSurfaceDocument;
|
||||
private UIDocument _nextMenuSurfaceDocument;
|
||||
private Func<bool> _canOpenRuntimeInputScreen;
|
||||
private Action _openRuntimeInputScreen;
|
||||
private bool _fadeFromRight;
|
||||
private bool _fading;
|
||||
private float _fadeLerp;
|
||||
private readonly List<MenuHoverButton> _hoverButtons = new List<MenuHoverButton>();
|
||||
private readonly AetheriaEveUnitySurfaceChrome _menuSurfaceChrome = new AetheriaEveUnitySurfaceChrome
|
||||
{
|
||||
RootAlignItems = Align.Center,
|
||||
RootJustifyContent = Justify.Center,
|
||||
RootPaddingLeft = 24f,
|
||||
UseShell = false,
|
||||
RootAlignItems = Align.FlexStart,
|
||||
RootJustifyContent = Justify.FlexStart,
|
||||
RootPaddingLeft = 96f,
|
||||
RootPaddingTop = 92f,
|
||||
RootPaddingRight = 24f,
|
||||
RootPaddingTop = 24f,
|
||||
RootPaddingBottom = 24f,
|
||||
RootBackgroundColor = new Color(0f, 0f, 0f, 0.6f),
|
||||
Width = 560f,
|
||||
MinWidth = 0f,
|
||||
MaxWidth = 560f,
|
||||
PaddingLeft = 20f,
|
||||
PaddingRight = 20f,
|
||||
PaddingTop = 20f,
|
||||
PaddingBottom = 20f,
|
||||
BorderRadius = 0f,
|
||||
BorderWidth = 0f,
|
||||
BackgroundColor = new Color(0.08f, 0.1f, 0.14f, 0.96f)
|
||||
RootBackgroundColor = new Color(0f, 0f, 0f, 0f),
|
||||
RootPickingMode = PickingMode.Position
|
||||
};
|
||||
|
||||
void Start()
|
||||
{
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
}
|
||||
|
||||
private void ShowMain()
|
||||
void Update()
|
||||
{
|
||||
UpdateMenuFade();
|
||||
UpdateHoverButtons();
|
||||
}
|
||||
|
||||
private void ShowMain(bool animateFromRight = true)
|
||||
{
|
||||
var stateBoot = CurrentStateBoot();
|
||||
var sectorMap = ResolveSectorMap(stateBoot);
|
||||
|
|
@ -60,7 +72,8 @@ public class MainMenu : MonoBehaviour
|
|||
CanOpenRuntimeInputScreen(),
|
||||
InGame,
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
HandleMainSurfaceCommand);
|
||||
HandleMainSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void HandleMainSurfaceCommand(EveSurfaceCommandRequest request)
|
||||
|
|
@ -77,7 +90,7 @@ public class MainMenu : MonoBehaviour
|
|||
if (ResolveSectorMap(CurrentStateBoot()) == null)
|
||||
{
|
||||
Debug.LogWarning("Main-menu Continue requested without a typed Aetheria sector-map projection.");
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +100,7 @@ public class MainMenu : MonoBehaviour
|
|||
StartNewGame();
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.Quit:
|
||||
Application.Quit();
|
||||
|
|
@ -102,7 +115,7 @@ public class MainMenu : MonoBehaviour
|
|||
{
|
||||
if (!TryStartDaemonObservedGame("Starting Daemon Run"))
|
||||
{
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +158,9 @@ public class MainMenu : MonoBehaviour
|
|||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentSectorMap(stateBoot, "unity-main-menu");
|
||||
.RuntimeState(stateBoot, "unity-main-menu")
|
||||
.SectorMap
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -162,7 +177,9 @@ public class MainMenu : MonoBehaviour
|
|||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings(stateBoot, "unity-main-menu");
|
||||
.RuntimeState(stateBoot, "unity-main-menu")
|
||||
.PlayerSettings
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -179,7 +196,9 @@ public class MainMenu : MonoBehaviour
|
|||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentVerseHostSettings(stateBoot, "unity-main-menu");
|
||||
.RuntimeState(stateBoot, "unity-main-menu")
|
||||
.VerseHostSettings
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -192,18 +211,19 @@ public class MainMenu : MonoBehaviour
|
|||
{
|
||||
if (!TryStartDaemonObservedGame("Continuing Daemon Run"))
|
||||
{
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowSettings()
|
||||
private void ShowSettings(bool animateFromRight = true)
|
||||
{
|
||||
RenderMenuSurface(
|
||||
AetheriaRuntimeMainMenuSurfaceBuilder.BuildSettings(DateTime.UtcNow.ToString("O")),
|
||||
HandleSettingsSurfaceCommand);
|
||||
HandleSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void ShowInputSettings()
|
||||
private void ShowInputSettings(bool animateFromRight = true)
|
||||
{
|
||||
var stateBoot = CurrentStateBoot();
|
||||
RenderMenuSurface(
|
||||
|
|
@ -213,19 +233,21 @@ public class MainMenu : MonoBehaviour
|
|||
CanOpenRuntimeInputScreen(),
|
||||
InGame,
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
HandleInputSettingsSurfaceCommand);
|
||||
HandleInputSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void ShowPlayerSettingsSurface()
|
||||
private void ShowPlayerSettingsSurface(bool animateFromRight = true)
|
||||
{
|
||||
RenderMenuSurface(
|
||||
AetheriaRuntimeMainMenuSurfaceBuilder.BuildPlayerSettingsShell(
|
||||
ResolvePlayerSettings(CurrentStateBoot()),
|
||||
DateTime.UtcNow.ToString("O")),
|
||||
HandlePlayerSettingsSurfaceCommand);
|
||||
HandlePlayerSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void ShowVerseSettingsSurface()
|
||||
private void ShowVerseSettingsSurface(bool animateFromRight = true)
|
||||
{
|
||||
var stateBoot = CurrentStateBoot();
|
||||
RenderMenuSurface(
|
||||
|
|
@ -234,20 +256,377 @@ public class MainMenu : MonoBehaviour
|
|||
stateBoot,
|
||||
ResolveVerseHostSettings(stateBoot),
|
||||
DateTime.UtcNow.ToString("O"))),
|
||||
HandleVerseSettingsSurfaceCommand);
|
||||
HandleVerseSettingsSurfaceCommand,
|
||||
animateFromRight);
|
||||
}
|
||||
|
||||
private void RenderMenuSurface(
|
||||
AetheriaRuntimeSurfaceDocument document,
|
||||
Action<EveSurfaceCommandRequest> commandHandler)
|
||||
Action<EveSurfaceCommandRequest> commandHandler,
|
||||
bool animateFromRight)
|
||||
{
|
||||
_menuSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
var initialRender = _currentMenuSurfaceDocument == null;
|
||||
var targetDocument = initialRender ? _currentMenuSurfaceDocument : _nextMenuSurfaceDocument;
|
||||
targetDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
transform,
|
||||
_menuSurfaceDocument,
|
||||
"Aetheria Menu Surface",
|
||||
targetDocument,
|
||||
initialRender ? "Aetheria Menu Surface" : "Aetheria Menu Surface Transition",
|
||||
document,
|
||||
commandHandler,
|
||||
_menuSurfaceChrome);
|
||||
_menuSurfaceChrome,
|
||||
sortingOrder: initialRender ? 1000 : 1001);
|
||||
|
||||
ApplyMenuStyles(targetDocument.rootVisualElement, IsRootMainMenu(document));
|
||||
SetDocumentTransition(targetDocument, initialRender ? 0f : (animateFromRight ? FadeDistance : -FadeDistance), initialRender ? 1f : 0f);
|
||||
|
||||
if (initialRender)
|
||||
{
|
||||
_currentMenuSurfaceDocument = targetDocument;
|
||||
return;
|
||||
}
|
||||
|
||||
_nextMenuSurfaceDocument = targetDocument;
|
||||
_fadeFromRight = animateFromRight;
|
||||
_fadeLerp = 0f;
|
||||
_fading = true;
|
||||
}
|
||||
|
||||
private static bool IsRootMainMenu(AetheriaRuntimeSurfaceDocument document)
|
||||
{
|
||||
return string.Equals(
|
||||
document?.Surface?.Id,
|
||||
AetheriaRuntimeMainMenuCommands.RootSurfaceId,
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private void UpdateMenuFade()
|
||||
{
|
||||
if (!_fading)
|
||||
return;
|
||||
|
||||
_fadeLerp += Time.unscaledDeltaTime / Mathf.Max(0.01f, FadeTime);
|
||||
var t = Mathf.Clamp01(_fadeLerp);
|
||||
var outgoing = Mathf.Pow(t, FadePositionExponent);
|
||||
var incoming = Mathf.Pow(1f - t, FadePositionExponent);
|
||||
var direction = _fadeFromRight ? 1f : -1f;
|
||||
|
||||
SetDocumentTransition(
|
||||
_currentMenuSurfaceDocument,
|
||||
-direction * FadeDistance * outgoing,
|
||||
Mathf.Pow(1f - t, FadeAlphaExponent));
|
||||
SetDocumentTransition(
|
||||
_nextMenuSurfaceDocument,
|
||||
direction * FadeDistance * incoming,
|
||||
Mathf.Pow(t, FadeAlphaExponent));
|
||||
|
||||
if (_fadeLerp <= 1f)
|
||||
return;
|
||||
|
||||
_fading = false;
|
||||
AetheriaEveUnitySurfaceHost.Hide(_currentMenuSurfaceDocument);
|
||||
var previous = _currentMenuSurfaceDocument;
|
||||
_currentMenuSurfaceDocument = _nextMenuSurfaceDocument;
|
||||
_nextMenuSurfaceDocument = previous;
|
||||
SetDocumentTransition(_currentMenuSurfaceDocument, 0f, 1f);
|
||||
}
|
||||
|
||||
private static void SetDocumentTransition(UIDocument document, float x, float opacity)
|
||||
{
|
||||
if (document?.rootVisualElement == null)
|
||||
return;
|
||||
|
||||
document.rootVisualElement.style.translate = new Translate(new Length(x, LengthUnit.Pixel), 0f, 0f);
|
||||
document.rootVisualElement.style.opacity = opacity;
|
||||
}
|
||||
|
||||
private void UpdateHoverButtons()
|
||||
{
|
||||
for (var i = _hoverButtons.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var hover = _hoverButtons[i];
|
||||
if (hover.Button == null)
|
||||
{
|
||||
_hoverButtons.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var direction = hover.Hovering && hover.Button.enabledInHierarchy ? 1f : -1f;
|
||||
hover.Lerp = Mathf.Clamp01(hover.Lerp + Time.unscaledDeltaTime / Mathf.Max(0.01f, HoverAnimationDuration) * direction);
|
||||
hover.Button.style.letterSpacing = HoverSpacing * hover.Lerp;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyMenuStyles(VisualElement root, bool rootMainMenu)
|
||||
{
|
||||
if (root == null)
|
||||
return;
|
||||
|
||||
StyleMenuTree(root, rootMainMenu);
|
||||
|
||||
var surface = rootMainMenu
|
||||
? FindElement(root, $"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.root")
|
||||
: FindFirstKind(root, "surface");
|
||||
if (surface != null)
|
||||
{
|
||||
surface.style.flexGrow = 0f;
|
||||
surface.style.width = rootMainMenu ? 680f : 560f;
|
||||
surface.style.alignItems = Align.FlexStart;
|
||||
surface.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
var title = FindElement(root, $"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.title") as Label;
|
||||
if (title != null)
|
||||
{
|
||||
title.style.fontSize = 82f;
|
||||
title.style.color = new Color(0.82f, 0.95f, 1f, 0.96f);
|
||||
title.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
title.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
title.style.marginLeft = 0f;
|
||||
title.style.marginBottom = -12f;
|
||||
title.style.width = 660f;
|
||||
}
|
||||
|
||||
var subtitle = FindElement(root, $"{AetheriaRuntimeMainMenuCommands.RootSurfaceId}.subtitle") as Label;
|
||||
if (subtitle != null)
|
||||
{
|
||||
subtitle.style.fontSize = 38f;
|
||||
subtitle.style.color = new Color(0.82f, 0.95f, 1f, 0.92f);
|
||||
subtitle.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
subtitle.style.unityTextAlign = TextAnchor.MiddleRight;
|
||||
subtitle.style.marginTop = 0f;
|
||||
subtitle.style.marginBottom = 36f;
|
||||
subtitle.style.width = 660f;
|
||||
}
|
||||
|
||||
RegisterHoverButtons(root);
|
||||
}
|
||||
|
||||
private void StyleMenuTree(VisualElement element, bool rootMainMenu)
|
||||
{
|
||||
if (element == null)
|
||||
return;
|
||||
|
||||
element.pickingMode = PickingMode.Position;
|
||||
|
||||
if (element is UiButton button)
|
||||
StyleMenuButton(button, rootMainMenu);
|
||||
else if (element is TextField textField)
|
||||
StyleMenuTextField(textField, rootMainMenu);
|
||||
else if (element is Label label)
|
||||
StyleMenuLabel(label, rootMainMenu);
|
||||
else
|
||||
StyleMenuContainer(element, rootMainMenu);
|
||||
|
||||
foreach (var child in element.Children())
|
||||
StyleMenuTree(child, rootMainMenu);
|
||||
}
|
||||
|
||||
private static void StyleMenuContainer(VisualElement element, bool rootMainMenu)
|
||||
{
|
||||
element.style.backgroundColor = new Color(0f, 0f, 0f, 0f);
|
||||
element.style.borderLeftWidth = 0f;
|
||||
element.style.borderRightWidth = 0f;
|
||||
element.style.borderTopWidth = 0f;
|
||||
element.style.borderBottomWidth = 0f;
|
||||
element.style.marginLeft = 0f;
|
||||
element.style.marginTop = 0f;
|
||||
element.style.marginBottom = 0f;
|
||||
|
||||
if (element.ClassListContains("eve-row"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
element.style.flexWrap = Wrap.Wrap;
|
||||
element.style.alignItems = Align.Center;
|
||||
element.style.marginTop = 2f;
|
||||
element.style.marginBottom = 6f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-card"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Column;
|
||||
element.style.alignItems = Align.FlexStart;
|
||||
element.style.width = rootMainMenu ? 680f : 540f;
|
||||
element.style.marginBottom = 18f;
|
||||
element.style.paddingTop = 0f;
|
||||
element.style.paddingBottom = 2f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-metric") || element.ClassListContains("eve-field"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
element.style.alignItems = Align.Center;
|
||||
element.style.width = rootMainMenu ? 320f : 520f;
|
||||
element.style.marginBottom = 5f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-kind-control-text"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
element.style.alignItems = Align.Center;
|
||||
element.style.width = rootMainMenu ? 520f : 520f;
|
||||
element.style.marginBottom = rootMainMenu ? 6f : 10f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.ClassListContains("eve-surface-root") || element.ClassListContains("eve-kind-surface"))
|
||||
{
|
||||
element.style.flexDirection = FlexDirection.Column;
|
||||
element.style.alignItems = Align.FlexStart;
|
||||
element.style.width = rootMainMenu ? 680f : 560f;
|
||||
return;
|
||||
}
|
||||
|
||||
element.style.flexDirection = FlexDirection.Column;
|
||||
element.style.alignItems = Align.FlexStart;
|
||||
}
|
||||
|
||||
private static void StyleMenuLabel(Label label, bool rootMainMenu)
|
||||
{
|
||||
label.style.color = new Color(0.86f, 0.98f, 1f, 0.94f);
|
||||
label.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.whiteSpace = WhiteSpace.Normal;
|
||||
label.style.marginLeft = 0f;
|
||||
label.style.marginTop = 0f;
|
||||
label.style.marginBottom = 0f;
|
||||
|
||||
if (label.ClassListContains("eve-title"))
|
||||
{
|
||||
label.style.fontSize = rootMainMenu ? 24f : 24f;
|
||||
label.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
label.style.marginTop = rootMainMenu ? 0f : 2f;
|
||||
label.style.marginBottom = rootMainMenu ? 0f : 10f;
|
||||
label.style.maxWidth = rootMainMenu ? 620f : 520f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (label.ClassListContains("eve-muted"))
|
||||
{
|
||||
label.style.fontSize = rootMainMenu ? 18f : 15f;
|
||||
label.style.color = new Color(0.78f, 0.92f, 0.98f, 0.84f);
|
||||
label.style.width = rootMainMenu ? 120f : 190f;
|
||||
label.style.marginRight = 12f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (label.ClassListContains("eve-value"))
|
||||
{
|
||||
label.style.fontSize = rootMainMenu ? 20f : 16f;
|
||||
label.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
label.style.maxWidth = rootMainMenu ? 360f : 300f;
|
||||
return;
|
||||
}
|
||||
|
||||
label.style.fontSize = rootMainMenu ? 24f : 16f;
|
||||
label.style.maxWidth = rootMainMenu ? 620f : 520f;
|
||||
label.style.marginBottom = rootMainMenu ? 0f : 10f;
|
||||
}
|
||||
|
||||
private static void StyleMenuTextField(TextField field, bool rootMainMenu)
|
||||
{
|
||||
field.style.width = rootMainMenu ? 360f : 520f;
|
||||
field.style.height = rootMainMenu ? 30f : 28f;
|
||||
field.style.marginLeft = 0f;
|
||||
field.style.marginTop = 0f;
|
||||
field.style.marginBottom = rootMainMenu ? 4f : 8f;
|
||||
field.style.color = new Color(0.86f, 0.98f, 1f, 0.96f);
|
||||
field.style.fontSize = rootMainMenu ? 18f : 15f;
|
||||
field.pickingMode = PickingMode.Position;
|
||||
|
||||
field.labelElement.style.minWidth = rootMainMenu ? 100f : 190f;
|
||||
field.labelElement.style.width = rootMainMenu ? 100f : 190f;
|
||||
field.labelElement.style.color = new Color(0.78f, 0.92f, 0.98f, 0.84f);
|
||||
}
|
||||
|
||||
private static void StyleMenuButton(UiButton button, bool rootMainMenu)
|
||||
{
|
||||
button.style.backgroundColor = new Color(0f, 0f, 0f, 0f);
|
||||
button.style.borderLeftWidth = 0f;
|
||||
button.style.borderRightWidth = 0f;
|
||||
button.style.borderTopWidth = 0f;
|
||||
button.style.borderBottomWidth = 0f;
|
||||
button.style.color = new Color(0.86f, 0.98f, 1f, 0.96f);
|
||||
button.style.fontSize = rootMainMenu ? 24f : 16f;
|
||||
button.style.unityFontStyleAndWeight = FontStyle.Normal;
|
||||
button.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
button.style.width = rootMainMenu ? 220f : 230f;
|
||||
button.style.height = rootMainMenu ? 32f : 24f;
|
||||
button.style.marginLeft = 0f;
|
||||
button.style.marginTop = 0f;
|
||||
button.style.marginRight = rootMainMenu ? 0f : 14f;
|
||||
button.style.marginBottom = rootMainMenu ? 0f : 4f;
|
||||
button.style.paddingLeft = 0f;
|
||||
button.style.paddingRight = 0f;
|
||||
button.style.paddingTop = 0f;
|
||||
button.style.paddingBottom = 0f;
|
||||
button.style.letterSpacing = 0f;
|
||||
button.focusable = true;
|
||||
button.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
private void RegisterHoverButtons(VisualElement root)
|
||||
{
|
||||
foreach (var button in FindButtons(root))
|
||||
{
|
||||
var hover = new MenuHoverButton(button);
|
||||
_hoverButtons.Add(hover);
|
||||
button.RegisterCallback<PointerEnterEvent>(_ => hover.Hovering = true);
|
||||
button.RegisterCallback<PointerLeaveEvent>(_ => hover.Hovering = false);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<UiButton> FindButtons(VisualElement root)
|
||||
{
|
||||
if (root == null)
|
||||
yield break;
|
||||
|
||||
if (root is UiButton button)
|
||||
yield return button;
|
||||
|
||||
foreach (var child in root.Children())
|
||||
{
|
||||
foreach (var nested in FindButtons(child))
|
||||
yield return nested;
|
||||
}
|
||||
}
|
||||
|
||||
private static VisualElement FindFirstKind(VisualElement root, string kind)
|
||||
{
|
||||
if (root == null)
|
||||
return null;
|
||||
|
||||
if (root.ClassListContains($"eve-kind-{kind}"))
|
||||
return root;
|
||||
|
||||
foreach (var child in root.Children())
|
||||
{
|
||||
var match = FindFirstKind(child, kind);
|
||||
if (match != null)
|
||||
return match;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static VisualElement FindElement(VisualElement root, string name)
|
||||
{
|
||||
if (root == null)
|
||||
return null;
|
||||
|
||||
if (string.Equals(root.name, name, StringComparison.Ordinal))
|
||||
return root;
|
||||
|
||||
foreach (var child in root.Children())
|
||||
{
|
||||
var match = FindElement(child, name);
|
||||
if (match != null)
|
||||
return match;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void HandleSettingsSurfaceCommand(EveSurfaceCommandRequest request)
|
||||
|
|
@ -261,16 +640,16 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowPlayerSettings:
|
||||
ShowPlayerSettingsSurface();
|
||||
ShowPlayerSettingsSurface(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowVerseSettings:
|
||||
ShowVerseSettingsSurface();
|
||||
ShowVerseSettingsSurface(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ShowInputSettings:
|
||||
ShowInputSettings();
|
||||
ShowInputSettings(true);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToMain:
|
||||
ShowMain();
|
||||
ShowMain(false);
|
||||
return;
|
||||
default:
|
||||
Debug.LogWarning($"Unhandled settings menu command kind: {command.Kind}");
|
||||
|
|
@ -289,12 +668,12 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.OpenRuntimeInputScreen:
|
||||
if (!TryOpenRuntimeInputScreen())
|
||||
{
|
||||
ShowInputSettings();
|
||||
ShowInputSettings(false);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -315,11 +694,11 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.PlayerSettingsCommand:
|
||||
SendKnownAetheriaEveCommand(request, "player-settings");
|
||||
ShowPlayerSettingsSurface();
|
||||
ShowPlayerSettingsSurface(false);
|
||||
return;
|
||||
default:
|
||||
Debug.LogWarning($"Unhandled player-settings command kind: {command.Kind}");
|
||||
|
|
@ -338,15 +717,15 @@ public class MainMenu : MonoBehaviour
|
|||
switch (command.Kind)
|
||||
{
|
||||
case AetheriaRuntimeMainMenuCommandKind.BackToSettings:
|
||||
ShowSettings();
|
||||
ShowSettings(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.ClientTargetCommand:
|
||||
RequestClientTargetCommand(request);
|
||||
ShowVerseSettingsSurface();
|
||||
ShowVerseSettingsSurface(false);
|
||||
return;
|
||||
case AetheriaRuntimeMainMenuCommandKind.VerseHostCommand:
|
||||
SendKnownAetheriaEveCommand(request, "Verse-host");
|
||||
ShowVerseSettingsSurface();
|
||||
ShowVerseSettingsSurface(false);
|
||||
return;
|
||||
default:
|
||||
Debug.LogWarning($"Unhandled verse-settings command kind: {command.Kind}");
|
||||
|
|
@ -356,10 +735,8 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
private void HideMenuSurface()
|
||||
{
|
||||
if (_menuSurfaceDocument == null)
|
||||
return;
|
||||
|
||||
AetheriaEveUnitySurfaceHost.Hide(_menuSurfaceDocument);
|
||||
AetheriaEveUnitySurfaceHost.Hide(_currentMenuSurfaceDocument);
|
||||
AetheriaEveUnitySurfaceHost.Hide(_nextMenuSurfaceDocument);
|
||||
}
|
||||
|
||||
public void SetRuntimeInputScreenShell(Func<bool> canOpenRuntimeInputScreen, Action openRuntimeInputScreen)
|
||||
|
|
@ -446,10 +823,28 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_menuSurfaceDocument != null)
|
||||
if (_currentMenuSurfaceDocument != null)
|
||||
{
|
||||
Destroy(_menuSurfaceDocument.gameObject);
|
||||
_menuSurfaceDocument = null;
|
||||
Destroy(_currentMenuSurfaceDocument.gameObject);
|
||||
_currentMenuSurfaceDocument = null;
|
||||
}
|
||||
|
||||
if (_nextMenuSurfaceDocument != null)
|
||||
{
|
||||
Destroy(_nextMenuSurfaceDocument.gameObject);
|
||||
_nextMenuSurfaceDocument = null;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class MenuHoverButton
|
||||
{
|
||||
public MenuHoverButton(UiButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
|
||||
public UiButton Button { get; }
|
||||
public bool Hovering { get; set; }
|
||||
public float Lerp { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ using System.Linq;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.RenderGraphModule;
|
||||
|
||||
/// <summary>
|
||||
/// Based on github.com/yangrc1234/VolumeCloud
|
||||
|
|
@ -33,11 +35,11 @@ public class HaltonSequence
|
|||
/// <summary>
|
||||
/// Cloud renderer post processing.
|
||||
/// </summary>
|
||||
[ImageEffectAllowedInSceneView]
|
||||
[ExecuteInEditMode,RequireComponent(typeof(Camera))]
|
||||
[ImageEffectOpaque]
|
||||
public class VolumeCloudRenderer : EffectBase
|
||||
{
|
||||
private static readonly Dictionary<Camera, VolumeCloudRenderer> RenderersByCamera = new Dictionary<Camera, VolumeCloudRenderer>();
|
||||
|
||||
[Header("Render Settings")]
|
||||
[Range(0, 2)]
|
||||
public int downSample = 1;
|
||||
|
|
@ -50,16 +52,73 @@ public class VolumeCloudRenderer : EffectBase
|
|||
private Matrix4x4 prevV;
|
||||
private Camera mcam;
|
||||
private HaltonSequence sequence = new HaltonSequence() { radix = 3 };
|
||||
private const int TemporalHistoryVersion = 4;
|
||||
private int appliedTemporalHistoryVersion = -1;
|
||||
// The index of 4x4 pixels.
|
||||
private int frameIndex = 0;
|
||||
private bool firstFrame = true;
|
||||
private AetheriaClientState _runtimeState;
|
||||
private int _debugRenderCount;
|
||||
private int _debugLastRenderFrame = -1;
|
||||
|
||||
[SerializeField]
|
||||
private Shader cloudShader;
|
||||
|
||||
[SerializeField]
|
||||
private Texture2D ditherTexture;
|
||||
|
||||
public static bool TryGetRenderer(Camera camera, out VolumeCloudRenderer renderer)
|
||||
{
|
||||
renderer = null;
|
||||
return camera != null
|
||||
&& RenderersByCamera.TryGetValue(camera, out renderer)
|
||||
&& renderer != null
|
||||
&& renderer.isActiveAndEnabled;
|
||||
}
|
||||
|
||||
public int DebugRenderCount => _debugRenderCount;
|
||||
public int DebugLastRenderFrame => _debugLastRenderFrame;
|
||||
public RenderTexture DebugUndersampleBuffer => undersampleBuffer;
|
||||
public RenderTexture DebugHistoryBuffer => fullBuffer != null && fullBuffer.Length > 0 ? fullBuffer[fullBufferIndex] : null;
|
||||
public RenderTexture DebugCurrentCloudBuffer => fullBuffer != null && fullBuffer.Length > 1 ? fullBuffer[fullBufferIndex ^ 1] : null;
|
||||
public bool DebugFirstFrame => firstFrame;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
var camera = GetComponent<Camera>();
|
||||
if (camera != null)
|
||||
RenderersByCamera[camera] = this;
|
||||
ResetTemporalHistory();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
var camera = GetComponent<Camera>();
|
||||
if (camera != null && RenderersByCamera.TryGetValue(camera, out var renderer) && renderer == this)
|
||||
RenderersByCamera.Remove(camera);
|
||||
}
|
||||
|
||||
void EnsureMaterial(bool force = false) {
|
||||
if (cloudShader == null)
|
||||
cloudShader = Shader.Find("Aetheria/CloudShader");
|
||||
|
||||
if (mat == null || force) {
|
||||
mat = new Material(cloudShader);
|
||||
ResetTemporalHistory();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetTemporalHistory()
|
||||
{
|
||||
firstFrame = true;
|
||||
appliedTemporalHistoryVersion = TemporalHistoryVersion;
|
||||
if (fullBuffer != null)
|
||||
{
|
||||
for (var i = 0; i < fullBuffer.Length; i++)
|
||||
{
|
||||
if (fullBuffer[i] != null)
|
||||
fullBuffer[i].DiscardContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,8 +153,8 @@ public class VolumeCloudRenderer : EffectBase
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentPlayerSettings("unity-volume-cloud-renderer");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-volume-cloud-renderer");
|
||||
return _runtimeState.PlayerSettings.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -105,31 +164,73 @@ public class VolumeCloudRenderer : EffectBase
|
|||
return null;
|
||||
}
|
||||
|
||||
[ImageEffectOpaque]
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination) {
|
||||
if (cloudShader == null) {
|
||||
Graphics.Blit(source, destination);
|
||||
return;
|
||||
}
|
||||
|
||||
public void RenderClouds(UnsafeCommandBuffer cmd, Camera camera, TextureHandle colorTarget, TextureHandle depthTarget)
|
||||
{
|
||||
mcam = GetComponent<Camera>();
|
||||
if (camera != mcam || cloudShader == null)
|
||||
return;
|
||||
|
||||
_debugRenderCount++;
|
||||
_debugLastRenderFrame = Time.frameCount;
|
||||
|
||||
var width = mcam.pixelWidth >> downSample;
|
||||
var height = mcam.pixelHeight >> downSample;
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
this.EnsureMaterial();
|
||||
EnsureMaterial();
|
||||
EnsureDitherTexture();
|
||||
|
||||
if (appliedTemporalHistoryVersion != TemporalHistoryVersion)
|
||||
ResetTemporalHistory();
|
||||
|
||||
EnsureArray(ref fullBuffer, 2);
|
||||
firstFrame |= EnsureRenderTarget(ref fullBuffer[0], width, height, RenderTextureFormat.ARGBFloat, FilterMode.Bilinear);
|
||||
firstFrame |= EnsureRenderTarget(ref fullBuffer[1], width, height, RenderTextureFormat.ARGBFloat, FilterMode.Bilinear);
|
||||
firstFrame |= EnsureRenderTarget(ref undersampleBuffer, width , height, RenderTextureFormat.ARGBFloat, FilterMode.Bilinear);
|
||||
firstFrame |= EnsureRenderTarget(ref undersampleBuffer, width, height, RenderTextureFormat.ARGBFloat, FilterMode.Bilinear);
|
||||
|
||||
frameIndex = (frameIndex + 1)% 16;
|
||||
frameIndex = (frameIndex + 1) % 16;
|
||||
fullBufferIndex = (fullBufferIndex + 1) % 2;
|
||||
|
||||
/* Some code is from playdead TAA. */
|
||||
ApplyQualityKeywords();
|
||||
|
||||
//1. Pass1, Render a undersampled buffer. The buffer is dithered using blue noise and halton sequence.
|
||||
//If it's first frame, force a high quality sample to make the initial history buffer good enough.
|
||||
var gpuProjection = GL.GetGPUProjectionMatrix(mcam.projectionMatrix, true);
|
||||
mat.SetMatrix("_CamInvProj", (gpuProjection * mcam.worldToCameraMatrix).inverse);
|
||||
mat.SetVector("_ProjectionExtents", mcam.GetProjectionExtents());
|
||||
mat.SetFloat("_RaymarchOffset", sequence.Get());
|
||||
mat.SetVector("_TexelSize", undersampleBuffer.texelSize);
|
||||
mat.SetFloat("_ResetHistory", firstFrame ? 1.0f : 0.0f);
|
||||
|
||||
mat.SetTexture("_UndersampleCloudTex", undersampleBuffer);
|
||||
mat.SetMatrix("_PrevVP", gpuProjection * prevV);
|
||||
|
||||
cmd.SetRenderTarget(undersampleBuffer);
|
||||
cmd.SetViewport(new Rect(0, 0, width, height));
|
||||
cmd.ClearRenderTarget(false, true, Color.clear);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, mat, 0, MeshTopology.Triangles, 3, 1);
|
||||
|
||||
mat.SetTexture("_MainTex", firstFrame ? undersampleBuffer : fullBuffer[fullBufferIndex]);
|
||||
|
||||
cmd.SetRenderTarget(fullBuffer[fullBufferIndex ^ 1]);
|
||||
cmd.SetViewport(new Rect(0, 0, width, height));
|
||||
cmd.ClearRenderTarget(false, true, Color.clear);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, mat, 1, MeshTopology.Triangles, 3, 1);
|
||||
|
||||
mat.SetTexture("_CloudTex", fullBuffer[fullBufferIndex ^ 1]);
|
||||
|
||||
if (depthTarget.IsValid())
|
||||
cmd.SetRenderTarget(colorTarget, depthTarget);
|
||||
else
|
||||
cmd.SetRenderTarget(colorTarget);
|
||||
cmd.SetViewport(mcam.pixelRect);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, mat, 2, MeshTopology.Triangles, 3, 1);
|
||||
|
||||
prevV = mcam.worldToCameraMatrix;
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
private void ApplyQualityKeywords()
|
||||
{
|
||||
if (firstFrame || quality == Quality.Ultra) {
|
||||
mat.EnableKeyword("ULTRA_QUALITY");
|
||||
mat.DisableKeyword("HIGH_QUALITY");
|
||||
|
|
@ -151,30 +252,22 @@ public class VolumeCloudRenderer : EffectBase
|
|||
mat.DisableKeyword("MEDIUM_QUALITY");
|
||||
mat.EnableKeyword("LOW_QUALITY");
|
||||
}
|
||||
|
||||
mat.SetMatrix("_CamInvProj", (Camera.current.projectionMatrix * Camera.current.worldToCameraMatrix).inverse);
|
||||
mat.SetVector("_ProjectionExtents", mcam.GetProjectionExtents());
|
||||
mat.SetFloat("_RaymarchOffset", sequence.Get());
|
||||
mat.SetVector("_TexelSize", undersampleBuffer.texelSize);
|
||||
|
||||
Graphics.Blit(null, undersampleBuffer, mat, 0);
|
||||
|
||||
//2. Pass 2, blend undersampled image with history buffer to new buffer.
|
||||
mat.SetTexture("_UndersampleCloudTex", undersampleBuffer);
|
||||
mat.SetMatrix("_PrevVP", GL.GetGPUProjectionMatrix(mcam.projectionMatrix,false) * prevV);
|
||||
mat.SetVector("_ProjectionExtents", mcam.GetProjectionExtents());
|
||||
|
||||
if (firstFrame) { //Wait, is this the first frame? If it is, the history buffer is empty yet. It will cause glitch if we use it directly. Fill it using the undersample buffer.
|
||||
Graphics.Blit(undersampleBuffer, fullBuffer[fullBufferIndex]);
|
||||
}
|
||||
Graphics.Blit(fullBuffer[fullBufferIndex], fullBuffer[fullBufferIndex ^ 1], mat, 1);
|
||||
|
||||
//3. Pass3, Calculate lighting, blend final cloud image with final image.
|
||||
mat.SetTexture("_CloudTex", fullBuffer[fullBufferIndex ^ 1]);
|
||||
Graphics.Blit(source, destination, mat, 2);
|
||||
|
||||
//4. Cleanup
|
||||
prevV = mcam.worldToCameraMatrix;
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
private void EnsureDitherTexture()
|
||||
{
|
||||
if (ditherTexture == null)
|
||||
ditherTexture = Resources.Load<Texture2D>("LDR_LLL1_0");
|
||||
|
||||
if (ditherTexture == null)
|
||||
return;
|
||||
|
||||
Shader.SetGlobalTexture("_DitheringTex", ditherTexture);
|
||||
Shader.SetGlobalVector("_DitheringCoords", new Vector4(
|
||||
(float)Math.Max(1, Screen.width) / ditherTexture.width,
|
||||
(float)Math.Max(1, Screen.height) / ditherTexture.height,
|
||||
0,
|
||||
0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using UnityEngine.Rendering;
|
|||
using UnityEngine.Serialization;
|
||||
using static Unity.Mathematics.math;
|
||||
using static Unity.Mathematics.noise;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Drives the volume render.
|
||||
|
|
@ -19,6 +20,7 @@ using static Unity.Mathematics.noise;
|
|||
[RequireComponent( typeof( Camera ) )]
|
||||
public class VolumeSampling : MonoBehaviour
|
||||
{
|
||||
private static readonly List<VolumeSampling> ActiveSamplers = new List<VolumeSampling>();
|
||||
public Transform GridMesh;
|
||||
public Camera GridCamera;
|
||||
public GameSettings Settings;
|
||||
|
|
@ -29,16 +31,58 @@ public class VolumeSampling : MonoBehaviour
|
|||
public RenderTexture NebulaTint;
|
||||
public AetheriaUnityRenderSplatViewportSource SplatViewportSource;
|
||||
public AetheriaRenderSplatLayerRenderer SplatLayerRenderer;
|
||||
public AetheriaSceneRenderSplatSource SceneSplatSource;
|
||||
|
||||
[SerializeField]
|
||||
private bool useRuntimeRenderSplats;
|
||||
|
||||
[SerializeField]
|
||||
private bool renderSplatsEveryFrame;
|
||||
|
||||
[SerializeField]
|
||||
private float splatRenderIntervalSeconds = 0.25f;
|
||||
|
||||
private MeshRenderer _gridMeshRenderer;
|
||||
private float _flowScroll;
|
||||
private Transform _gridTransform;
|
||||
private Camera _ownerCamera;
|
||||
private Vector2 _lastSplatCenter;
|
||||
private Vector2 _lastSplatSize;
|
||||
private Vector2 _publishedSplatCenter;
|
||||
private Vector2 _publishedSplatSize;
|
||||
private float _nextSplatRenderTime;
|
||||
private bool _hasRenderedSplats;
|
||||
private GlobalKeyword _keywordFlowGlobal;
|
||||
private GlobalKeyword _keywordFlowSlope;
|
||||
private GlobalKeyword _keywordNoiseSlope;
|
||||
|
||||
public static void RenderForCamera(Camera camera)
|
||||
{
|
||||
if (camera == null)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < ActiveSamplers.Count; i++)
|
||||
{
|
||||
var sampler = ActiveSamplers[i];
|
||||
if (sampler != null && sampler.TargetsCamera(camera))
|
||||
sampler.RenderSamplingPass();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!ActiveSamplers.Contains(this))
|
||||
ActiveSamplers.Add(this);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
ActiveSamplers.Remove(this);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_ownerCamera = GetComponent<Camera>();
|
||||
_keywordFlowGlobal = GlobalKeyword.Create("FLOW_GLOBAL");
|
||||
_keywordFlowSlope = GlobalKeyword.Create("FLOW_SLOPE");
|
||||
_keywordNoiseSlope = GlobalKeyword.Create("NOISE_SLOPE");
|
||||
|
|
@ -53,12 +97,28 @@ public class VolumeSampling : MonoBehaviour
|
|||
{
|
||||
if(_gridTransform==null)
|
||||
_gridTransform = GridCamera?.transform;
|
||||
// Shader needs to know the position and scale of cameras used to render input textures
|
||||
if(GridCamera != null)
|
||||
Shader.SetGlobalVector("_GridTransform", new Vector4(_gridTransform.position.x,_gridTransform.position.z,GridCamera.orthographicSize*2));
|
||||
|
||||
RenderSplatTextures();
|
||||
_flowScroll += Settings.DefaultEnvironment.Flow.GlobalScrollSpeed * Time.deltaTime;
|
||||
UpdateGridMeshBounds();
|
||||
}
|
||||
|
||||
private bool TargetsCamera(Camera camera)
|
||||
{
|
||||
_ownerCamera ??= GetComponent<Camera>();
|
||||
return camera == _ownerCamera;
|
||||
}
|
||||
|
||||
private void RenderSamplingPass()
|
||||
{
|
||||
if (_gridTransform == null)
|
||||
_gridTransform = GridCamera?.transform;
|
||||
|
||||
RenderSplatTexturesIfNeeded();
|
||||
PublishSamplingGlobals();
|
||||
}
|
||||
|
||||
private void UpdateGridMeshBounds()
|
||||
{
|
||||
var environment = Settings.DefaultEnvironment;
|
||||
|
||||
if (GridMesh != null)
|
||||
|
|
@ -70,7 +130,19 @@ public class VolumeSampling : MonoBehaviour
|
|||
// GridMesh.position = new Vector3(_gridTransform.position.x, environment.Grid.Offset, _gridTransform.position.z);
|
||||
// GridMesh.localScale = new Vector3(GridCamera.orthographicSize, 1, GridCamera.orthographicSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PublishSamplingGlobals()
|
||||
{
|
||||
var environment = Settings.DefaultEnvironment;
|
||||
|
||||
ResolveSplatViewport(out var center, out var size);
|
||||
_publishedSplatCenter = center;
|
||||
_publishedSplatSize = size;
|
||||
|
||||
// Shader sampling must use the same world-space viewport that produced the splat textures.
|
||||
Shader.SetGlobalVector("_GridTransform", new Vector4(center.x, center.y, size.x));
|
||||
|
||||
// Volumetric sampling parameters are used by several shaders
|
||||
Shader.SetGlobalTexture("_NebulaSurfaceHeight", NebulaSurfaceHeight);
|
||||
Shader.SetGlobalTexture("_NebulaPatchHeight", NebulaPatchHeight);
|
||||
|
|
@ -105,7 +177,6 @@ public class VolumeSampling : MonoBehaviour
|
|||
Shader.SetGlobalFloat("_FlowAmplitude", environment.Flow.GlobalAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSlopeAmplitude", environment.Flow.SlopeAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSwirlAmplitude", environment.Flow.SwirlAmplitude);
|
||||
_flowScroll += environment.Flow.GlobalScrollSpeed * Time.deltaTime;
|
||||
Shader.SetGlobalFloat("_FlowScroll", _flowScroll);
|
||||
Shader.SetGlobalFloat("_FlowPeriod", environment.Flow.Period);
|
||||
|
||||
|
|
@ -114,20 +185,33 @@ public class VolumeSampling : MonoBehaviour
|
|||
Shader.SetKeyword(_keywordNoiseSlope, environment.Noise.SlopeExponent != 0);
|
||||
}
|
||||
|
||||
private void RenderSplatTextures()
|
||||
private void RenderSplatTexturesIfNeeded()
|
||||
{
|
||||
ResolveSplatRenderers();
|
||||
if (SplatViewportSource == null)
|
||||
if (SplatLayerRenderer == null)
|
||||
return;
|
||||
|
||||
var size = GridCamera != null
|
||||
? new Vector2(GridCamera.orthographicSize * 2, GridCamera.orthographicSize * 2)
|
||||
: new Vector2(1024, 1024);
|
||||
var center = _gridTransform != null
|
||||
? new Vector2(_gridTransform.position.x, _gridTransform.position.z)
|
||||
: Vector2.zero;
|
||||
SplatViewportSource.SetViewport(center, size);
|
||||
SplatViewportSource.RenderLatest();
|
||||
ResolveSplatViewport(out var center, out var size);
|
||||
var document = ResolveSceneSplatDocument(center, size);
|
||||
if (document == null && useRuntimeRenderSplats)
|
||||
document = ResolveRuntimeSplatDocument(center, size);
|
||||
if (document == null)
|
||||
return;
|
||||
|
||||
var viewportChanged = !_hasRenderedSplats ||
|
||||
!Approximately(center, _lastSplatCenter) ||
|
||||
!Approximately(size, _lastSplatSize);
|
||||
var intervalElapsed = Time.unscaledTime >= _nextSplatRenderTime;
|
||||
if (!renderSplatsEveryFrame && !viewportChanged && !intervalElapsed)
|
||||
return;
|
||||
|
||||
SplatLayerRenderer.Render(document, Mathf.RoundToInt(size.x), Mathf.RoundToInt(size.y));
|
||||
_lastSplatCenter = center;
|
||||
_lastSplatSize = size;
|
||||
_publishedSplatCenter = center;
|
||||
_publishedSplatSize = size;
|
||||
_nextSplatRenderTime = Time.unscaledTime + Mathf.Max(0.02f, splatRenderIntervalSeconds);
|
||||
_hasRenderedSplats = true;
|
||||
|
||||
if (SplatLayerRenderer == null)
|
||||
return;
|
||||
|
|
@ -138,6 +222,52 @@ public class VolumeSampling : MonoBehaviour
|
|||
NebulaTint = ResolveLayerTexture(AetheriaRuntimeRenderSplatLayerKeys.FogTint, NebulaTint);
|
||||
}
|
||||
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument ResolveSceneSplatDocument(Vector2 center, Vector2 size)
|
||||
{
|
||||
if (SceneSplatSource == null)
|
||||
SceneSplatSource = GetComponent<AetheriaSceneRenderSplatSource>();
|
||||
return SceneSplatSource != null
|
||||
? SceneSplatSource.BuildDocument(BuildViewportBounds(center, size))
|
||||
: null;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument ResolveRuntimeSplatDocument(Vector2 center, Vector2 size)
|
||||
{
|
||||
if (SplatViewportSource == null)
|
||||
return null;
|
||||
|
||||
SplatViewportSource.SetViewport(center, size);
|
||||
return SplatViewportSource.CurrentDocument;
|
||||
}
|
||||
|
||||
private void ResolveSplatViewport(out Vector2 center, out Vector2 size)
|
||||
{
|
||||
size = GridCamera != null
|
||||
? new Vector2(GridCamera.orthographicSize * 2, GridCamera.orthographicSize * 2)
|
||||
: new Vector2(1024, 1024);
|
||||
center = _gridTransform != null
|
||||
? new Vector2(_gridTransform.position.x, _gridTransform.position.z)
|
||||
: Vector2.zero;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRtsViewportBounds BuildViewportBounds(Vector2 center, Vector2 size)
|
||||
{
|
||||
var halfSize = size * 0.5f;
|
||||
return new AetheriaRuntimeRtsViewportBounds
|
||||
{
|
||||
MinX = center.x - halfSize.x,
|
||||
MinY = center.y - halfSize.y,
|
||||
MaxX = center.x + halfSize.x,
|
||||
MaxY = center.y + halfSize.y
|
||||
};
|
||||
}
|
||||
|
||||
private static bool Approximately(Vector2 lhs, Vector2 rhs)
|
||||
{
|
||||
return Mathf.Abs(lhs.x - rhs.x) < 0.001f &&
|
||||
Mathf.Abs(lhs.y - rhs.y) < 0.001f;
|
||||
}
|
||||
|
||||
private RenderTexture ResolveLayerTexture(string layerKey, RenderTexture fallback)
|
||||
{
|
||||
return SplatLayerRenderer.TryGetTexture(layerKey, out var texture) && texture != null
|
||||
|
|
@ -152,9 +282,13 @@ public class VolumeSampling : MonoBehaviour
|
|||
if (SplatLayerRenderer == null)
|
||||
SplatLayerRenderer = gameObject.AddComponent<AetheriaRenderSplatLayerRenderer>();
|
||||
|
||||
if (!useRuntimeRenderSplats)
|
||||
return;
|
||||
|
||||
if (SplatViewportSource == null)
|
||||
SplatViewportSource = GetComponent<AetheriaUnityRenderSplatViewportSource>();
|
||||
if (SplatViewportSource == null)
|
||||
SplatViewportSource = gameObject.AddComponent<AetheriaUnityRenderSplatViewportSource>();
|
||||
SplatViewportSource.RenderInLateUpdate = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Cinemachine;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Object = UnityEngine.Object;
|
||||
|
|
@ -29,6 +30,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public CinemachineVirtualCamera SceneCamera;
|
||||
public Camera[] FogCameras;
|
||||
public Camera[] MinimapCameras;
|
||||
private AetheriaClientState _runtimeState;
|
||||
public bool UseRenderSplatTextureLayers = true;
|
||||
public Material FogMaterial;
|
||||
public float FogFarFadeFraction = .125f;
|
||||
|
|
@ -1199,8 +1201,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.CurrentCatalog("unity-zone-renderer");
|
||||
_runtimeState ??= AetheriaUnityRuntimeClientProvider.RuntimeState("unity-zone-renderer");
|
||||
return _runtimeState.Catalog.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue