update dream world spawn animator

This commit is contained in:
JohnCorby 2022-03-26 10:14:55 -07:00
parent ab95b419aa
commit b1093b162f
2 changed files with 6 additions and 27 deletions

View File

@ -35,7 +35,7 @@ internal class EnterDreamWorldMessage : QSBWorldObjectMessage<QSBDreamLanternIte
player.AssignedSimulationLantern = WorldObject;
// do the spawn shader
player.SetVisible(false, 0);
player.SetVisible(false);
player.SetVisible(true, DreamWorldSpawnAnimator.DREAMWORLD_SPAWN_TIME);
player.DreamWorldSpawnAnimator.StartSpawnEffect();
}

View File

@ -1,10 +1,4 @@
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine;
namespace QSB.PlayerBodySetup.Remote;
@ -14,37 +8,22 @@ public class DreamWorldSpawnAnimator : MonoBehaviour
private Transform _bodyRoot;
private float _progression;
private OWRenderer[] _renderers;
private Renderer[] _renderers;
private Material _spawnEffectMaterial;
public const float DREAMWORLD_SPAWN_TIME = 2f;
private void Awake()
{
_renderers = GetComponentsInChildren<Renderer>(true)
.Select(x => x.gameObject.GetAddComponent<OWRenderer>())
.ToArray();
_renderers = GetComponentsInChildren<Renderer>(true);
enabled = false;
foreach (var renderer in _renderers)
{
if (renderer is null)
{
DebugLog.ToConsole($"Error - A renderer found on {gameObject.name} is null!", OWML.Common.MessageType.Error);
continue;
}
foreach (var material in renderer.sharedMaterials)
{
if (material is null)
if (material == null)
{
DebugLog.ToConsole($"Error - A material on renderer {renderer.name} is null!", OWML.Common.MessageType.Error);
continue;
}
if (material.shader is null)
{
DebugLog.ToConsole($"Error - The shader on material {material.name}, attached to renderer {renderer.name}, is null!", OWML.Common.MessageType.Error);
continue;
}
@ -71,7 +50,7 @@ public class DreamWorldSpawnAnimator : MonoBehaviour
{
_spawnEffectMaterial.SetVector("_BodyPosition", _bodyRoot.position);
_progression = Mathf.MoveTowards(_progression, 4, (4 * Time.deltaTime) / DREAMWORLD_SPAWN_TIME);
_progression = Mathf.MoveTowards(_progression, 4, 4 * Time.deltaTime / DREAMWORLD_SPAWN_TIME);
if (OWMath.ApproxEquals(_progression, 4))
{