Spaces:
Runtime error
Runtime error
File size: 1,028 Bytes
ce81a16 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
using System;
using System.Collections.Generic;
using Photon.Deterministic;
namespace Quantum
{
unsafe partial struct Chain
{
public void Update(FrameThreadSafe frame, ref ChainSystem.Filter filter)
{
FPVector3 direction = filter.Transform->Position - LastPosition;
Alpha = direction.Magnitude / DistanceThreshold;
// cycle element
if (Alpha > FP._1)
{
Alpha = Alpha % FP._1;
AddBreadCrumb(direction);
}
filter.Body->Drag = MinDrag + Count * DragPerItem;
if (filter.Drivable->Grounded == false) filter.Body->GravityScale = FP._1;
filter.Drivable->Grounded = false;
#if DEBUG
for (int i = 0; i < Positions.Length; i++)
{
Draw.Sphere(Positions[i], FP._0_10, ColorRGBA.ColliderBlue);
}
#endif
}
public void AddBreadCrumb(FPVector3 direction)
{
FPVector3 newPosition = LastPosition + direction.Normalized * DistanceThreshold;
*Positions.GetPointer(Current) = newPosition;
Current = (Current + 1) % Positions.Length;
LastPosition = newPosition;
}
}
}
|