Netcode Bootstrap

This commit is contained in:
Luis Gonzalez
2026-05-31 14:27:52 -07:00
parent 99d8d2d2a9
commit 7fa77ce821
1813 changed files with 2921554 additions and 84 deletions
@@ -0,0 +1,55 @@
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka.Samples
{
[BurstCompile]
[WorldSystemFilter(WorldSystemFilterFlags.LocalSimulation | WorldSystemFilterFlags.ClientSimulation)]
partial class DistanceBasedMixedModeAnimatorSystem: SystemBase
{
public float switchDistance;
/////////////////////////////////////////////////////////////////////////////////
[BurstCompile]
[WithOptions(EntityQueryOptions.IgnoreComponentEnabledState)]
partial struct AnimatorSwitchJob: IJobEntity
{
public float3 refPose;
public float switchDistance;
void Execute(EnabledRefRW<GPUAnimationEngineTag> gt, in LocalTransform lt)
{
var dv = refPose - lt.Position;
var d = math.length(dv);
gt.ValueRW = d > switchDistance;
}
}
/////////////////////////////////////////////////////////////////////////////////
protected override void OnCreate()
{
Enabled = false;
}
/////////////////////////////////////////////////////////////////////////////////
protected override void OnUpdate()
{
var switchJob = new AnimatorSwitchJob()
{
refPose = Camera.main.transform.position,
switchDistance = switchDistance
};
switchJob.ScheduleParallel();
}
}
}