Players mistook a plain Wood chest for the Eldividarkista, so neither Alfar chest looks like a buildable vanilla chest any more. Eldividarkista: the Mistlands dvergr crate stretched to 1.6 x 0.8 m, blackened iron with a bronze frame and an iron grate on the front. The grate glows and throws sparks only while the chest holds wood the drones may burn. Inngangskista: the dvergr town loot chest, navy steel with silver trim. A cyan line in the lid shines while it holds anything but the sigil. Both have new hammer icons, and their hover names say their role (input, fuel) in English, Italian and Russian. If a borrowed vanilla model is missing, the chest falls back to the old tinted wood chest. scripts/paint_*_chest.py repaint the textures and render previews and icons offline with scripts/render_obj.py.
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// The light on the two Alfar chests, which says whether the drones have work there: the fire
|
|
/// chest's grate burns while it holds wood they may burn, the entry chest's inlay shines while it
|
|
/// holds anything but the sigil. Every client asks its own copy of the inventory, which Container
|
|
/// keeps in step with the ZDO, so nothing travels over the network for it.
|
|
/// </summary>
|
|
public class AlfarChestGlow : MonoBehaviour
|
|
{
|
|
public Renderer[] Glows;
|
|
public ParticleSystem Embers;
|
|
public Color GlowColor;
|
|
public bool WoodOnly;
|
|
|
|
private Container m_container;
|
|
private Material m_lit;
|
|
private Material m_cold;
|
|
private bool? m_shown;
|
|
private float m_nextCheck;
|
|
|
|
private void Awake()
|
|
{
|
|
m_container = GetComponent<Container>();
|
|
if (Glows == null || Glows.Length == 0 || Glows[0] == null) return;
|
|
|
|
m_cold = Glows[0].sharedMaterial;
|
|
m_lit = new Material(m_cold) { name = m_cold.name + "_lit" };
|
|
m_lit.color = Color.black;
|
|
m_lit.EnableKeyword("_EMISSION");
|
|
m_lit.SetColor("_EmissionColor", GlowColor);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Time.time < m_nextCheck) return;
|
|
m_nextCheck = Time.time + 1f;
|
|
|
|
bool lit = HasWork();
|
|
if (m_shown == lit) return;
|
|
m_shown = lit;
|
|
|
|
if (m_lit != null)
|
|
{
|
|
foreach (Renderer glow in Glows)
|
|
{
|
|
if (glow != null) glow.sharedMaterial = lit ? m_lit : m_cold;
|
|
}
|
|
}
|
|
if (Embers != null)
|
|
{
|
|
if (lit) Embers.Play(true);
|
|
else Embers.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
|
}
|
|
}
|
|
|
|
private bool HasWork()
|
|
{
|
|
Inventory inventory = m_container != null ? m_container.GetInventory() : null;
|
|
if (inventory == null) return false;
|
|
|
|
foreach (ItemDrop.ItemData item in inventory.GetAllItems())
|
|
{
|
|
if (item == null || item.m_dropPrefab == null) continue;
|
|
|
|
string name = item.m_dropPrefab.name;
|
|
if (WoodOnly ? AlfarDroneAI.IsWood(name) : name != AlfarSigil.PrefabName) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (m_lit != null) Destroy(m_lit);
|
|
}
|
|
}
|
|
}
|