Megacity demo game for UOS
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

40 行
1.3 KiB

using Unity.Burst;
using Unity.Entities;
using Unity.NetCode;
using Unity.Physics;
using static Unity.Entities.SystemAPI;
namespace Unity.MegaCity.Gameplay
{
/// <summary>
/// Handles shooting
/// </summary>
[UpdateInGroup(typeof(PredictedSimulationSystemGroup))]
public partial struct ShootingSystem : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<NetworkTime>();
state.RequireForUpdate<PhysicsWorldHistorySingleton>();
state.RequireForUpdate<PhysicsWorldSingleton>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var netTime = GetSingleton<NetworkTime>();
if (!netTime.IsFirstTimeFullyPredictingTick)
return;
var laserJob = new LaserJob
{
CollisionHistory = GetSingleton<PhysicsWorldHistorySingleton>(),
PhysicsWorld = GetSingleton<PhysicsWorldSingleton>().PhysicsWorld,
DeltaTime = Time.DeltaTime,
PredictingTick = netTime.ServerTick,
healthLookup = GetComponentLookup<VehicleHealth>()
};
state.Dependency = laserJob.ScheduleParallel(state.Dependency);
}
}
}