您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
1.0 KiB
26 行
1.0 KiB
using Unity.Entities;
|
|
using Unity.Mathematics;
|
|
using Unity.Transforms;
|
|
using Unity.Collections;
|
|
|
|
namespace Unity.MegaCity.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// Job to handle the vehicle roll.
|
|
/// </summary>
|
|
[WithAll(typeof(Simulate))]
|
|
internal partial struct VehicleRollJob : IJobEntity
|
|
{
|
|
[ReadOnly] public ComponentLookup<VehicleBraking> VehicleBrakingLookup;
|
|
[ReadOnly] public ComponentLookup<VehicleRoll> VehicleRollLookup;
|
|
|
|
public void Execute(ref LocalTransform transform, in PlayerVehicleCosmeticPhysics cosmetic)
|
|
{
|
|
var vehicleBraking = VehicleBrakingLookup[cosmetic.VehicleEntity];
|
|
var vehicleRoll = VehicleRollLookup[cosmetic.VehicleEntity];
|
|
var roll = vehicleRoll.ManualRollValue != 0 ? vehicleRoll.ManualRollValue : vehicleRoll.BankAmount;
|
|
var eulerZXY = math.radians(new float3(vehicleBraking.PitchPseudoBraking, vehicleBraking.YawBreakRotation, roll));
|
|
transform.Rotation = quaternion.EulerZXY(eulerZXY);
|
|
}
|
|
}
|
|
}
|