Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at each engine boundary: FieldDriver, GuidedProjectile(Manager), EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance, ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace, MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math calls that were handed Unity vectors now take converted values; Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's Vector3.Dot on float3s becomes dot. packages-lock.json records the cultmath git package at f0605367 and demotes com.unity.mathematics to a transitive dependency. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3dc00e1225
commit
2281793154
17 changed files with 86 additions and 63 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using CultMath;
|
||||
using CultMath.UnityBridge;
|
||||
using static CultMath.math;
|
||||
using Random = UnityEngine.Random;
|
||||
using static Noise1D;
|
||||
|
|
@ -71,18 +72,18 @@ public class GuidedProjectile : MonoBehaviour
|
|||
StartCoroutine(FadeOut());
|
||||
return;
|
||||
}
|
||||
var position = (float3) t.position;
|
||||
var position = t.position.ToCultMath();
|
||||
|
||||
var targetPosition = TargetPosition?.Invoke() ?? Target.position;
|
||||
_targetVelocity = lerp(_targetVelocity, targetPosition - _previousTargetPosition, saturate(Time.deltaTime * 5));
|
||||
_targetVelocity = lerp(_targetVelocity.ToCultMath(), (targetPosition - _previousTargetPosition).ToCultMath(), saturate(Time.deltaTime * 5)).ToUnity();
|
||||
_previousTargetPosition = targetPosition;
|
||||
targetPosition = AetheriaMath.FirstOrderIntercept(position,float3.zero, TopSpeed, targetPosition, _targetVelocity);
|
||||
targetPosition = AetheriaMath.FirstOrderIntercept(position,float3.zero, TopSpeed, targetPosition.ToCultMath(), _targetVelocity.ToCultMath()).ToUnity();
|
||||
|
||||
var diff = targetPosition - transform.position;
|
||||
var targetDist = diff.magnitude;
|
||||
var sourceDist = length(StartPosition.xz - position.xz);
|
||||
|
||||
if (sourceDist > Range || dot(diff,Velocity) < 0)
|
||||
if (sourceDist > Range || dot(diff.ToCultMath(), Velocity.ToCultMath()) < 0)
|
||||
{
|
||||
StartCoroutine(FadeOut());
|
||||
if (HitEffect != null)
|
||||
|
|
@ -97,8 +98,8 @@ public class GuidedProjectile : MonoBehaviour
|
|||
var targetDistFlat = diff.Flatland().magnitude;
|
||||
var curveLerp = 1 - targetDistFlat / (sourceDist + targetDistFlat);
|
||||
var dir = diff.normalized;
|
||||
var right = cross(dir, float3(0, 1, 0));
|
||||
var up = cross(dir, right);
|
||||
var right = cross(dir.ToCultMath(), float3(0, 1, 0));
|
||||
var up = cross(dir.ToCultMath(), right);
|
||||
|
||||
if (Children > 0 && SplitTime < curveLerp)
|
||||
{
|
||||
|
|
@ -107,9 +108,9 @@ public class GuidedProjectile : MonoBehaviour
|
|||
var child = ChildProjectile.Instantiate<GuidedProjectile>();
|
||||
child.transform.position = t.position;
|
||||
child.StartPosition = StartPosition;
|
||||
var randomDirection = normalize(Random.insideUnitCircle);
|
||||
var randomDirection = normalize(Random.insideUnitCircle.ToCultMath());
|
||||
var perpendicularRandom = randomDirection.x * right + randomDirection.y * up;
|
||||
child.Velocity = normalize(lerp(perpendicularRandom, dir, SplitSeparationForwardness)) * length(Velocity) * SplitSeparationVelocity;
|
||||
child.Velocity = (normalize(lerp(perpendicularRandom, dir.ToCultMath(), SplitSeparationForwardness)) * length(Velocity.ToCultMath()) * SplitSeparationVelocity).ToUnity();
|
||||
child.Range = Range;
|
||||
child.Damage = Damage / Children;
|
||||
child.Penetration = Penetration;
|
||||
|
|
@ -136,7 +137,7 @@ public class GuidedProjectile : MonoBehaviour
|
|||
|
||||
var dodge = normalize(lerp(
|
||||
normalize(right * noise(Time.time * Frequency + _phase) + up * noise(Time.time * Frequency + (100 + _phase))),
|
||||
Vector3.up, LiftCurve.Evaluate(curveLerp)));
|
||||
float3(0, 1, 0), LiftCurve.Evaluate(curveLerp))).ToUnity();
|
||||
var desired = Vector3.Slerp(dodge, dir, GuidanceCurve.Evaluate(curveLerp)).normalized * TopSpeed;
|
||||
var thrustCurve = ThrustCurve.Evaluate(curveLerp);
|
||||
var thrust = Thrust * thrustCurve;
|
||||
|
|
|
|||
Loading…
Reference in a new issue