Add canonical Aetheria Unity client
This commit is contained in:
parent
7c9e4cf37d
commit
27720f080b
34 changed files with 682 additions and 1 deletions
63
Aetheria.Unity/Assets/AetheriaUnityClient.cs
Normal file
63
Aetheria.Unity/Assets/AetheriaUnityClient.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using GameCult.Eve.UnityScene;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class AetheriaUnityClient : MonoBehaviour
|
||||
{
|
||||
private EveUnityCultMeshPlayableWorldProvider _provider;
|
||||
private EveUnityPlayableWorldClientBootstrap _bootstrap;
|
||||
private string _status = "Starting EveUnity...";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Application.runInBackground = true;
|
||||
var endpoint = Environment.GetEnvironmentVariable("EVEUNITY_RENDEZVOUS_ENDPOINT") ?? "rudp://127.0.0.1:3076";
|
||||
var surfaceId = Environment.GetEnvironmentVariable("EVEUNITY_SURFACE_ID") ?? "aetheria.pilot";
|
||||
var replicaPath = Path.Combine(Application.persistentDataPath, "aetheria-unity.cc");
|
||||
|
||||
CreateView();
|
||||
_provider = gameObject.AddComponent<EveUnityCultMeshPlayableWorldProvider>();
|
||||
_provider.Configure(
|
||||
endpoint,
|
||||
replicaPath,
|
||||
surfaceId: surfaceId,
|
||||
requiredSurfaceKind: "interactive-world",
|
||||
clientRuntimeId: "aetheria-unity");
|
||||
_bootstrap = gameObject.AddComponent<EveUnityPlayableWorldClientBootstrap>();
|
||||
_bootstrap.ConfigureProvider(_provider);
|
||||
StartCoroutine(ConnectAfterFirstFrame());
|
||||
}
|
||||
|
||||
private IEnumerator ConnectAfterFirstFrame()
|
||||
{
|
||||
yield return null;
|
||||
_status = "Connecting to the advertised Eve surface...";
|
||||
yield return null;
|
||||
var presentation = _bootstrap.Mount();
|
||||
_status = $"Connected: {_provider.Selection.ProviderId} / {_provider.Selection.SurfaceId} / {presentation.ActiveEntities} entities";
|
||||
}
|
||||
|
||||
private static void CreateView()
|
||||
{
|
||||
var cameraObject = new GameObject("Main Camera") { tag = "MainCamera" };
|
||||
var camera = cameraObject.AddComponent<Camera>();
|
||||
camera.clearFlags = CameraClearFlags.SolidColor;
|
||||
camera.backgroundColor = new Color(0.025f, 0.035f, 0.055f);
|
||||
camera.nearClipPlane = 0.05f;
|
||||
camera.farClipPlane = 10000f;
|
||||
|
||||
var lightObject = new GameObject("World Light");
|
||||
var light = lightObject.AddComponent<Light>();
|
||||
light.type = LightType.Directional;
|
||||
light.intensity = 1.4f;
|
||||
lightObject.transform.rotation = Quaternion.Euler(50f, -35f, 0f);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUI.Box(new Rect(12, 12, Math.Min(Screen.width - 24, 760), 54),
|
||||
_status + "\nWASD / left stick: move Mouse 1 / controller action: activate");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue