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

39 行
1.5 KiB

using Unity.Burst;
using Unity.Entities;
using Unity.NetCode;
using Unity.Physics.Systems;
namespace Unity.MegaCity.Gameplay
{
/// <summary>
/// Schedule the necessary job to process the user inputs and move the player accordingly
/// </summary>
[BurstCompile]
[UpdateInGroup(typeof(BeforePhysicsSystemGroup))]
public partial struct PlayerVehicleControlSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<NetworkTime>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var deltaTime = state.WorldUnmanaged.Time.DeltaTime;
var thrustJob = new ThrustJob {DeltaTime = deltaTime};
var bankingJob = new VehicleBankingJob();
var breakingJob = new VehicleBreakingPseudoPhysicsJob {DeltaTime = deltaTime};
var moveJob = new MoveJob {DeltaTime = deltaTime, Tick = SystemAPI.GetSingleton<NetworkTime>().ServerTick};
var autoLevelJob = new AutoLevelJob {DeltaTime = deltaTime};
state.Dependency = thrustJob.ScheduleParallel(state.Dependency);
state.Dependency = bankingJob.ScheduleParallel(state.Dependency);
state.Dependency = breakingJob.ScheduleParallel(state.Dependency);
state.Dependency = moveJob.ScheduleParallel(state.Dependency);
state.Dependency = autoLevelJob.ScheduleParallel(state.Dependency);
}
}
}