Files
cloud-mainworld/ufm cloud/Library/Artifacts/00/004f9959a50fa5e674edc761efdb1514
T

91 lines
6.1 KiB
Plaintext
Raw Normal View History

2026-10-21 20:35:53 +01:00

2026-10-24 12:03:45 +01:00
aP
2026-10-21 20:35:53 +01:00
 0.0.0þÿÿÿÿÿ0v²,¾|pØäA Ê@Ã3Ë7€ÿÿÿÿ€¦€²€E€ Þ€)€.€2€;a€ Þ€)€.€2€†€r€ Þ€) €.€2
€H€«€ÿÿÿÿ €1€1€ÿÿÿÿ @Þ€€
Q€j€ñ€PÿÿÿÿÀ1€1€ÿÿÿÿ€Þ€€€j€ÿÿÿÿ€b›€ÿÿÿÿ€H€xÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€H€}ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€H€†ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€y€
2026-10-24 12:03:45 +01:00
€ Þ€)!€.€2"€€‹ÿÿÿÿ#@1€1€ÿÿÿÿ$Þ€€%.€j€&H€™ÿÿÿÿ'€1€1€ÿÿÿÿ(@Þ€€)Q€j€*H€¤ÿÿÿÿ+€1€1€ÿÿÿÿ,@Þ€€-Q€j€.H€¶ÿÿÿÿ/€1€1€ÿÿÿÿ0@Þ€€1Q€j€2TextScriptImporterPPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_UsedFileIDsm_UserDatam_AssetBundleNamem_AssetBundleVariant1ÿÿeF¼_1Ch_Þ‰Ž$=O€7€ÿÿÿÿ€¦€²€E€ Þ€€.€€(a€ Þ€€.€€†€r€ Þ€ €.€
€H€«€ÿÿÿÿ €1€1€ÿÿÿÿ @Þ€€
Q€j€H€ê€ÿÿÿÿ€1€1€ÿÿÿÿ@Þ€€Q€j€PPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>H ÄJP`
 ÄJ-SomniumWeatherIntegration.cs._20260801-031835ý using UnityEngine;
using SomniumSpace.Bridge;
namespace SomniumSpace.Worlds.TheCloud.Pkg_bentlybro_bentlyweather
{
/// <summary>
/// Optional Somnium glue for <see cref="SkyWeather"/>. Add it next to a SkyWeather.
/// - Registers our skybox + sun with Somnium's environment system (cooperative, so the
/// host environment is aware of them) via ISomniumEnvironment.
/// - Makes rain/snow follow the local player's head once Somnium spawns it.
///
/// Time and weather are kept in sync across players by SkyWeather's shared deterministic
/// clock (no networking needed), so this component does NOT need to send anything.
/// It runs only in Play mode and safely no-ops outside a Somnium session.
/// </summary>
[AddComponentMenu("Bently/Somnium Weather Integration")]
[RequireComponent(typeof(SkyWeather))]
[DisallowMultipleComponent]
public class SomniumWeatherIntegration : MonoBehaviour
{
[Tooltip("Tell Somnium's environment system about our skybox + sun (cooperative).")]
public bool registerEnvironment = true;
[Tooltip("Make rain/snow follow the local player's head once it spawns.")]
public bool followLocalPlayer = true;
SkyWeather _sky;
WeatherParticles _particles;
bool _envDone;
float _retry;
void Awake()
{
_sky = GetComponent<SkyWeather>();
_particles = GetComponentInChildren<WeatherParticles>(true);
}
void Update()
{
// Throttle: Somnium objects appear a moment after join, so retry once a second.
_retry -= Time.unscaledDeltaTime;
if (_retry > 0f) return;
_retry = 1f;
if (registerEnvironment && !_envDone) TryRegisterEnvironment();
if (followLocalPlayer) TryFollowLocalPlayer();
}
void TryRegisterEnvironment()
{
try
{
var env = SomniumBridge.Environment;
if (env == null) return;
if (RenderSettings.skybox != null) env.SetSkybox(RenderSettings.skybox);
if (_sky != null && _sky.sunLight != null) env.SetSunSource(_sky.sunLight);
env.UpdateEnvironment();
_envDone = true;
}
catch { /* not in a Somnium session / bridge not ready */ }
}
void TryFollowLocalPlayer()
{
if (_particles == null)
{
_particles = GetComponentInChildren<WeatherParticles>(true);
if (_particles == null) return;
}
if (_particles.followTarget != null) return;
try
{
var pc = SomniumBridge.PlayersContainer;
if (pc == null) return;
var lp = pc.LocalPlayer;
if (lp == null) return;
var refs = lp.References;
if (refs == null || refs.Body == null) return;
Transform head = refs.Body.Head != null ? refs.Body.Head : refs.Body.Root;
if (head != null) _particles.followTarget = head;
}
catch { /* bridge not ready */ }
}