58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Convention;
|
|
using UnityEngine;
|
|
using System;
|
|
using Unity.Collections;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace Demo.Game
|
|
{
|
|
public class DDT : ScriptableObject
|
|
{
|
|
protected override bool IsSelfEnableUpdate => false;
|
|
public static DDT Make()
|
|
{
|
|
return new GameObject().AddComponent<DDT>();
|
|
}
|
|
|
|
public NativeArray<float> Datas = new(128, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
|
public int Count { get; private set; } = 0;
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public void Add(float value)
|
|
{
|
|
if (Count >= Datas.Length)
|
|
Datas.ResizeArray(Mathf.FloorToInt(Count * 1.5f));
|
|
Datas[Count] = value;
|
|
Count++;
|
|
}
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public void Add(int barSplitTimes, int barCount, int tickCount)
|
|
{
|
|
Add((barCount + tickCount / (float)barSplitTimes) * OneBarTime);
|
|
}
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public float At(int index)
|
|
{
|
|
if (index < 0)
|
|
index = Count + index;
|
|
if (index < 0 || index >= Count)
|
|
throw new IndexOutOfRangeException($"{index} is out of [0, {Count})");
|
|
return Datas[index];
|
|
}
|
|
|
|
/// <summary>
|
|
/// »ñÈ¡Êý¾Ý³¤¶È
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public int GetCount()
|
|
{
|
|
return Count;
|
|
}
|
|
}
|
|
}
|