2026-08-10 14:57:50 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UniRx;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using CultMath;
|
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>
2026-09-14 17:47:33 +02:00
|
|
|
|
using CultMath.UnityBridge;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using static CultMath.math;
|
2021-01-05 02:56:17 +00:00
|
|
|
|
using UnityEngine;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using float2 = CultMath.float2;
|
2021-01-05 02:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
public class HullCollider : MonoBehaviour
|
|
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public Subject<HullHitEventArgs> Hit = new Subject<HullHitEventArgs>();
|
|
|
|
|
|
public Subject<HullSplashEventArgs> Splash = new Subject<HullSplashEventArgs>();
|
|
|
|
|
|
|
2021-01-05 02:56:17 +00:00
|
|
|
|
public Entity Entity { get; set; }
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
public void SendHit(float damage, float penetration, float spread, DamageType damageType, Entity source, Vector2 texCoord, Vector3 direction)
|
2021-01-05 02:56:17 +00:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
Hit.OnNext(new HullHitEventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
Damage = damage,
|
|
|
|
|
|
Penetration = penetration,
|
|
|
|
|
|
Spread = spread,
|
|
|
|
|
|
DamageType = damageType,
|
|
|
|
|
|
Source = source,
|
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>
2026-09-14 17:47:33 +02:00
|
|
|
|
TexCoord = texCoord.ToCultMath(),
|
|
|
|
|
|
Direction = direction.ToCultMath()
|
2026-08-10 14:57:50 +01:00
|
|
|
|
});
|
2021-01-05 02:56:17 +00:00
|
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
public void SendSplash(float damage, DamageType damageType, Entity source, Vector3 direction)
|
2021-02-01 08:13:14 +00:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
Splash.OnNext(new HullSplashEventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
Damage = damage,
|
|
|
|
|
|
DamageType = damageType,
|
|
|
|
|
|
Source = source,
|
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>
2026-09-14 17:47:33 +02:00
|
|
|
|
Direction = direction.ToCultMath()
|
2026-08-10 14:57:50 +01:00
|
|
|
|
});
|
2021-02-01 08:13:14 +00:00
|
|
|
|
}
|
2021-02-26 19:01:47 +00:00
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
|
private void OnCollisionEnter(Collision other)
|
2021-02-26 19:01:47 +00:00
|
|
|
|
{
|
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>
2026-09-14 17:47:33 +02:00
|
|
|
|
Entity.Velocity += other.impulse.ToCultMath().xz / Time.deltaTime;
|
2021-02-26 19:01:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public class HullHitEventArgs
|
2021-01-05 02:56:17 +00:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public float Damage;
|
|
|
|
|
|
public float Penetration;
|
|
|
|
|
|
public float Spread;
|
|
|
|
|
|
public DamageType DamageType;
|
|
|
|
|
|
public Entity Source;
|
|
|
|
|
|
public float2 TexCoord;
|
|
|
|
|
|
public float3 Direction;
|
2021-01-05 02:56:17 +00:00
|
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
public class HullSplashEventArgs
|
2021-02-01 08:13:14 +00:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public float Damage;
|
|
|
|
|
|
public DamageType DamageType;
|
|
|
|
|
|
public Entity Source;
|
|
|
|
|
|
public float3 Direction;
|
2021-02-01 08:13:14 +00:00
|
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
|
}
|