SanAndreasUnity/Assets/Scripts/Behaviours/World/LightSource.cs
in0finite 28316f720a ...
2021-06-26 00:58:25 +02:00

28 lines
932 B
C#

using SanAndreasUnity.Importing.RenderWareStream;
using SanAndreasUnity.Utilities;
using UnityEngine;
namespace SanAndreasUnity.Behaviours.World
{
public class LightSource : MonoBehaviour
{
public TwoDEffect.Light LightInfo { get; private set; }
public static LightSource Create(
Transform parent,
TwoDEffect.Light lightInfo)
{
var go = Instantiate(Cell.Instance.lightSourcePrefab, parent);
go.transform.localPosition = lightInfo.Position;
go.transform.localScale = Vector3.one * lightInfo.CoronaSize * Cell.Instance.lightScaleMultiplier;
var lightSource = go.GetComponentOrThrow<LightSource>();
lightSource.LightInfo = lightInfo;
var spriteRenderer = go.GetComponentOrThrow<SpriteRenderer>();
spriteRenderer.color = lightInfo.Color;
return lightSource;
}
}
}