您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
38 行
1.3 KiB
38 行
1.3 KiB
using Unity.Entities;
|
|
using Unity.Transforms;
|
|
using Unity.Mathematics;
|
|
using Unity.Physics;
|
|
using static Unity.Entities.SystemAPI;
|
|
|
|
namespace Unity.MegaCity.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// System to handle shooting presentation
|
|
/// </summary>
|
|
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
|
|
[UpdateInGroup(typeof(PresentationSystemGroup))]
|
|
public partial struct ShootingPresentationSystem : ISystem
|
|
{
|
|
public void OnUpdate(ref SystemState state)
|
|
{
|
|
if (!LaserPool.Instance)
|
|
return;
|
|
|
|
LaserPool.Instance.BeginUpdate();
|
|
foreach (var (laser, localTrans, velocity) in
|
|
Query<RefRO<VehicleLaser>, RefRO<LocalTransform>, RefRO<PhysicsVelocity>>())
|
|
{
|
|
if (math.all(laser.ValueRO.HitPoint == default) || laser.ValueRO.Energy <= 0)
|
|
continue;
|
|
|
|
var forward = math.mul(localTrans.ValueRO.Rotation, math.normalize(new float3(0, 2, 25)));
|
|
|
|
var startPoint = localTrans.ValueRO.Position + forward * 5;
|
|
var currentSpeed = math.length(velocity.ValueRO.Linear);
|
|
LaserPool.Instance.AddLine(startPoint, laser.ValueRO.HitPoint, currentSpeed);
|
|
}
|
|
|
|
LaserPool.Instance.EndUpdate();
|
|
}
|
|
}
|
|
}
|