Files
beyond/Assets/Scripts/Grid/ResourceSpawnerDB.cs
2024-11-20 15:21:28 +01:00

50 lines
1.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Beyond
{
[CreateAssetMenu(fileName = "ResourceSpawnerDB", menuName = "Beyond/ResourceSpawnerDB", order = 1)]
public class ResourceSpawnerDB : ScriptableObject
{
[SerializeField] private List<SerializedStreamedItem> m_serializedItems;
public List<SerializedStreamedItem> Items => m_serializedItems;
[Tooltip("Overal density scaling parameter - 0, nothing will be dropperd, 1 maximum drop after brighness and maturity influence")]
public float density = 1.0f;
[Tooltip("How much does brightness below 50 affects density? 0 - none, 1, nothing will be dropped for brighness of 0")]
public float negativeBrightnessFactor = 0.5f;
[Tooltip("How much does brightness above 50 affects density? 0 - none, 1 double drop for brightness of 100")]
public float positiveBrightnessFactor = 0.5f;
[Tooltip("How much signe level of maturity affects density?")]
public float maturityFactor = 0.01f;
public float offset = 0f;
public GameObject[] resourceObjectsRoot;
public GameObject basePrefab;
public bool m_autoDisableObjects = true;
[Button]
void CopyDataFromResouces()
{
m_serializedItems = new List<SerializedStreamedItem>();
foreach ( var r in resourceObjectsRoot)
{
if (r != null)
{
for (int i = 0; i < r.transform.childCount; i++)
{
var t = r.transform.GetChild(i);
m_serializedItems.Add(new SerializedStreamedItem(basePrefab, t));
}
}
if (m_autoDisableObjects)
r.SetActive(false);
}
}
}
}