42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using Assets.MyGame.Scripts.Net.API.UserData_SubClass;
|
|
using System.Collections.Generic;
|
|
using Unity.Burst;
|
|
using Unity.Collections;
|
|
using Unity.Jobs;
|
|
using UnityEngine;
|
|
|
|
[BurstCompile]
|
|
public struct FishSpawnTimerJob : IJob
|
|
{
|
|
public float deltaTime;
|
|
public NativeArray<float> timers; // 每条鱼的计时器
|
|
static List<float> spawnTimes = new List<float>();
|
|
public NativeArray<float> frequencies; // 每条鱼的频率
|
|
public NativeArray<int> shouldSpawn; // 输出:是否应该生成
|
|
//public NativeHashMap<int, bool> keyValues;
|
|
|
|
|
|
public void Execute()
|
|
{
|
|
|
|
for (int i = 0; i < timers.Length; i++)
|
|
{
|
|
if (shouldSpawn[i] == 0)
|
|
{
|
|
if (timers[i] <= 10000)
|
|
{
|
|
timers[i] += deltaTime;
|
|
}
|
|
|
|
|
|
if (timers[i] >= frequencies[i])
|
|
{
|
|
timers[i] = 0;
|
|
if (shouldSpawn[i] == 0)
|
|
shouldSpawn[i] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|