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

35 行
1.2 KiB

using Unity.Entities;
using Unity.NetCode;
using Unity.NetCode.Extensions;
namespace Unity.MegaCity.Gameplay
{
/// <summary>
/// Handles shooting on the server
/// </summary>
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
public partial struct ShootingSystemServer : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<NetworkTime>();
}
public void OnUpdate(ref SystemState state)
{
var netTime = SystemAPI.GetSingleton<NetworkTime>();
var shootingJob = new ApplyingDamageAndPointsJob
{
DamagePerSecond = 50f,
DeltaTime = SystemAPI.Time.DeltaTime,
PredictingTick = netTime.ServerTick,
healthLookup = SystemAPI.GetComponentLookup<VehicleHealth>(),
playerPointsLookUp = SystemAPI.GetComponentLookup<PlayerScore>(),
playerNameLookup = SystemAPI.GetComponentLookup<PlayerName>(),
immunityLookup = SystemAPI.GetComponentLookup<Immunity>(),
};
state.Dependency = shootingJob.Schedule(state.Dependency);
}
}
}