Initial Upload;
This commit is contained in:
17
Runtime/Models/VolumeEntity.cs
Normal file
17
Runtime/Models/VolumeEntity.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace Misaki.AoVolume
|
||||
{
|
||||
internal readonly struct VolumeEntity
|
||||
{
|
||||
private const int _INVALID_INDEX = -1;
|
||||
|
||||
public readonly int entityIndex;
|
||||
public readonly bool IsValid => entityIndex != _INVALID_INDEX;
|
||||
|
||||
public static readonly VolumeEntity InvalidEntity = new(_INVALID_INDEX);
|
||||
|
||||
public VolumeEntity(int index)
|
||||
{
|
||||
entityIndex = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Models/VolumeEntity.cs.meta
Normal file
2
Runtime/Models/VolumeEntity.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de5e2eab102d42b4fa1e2b7a06810b4d
|
||||
39
Runtime/Models/VolumeObject.cs
Normal file
39
Runtime/Models/VolumeObject.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.AoVolume
|
||||
{
|
||||
internal abstract class VolumeObject : MonoBehaviour
|
||||
{
|
||||
private VolumeEntity _entity = VolumeEntity.InvalidEntity;
|
||||
|
||||
public VolumeData data;
|
||||
|
||||
protected virtual void InitializeEntity()
|
||||
{
|
||||
if (_entity.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_entity = VolumeDatabase.Instance.CreateEntity(this);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
InitializeEntity();
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_entity.IsValid)
|
||||
{
|
||||
VolumeDatabase.Instance.DestroyEntity(_entity);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Models/VolumeObject.cs.meta
Normal file
2
Runtime/Models/VolumeObject.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 410059065965c744db4523b0dec8a3aa
|
||||
Reference in New Issue
Block a user