refactor modules

This commit is contained in:
2023-03-22 17:03:55 +01:00
parent 52cf3a7fbd
commit 128ab216d2
503 changed files with 1835 additions and 379 deletions

View File

@@ -0,0 +1,43 @@
using System;
using NaughtyAttributes;
using Station46.Runtime;
using UnityEngine;
namespace Station46.Dispenser.Scripts
{
[Serializable]
public struct DispenserLightRow
{
public bool[] lights;
}
/// <summary>
/// This component controls the grid of lights on the dispenser.
/// </summary>
public class DispenserLights : MonoBehaviour
{
[Tooltip("Control the pattern of lights on a dispenser.")]
[SerializeField]
private DispenserLightRow[] lights;
[BoxGroup("Internal")] [SerializeField]
private GameObject lightPrefab;
[BoxGroup("Internal")] [SerializeField]
private Vector2Int gridDimensions;
[BoxGroup("Internal")] [SerializeField]
private Vector2 lightOffset;
private void Start()
{
for (var y = 0; y < gridDimensions.y; y++)
{
var row = lights[y].lights;
for (var x = 0; x < gridDimensions.x; x++)
{
var instance = Instantiate(lightPrefab, transform, false);
instance.transform.localPosition = new Vector3(-x * lightOffset.x, 0, y * lightOffset.y);
instance.GetComponent<Emission>().active = row[x];
}
}
}
}
}