From d687e275d8b969205044d3bf1dba3143ccecc9f9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 01:38:18 +0100 Subject: [PATCH] Delete Unity weapon effect authority --- Aetheria.State.Verify/Program.cs | 114 +--- .../Physics/AetheriaYmirPhysicsBridge.cs | 645 +----------------- .../Scripts/Gameplay/Weapons/ConstantLaser.cs | 106 --- .../Gameplay/Weapons/ConstantLaser.cs.meta | 11 - .../Gameplay/Weapons/ConstantLaserManager.cs | 32 - .../Weapons/ConstantLaserManager.cs.meta | 11 - .../Gameplay/Weapons/ConstantLightning.cs | 87 --- .../Weapons/ConstantLightning.cs.meta | 11 - .../Weapons/ConstantLightningManager.cs | 29 - .../Weapons/ConstantLightningManager.cs.meta | 3 - .../Weapons/ConstantParticleWeapon.cs | 71 -- .../Weapons/ConstantParticleWeapon.cs.meta | 3 - .../Weapons/ConstantParticleWeaponManager.cs | 32 - .../ConstantParticleWeaponManager.cs.meta | 3 - .../Weapons/ConstantWeaponEffectManager.cs | 9 - .../ConstantWeaponEffectManager.cs.meta | 11 - .../Scripts/Gameplay/Weapons/HitscanEffect.cs | 89 --- .../Gameplay/Weapons/HitscanEffect.cs.meta | 11 - .../Gameplay/Weapons/HitscanManager.cs | 23 - .../Gameplay/Weapons/HitscanManager.cs.meta | 3 - Assets/Scripts/Gameplay/Weapons/Laser.cs | 68 -- Assets/Scripts/Gameplay/Weapons/Laser.cs.meta | 11 - .../Scripts/Gameplay/Weapons/LaserManager.cs | 23 - .../Gameplay/Weapons/LaserManager.cs.meta | 11 - Assets/Scripts/Gameplay/Weapons/Lightning.cs | 77 --- .../Gameplay/Weapons/Lightning.cs.meta | 11 - .../Gameplay/Weapons/LightningGunManager.cs | 21 - .../Weapons/LightningGunManager.cs.meta | 11 - docs/aetheria-current-codebase-model.md | 26 +- 29 files changed, 62 insertions(+), 1501 deletions(-) delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/HitscanManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/HitscanManager.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/Laser.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/Laser.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/LaserManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/LaserManager.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/Lightning.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/Lightning.cs.meta delete mode 100644 Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs delete mode 100644 Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs.meta diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 5c0c7cf19..3d9a8867b 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -17031,61 +17031,15 @@ static void RequireUnityPhysicsIsNotGameplayAuthority(string root) var ymirBridgePath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Physics", "AetheriaYmirPhysicsBridge.cs"); var projectilePath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "Projectile.cs"); - var laserPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "Laser.cs"); - var laserManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "LaserManager.cs"); - var constantLaserPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantLaser.cs"); - var constantLaserManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantLaserManager.cs"); - var hitscanPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "HitscanEffect.cs"); - var hitscanManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "HitscanManager.cs"); var clickRaycasterPath = Path.Combine(root, "Assets", "Scripts", "UI", "ClickRaycaster.cs"); var requiredSymbols = new Dictionary { [ymirBridgePath] = new[] { - "YmirPhysicsQueries.OverlapSphere(", - "YmirPhysicsQueries.CastSphere(request)", - "YmirPhysicsQueries.OverlapCircle(request)", - "YmirPhysicsQueries.CastCircle(request)", - "TryCastZoneHulls(", - "TryBuildDaemonWorld(", - "private const string DaemonEntityBodyPrefix = \"aetheria.daemon.entity.\"", - "id = DaemonEntityBodyPrefix + daemonEntityIndex", - "TryResolveDaemonEntityHull(zoneRenderer, hit.bodyId, out var hull)", - "TryResolveTargetDaemonHull(target, hit.bodyId, out var hull)", - "TargetDaemonEntityIndex(", - "onlyDaemonEntityIndex.HasValue && onlyDaemonEntityIndex.Value != daemonEntityIndex", - "TryParseDaemonEntityBodyId(" - }, - [laserPath] = new[] - { - "public ZoneRenderer ZoneRenderer { get; set; }", - "AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls", - "ZoneRenderer," - }, - [laserManagerPath] = new[] - { - "p.ZoneRenderer = source.ZoneRenderer" - }, - [constantLaserPath] = new[] - { - "public ZoneRenderer ZoneRenderer { get; set; }", - "AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls", - "ZoneRenderer," - }, - [constantLaserManagerPath] = new[] - { - "p.ZoneRenderer = source.ZoneRenderer" - }, - [hitscanPath] = new[] - { - "public ZoneRenderer ZoneRenderer { get; set; }", - "AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls", - "ZoneRenderer," - }, - [hitscanManagerPath] = new[] - { - "p.ZoneRenderer = source.ZoneRenderer" + "public bool TryCastClickables(", + "YmirPhysicsQueries.CastSphere(new YmirSphereCastRequest", + "private readonly Dictionary _clickableBodyMap" }, [clickRaycasterPath] = new[] { @@ -17107,7 +17061,7 @@ static void RequireUnityPhysicsIsNotGameplayAuthority(string root) if (missingSymbols.Length > 0) { throw new InvalidOperationException( - "Ymir gameplay query bridge is incomplete: " + + "Ymir presentation picking bridge is incomplete: " + string.Join("; ", missingSymbols)); } @@ -17133,7 +17087,7 @@ static void RequireUnityPhysicsIsNotGameplayAuthority(string root) if (ymirTransportHits.Length > 0) { throw new InvalidOperationException( - "Ymir gameplay queries must use the typed query surface, not a local HTTP transport shortcut: " + + "Ymir presentation queries must use the typed query surface, not a local HTTP transport shortcut: " + string.Join("; ", ymirTransportHits)); } @@ -17143,7 +17097,20 @@ static void RequireUnityPhysicsIsNotGameplayAuthority(string root) Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ProjectileManager.cs"), Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "GuidedProjectile.cs"), Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "GuidedProjectileManager.cs"), - Path.Combine(root, "Assets", "Scripts", "Gameplay", "Physics", "YmirUnityRuntimeProofTests.cs") + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Physics", "YmirUnityRuntimeProofTests.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "Laser.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "LaserManager.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "Lightning.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "LightningGunManager.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "HitscanEffect.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "HitscanManager.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantLaser.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantLaserManager.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantLightning.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantLightningManager.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantParticleWeapon.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantParticleWeaponManager.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons", "ConstantWeaponEffectManager.cs") }; var survivingUnityProjectileAuthority = forbiddenUnityProjectileAuthorityPaths .Where(File.Exists) @@ -17157,49 +17124,6 @@ static void RequireUnityPhysicsIsNotGameplayAuthority(string root) string.Join(", ", survivingUnityProjectileAuthority)); } - if (ymirBridge.Contains("BuildZoneWorld(", StringComparison.Ordinal) || - ymirBridge.Contains("BuildTargetWorld(", StringComparison.Ordinal) || - ymirBridge.Contains("_zoneBodies", StringComparison.Ordinal) || - ymirBridge.Contains("_targetBodies", StringComparison.Ordinal) || - ymirBridge.Contains("TargetBodyPrefix", StringComparison.Ordinal) || - ymirBridge.Contains("bodyMap[bodyId] = hull", StringComparison.Ordinal) || - ymirBridge.Contains("TargetRadiusPadding", StringComparison.Ordinal) || - ymirBridge.Contains("view.HasEntityIndex ? view.EntityIndex[i] : i", StringComparison.Ordinal)) - { - throw new InvalidOperationException( - "Ymir gameplay target/zone queries must be built from daemon SOA entity bodies with explicit daemon entity ids, not Unity HullCollider presentation geometry or row-order fallbacks."); - } - - if (!ymirBridge.Contains("!view.IsCreated || !view.HasEntityIndex || !view.HasPhysicsRadius", StringComparison.Ordinal) || - !ymirBridge.Contains("var daemonEntityIndex = view.EntityIndex[i];", StringComparison.Ordinal)) - { - throw new InvalidOperationException( - "Ymir daemon body construction must require the daemon EntityIndex SoA column and derive body ids from that column."); - } - - var forbiddenWeaponZoneHandles = new Dictionary - { - [hitscanPath] = new[] { "public Zone Zone", "Zone { get; set; }" }, - [hitscanManagerPath] = new[] { "p.Zone =", "source.Entity.Zone" } - }; - var weaponZoneHandleHits = forbiddenWeaponZoneHandles - .Where(pair => File.Exists(pair.Key)) - .SelectMany(pair => - { - var text = File.ReadAllText(pair.Key); - return pair.Value - .Where(symbol => text.Contains(symbol, StringComparison.Ordinal)) - .Select(symbol => $"{Path.GetRelativePath(root, pair.Key)}: {symbol}"); - }) - .ToArray(); - - if (weaponZoneHandleHits.Length > 0) - { - throw new InvalidOperationException( - "Unity weapon effects must query Ymir/renderer state directly instead of carrying renderer-local Zone handles: " + - string.Join("; ", weaponZoneHandleHits)); - } - var weaponEffectRoot = Path.Combine(root, "Assets", "Scripts", "Gameplay", "Weapons"); var forbiddenWeaponCombatSymbols = new[] { diff --git a/Assets/Scripts/Gameplay/Physics/AetheriaYmirPhysicsBridge.cs b/Assets/Scripts/Gameplay/Physics/AetheriaYmirPhysicsBridge.cs index 2d75f4fde..6900fbb4f 100644 --- a/Assets/Scripts/Gameplay/Physics/AetheriaYmirPhysicsBridge.cs +++ b/Assets/Scripts/Gameplay/Physics/AetheriaYmirPhysicsBridge.cs @@ -4,181 +4,28 @@ using UnityEngine; public sealed class AetheriaYmirPhysicsBridge : MonoBehaviour { - private const string DaemonEntityBodyPrefix = "aetheria.daemon.entity."; - private static AetheriaYmirPhysicsBridge _instance; - - public bool EnableProjectileCutover = true; - public AetheriaDaemonObserver DaemonObserver; - public IYmirDaemonBodySource DaemonBodySource { get; set; } - - private readonly List _daemonBodies = new List(); private readonly List _clickableBodies = new List(); - private readonly Dictionary _hullBodyMap = new Dictionary(StringComparer.Ordinal); - private readonly Dictionary _clickableBodyMap = new Dictionary(StringComparer.Ordinal); + private readonly Dictionary _clickableBodyMap = + new Dictionary(StringComparer.Ordinal); + + public bool EnableQueries = true; public static AetheriaYmirPhysicsBridge Instance { get { if (_instance != null) return _instance; - _instance = FindAnyObjectByType(); if (_instance != null) return _instance; - var bridge = new GameObject("Aetheria Ymir Physics Bridge"); + var bridge = new GameObject("Aetheria Ymir Presentation Query Bridge"); DontDestroyOnLoad(bridge); _instance = bridge.AddComponent(); return _instance; } } - public bool TryOverlapDaemonBodies( - Vector3 center, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!TryBuildDaemonWorld(null, null, out var world) || radius <= 0) - return false; - - var request = new YmirCircleOverlapRequest - { - world = world, - center = ToVec2(center), - radius = radius - }; - - return TryOverlapCircle(request, out hits); - } - - public bool TryCastDaemonBodies( - Vector3 origin, - Vector3 direction, - float distance, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!TryBuildDaemonWorld(null, null, out var world) || distance <= 0 || radius < 0) - return false; - - var planarDirection = new Vector3(direction.x, 0, direction.z); - if (planarDirection.sqrMagnitude <= float.Epsilon) - return false; - - var request = new YmirCircleCastRequest - { - world = world, - origin = ToVec2(origin), - direction = ToVec2(planarDirection.normalized), - distance = distance, - radius = radius - }; - - return TryCastCircle(request, "Ymir daemon body circle cast query", out hits); - } - - public bool TryOverlapTargetHulls( - EntityInstance target, - Vector3 center, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || target == null || radius <= 0) - return false; - - if (!TryBuildDaemonWorld(null, TargetDaemonEntityIndex(target), out var world)) - return false; - - var request = new YmirCircleOverlapRequest - { - center = ToVec2(center), - radius = radius, - world = world - }; - - if (!TryOverlapCircle(request, out var ymirHits)) - return false; - - var resolved = new List(); - foreach (var hit in ymirHits) - { - if (!TryResolveTargetDaemonHull(target, hit.bodyId, out var hull)) - continue; - - resolved.Add(new AetheriaYmirOverlapHit( - hull, - new Vector3(hit.point.x, center.y, hit.point.y), - new Vector3(hit.normal.x, 0, hit.normal.y).normalized, - hit.penetration, - hit.distance)); - } - - hits = resolved; - return true; - } - - public bool TryOverlapSphere( - IReadOnlyList bodies, - Vector3 center, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (bodies == null || bodies.Count == 0) - return false; - - var bodyArray = bodies as YmirSphereQueryBody[] ?? CopySphereQueryBodies(bodies); - return TryOverlapSphere(bodyArray, center, radius, "Ymir sphere overlap query", out hits); - } - - public bool TryCastTargetHulls( - EntityInstance target, - Vector3 origin, - Vector3 direction, - float distance, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || target == null || distance <= 0 || direction.sqrMagnitude <= 0.000001f) - return false; - - if (!TryBuildDaemonWorld(null, TargetDaemonEntityIndex(target), out var world)) - return false; - - var request = new YmirCircleCastRequest - { - origin = ToVec2(origin), - direction = ToVec2(direction.normalized), - distance = distance, - radius = Mathf.Max(0, radius), - world = world - }; - - if (!TryCastCircle(request, "Ymir daemon target cast query", out var ymirHits)) - return false; - - var resolved = new List(); - foreach (var hit in ymirHits) - { - if (!TryResolveTargetDaemonHull(target, hit.bodyId, out var hull)) - continue; - - resolved.Add(new AetheriaYmirCastHit( - hull, - ResolveShield(hull), - new Vector3(hit.point.x, origin.y, hit.point.y), - new Vector3(hit.normal.x, 0, hit.normal.y).normalized, - hit.distance)); - } - - hits = resolved; - return true; - } - public bool TryCastClickables( IReadOnlyList clickables, Ray ray, @@ -186,19 +33,18 @@ public sealed class AetheriaYmirPhysicsBridge : MonoBehaviour out AetheriaYmirClickableHit hit) { hit = default; - if (!EnableProjectileCutover || clickables == null || clickables.Count == 0 || distance <= 0) + if (!EnableQueries || clickables == null || clickables.Count == 0 || distance <= 0) return false; _clickableBodyMap.Clear(); _clickableBodies.Clear(); - for (var i = 0; i < clickables.Count; i++) + for (var index = 0; index < clickables.Count; index++) { - var clickable = clickables[i]; - if (clickable == null || !clickable.isActiveAndEnabled) - continue; + var clickable = clickables[index]; + if (clickable == null || !clickable.isActiveAndEnabled) continue; var bounds = clickable.ClickBounds; - var bodyId = $"aetheria.clickable.{i}"; + var bodyId = $"eve.clickable.{index}"; _clickableBodyMap[bodyId] = clickable; _clickableBodies.Add(new YmirSphereQueryBody { @@ -208,467 +54,42 @@ public sealed class AetheriaYmirPhysicsBridge : MonoBehaviour }); } - if (_clickableBodies.Count == 0) - return false; + if (_clickableBodies.Count == 0) return false; - var bodyArray = _clickableBodies.ToArray(); - var request = new YmirSphereCastRequest + YmirSphereCastResult result; + try { - origin = ToVec3(ray.origin), - direction = ToVec3(ray.direction.normalized), - distance = distance, - radius = 0, - bodies = bodyArray - }; - - if (!TryCastSphere(request, "Ymir clickable cast query", out var ymirHits)) - return false; - - foreach (var resultHit in ymirHits) + result = YmirPhysicsQueries.CastSphere(new YmirSphereCastRequest + { + origin = ToVec3(ray.origin), + direction = ToVec3(ray.direction.normalized), + distance = distance, + radius = 0, + bodies = _clickableBodies.ToArray() + }); + } + catch (Exception error) { - if (!_clickableBodyMap.TryGetValue(resultHit.bodyId, out var clickable) || clickable == null) + Debug.LogWarning($"Ymir clickable presentation query failed: {error.Message}"); + return false; + } + + foreach (var candidate in result?.hits ?? Array.Empty()) + { + if (!_clickableBodyMap.TryGetValue(candidate.bodyId, out var clickable) || clickable == null) continue; - hit = new AetheriaYmirClickableHit( clickable, - ToVector3(resultHit.point), - ToVector3(resultHit.normal).normalized, - resultHit.distance); + ToVector3(candidate.point), + ToVector3(candidate.normal).normalized, + candidate.distance); return true; } - return false; } - public bool TryOverlapZoneHulls( - ZoneRenderer zoneRenderer, - Entity sourceEntity, - Vector3 center, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || zoneRenderer == null || radius <= 0) - return false; - - if (!TryBuildDaemonWorld(sourceEntity, null, out var world)) - return false; - - var request = new YmirCircleOverlapRequest - { - center = ToVec2(center), - radius = radius, - world = world - }; - - if (!TryOverlapCircle(request, out var ymirHits)) - return false; - - var resolved = new List(); - foreach (var hit in ymirHits) - { - if (!TryResolveDaemonEntityHull(zoneRenderer, hit.bodyId, out var hull)) - continue; - - resolved.Add(new AetheriaYmirOverlapHit( - hull, - new Vector3(hit.point.x, center.y, hit.point.y), - new Vector3(hit.normal.x, 0, hit.normal.y).normalized, - hit.penetration, - hit.distance)); - } - - hits = resolved; - return true; - } - - public bool TryCastZoneHulls( - ZoneRenderer zoneRenderer, - Entity sourceEntity, - Vector3 origin, - Vector3 direction, - float distance, - float radius, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || zoneRenderer == null || distance <= 0 || direction.sqrMagnitude <= 0.000001f) - return false; - - if (!TryBuildDaemonWorld(sourceEntity, null, out var world)) - return false; - - var request = new YmirCircleCastRequest - { - origin = ToVec2(origin), - direction = ToVec2(direction.normalized), - distance = distance, - radius = Mathf.Max(0, radius), - world = world - }; - - if (!TryCastCircle(request, "Ymir daemon zone cast query", out var ymirHits)) - return false; - - var resolved = new List(); - foreach (var hit in ymirHits) - { - if (!TryResolveDaemonEntityHull(zoneRenderer, hit.bodyId, out var hull)) - continue; - - resolved.Add(new AetheriaYmirCastHit( - hull, - ResolveShield(hull), - new Vector3(hit.point.x, origin.y, hit.point.y), - new Vector3(hit.normal.x, 0, hit.normal.y).normalized, - hit.distance)); - } - - hits = resolved; - return true; - } - - private bool TryBuildDaemonWorld(Entity sourceEntity, int? onlyDaemonEntityIndex, out YmirWorld world) - { - world = null; - if (DaemonBodySource != null) - { - _daemonBodies.Clear(); - if (!DaemonBodySource.TryAppendDaemonBodies(sourceEntity, onlyDaemonEntityIndex, _daemonBodies) || - _daemonBodies.Count == 0) - { - return false; - } - - world = new YmirWorld - { - time = Time.time, - bodies = _daemonBodies.ToArray(), - fields = Array.Empty() - }; - return true; - } - - var observer = ResolveDaemonObserver(); - if (observer == null || !observer.HasRenderNativeView) - return false; - - var view = observer.LastRenderNativeView; - if (!view.IsCreated || !view.HasEntityIndex || !view.HasPhysicsRadius) - return false; - - _daemonBodies.Clear(); - for (var i = 0; i < view.Count; i++) - { - var radius = view.PhysicsBodyRadius[i]; - if (radius <= 0) - continue; - - var daemonEntityIndex = view.EntityIndex[i]; - if (sourceEntity != null && sourceEntity.DaemonEntityIndex == daemonEntityIndex) - continue; - if (onlyDaemonEntityIndex.HasValue && onlyDaemonEntityIndex.Value != daemonEntityIndex) - continue; - - var inverseMass = view.HasPhysicsInverseMass ? view.PhysicsBodyInverseMass[i] : 1.0f; - var mass = view.HasPhysicsMass && view.PhysicsBodyMass[i] > 0 - ? view.PhysicsBodyMass[i] - : inverseMass > 0 - ? 1.0f / inverseMass - : 1.0f; - var rotation = view.HasRotation ? view.RotationRadians[i] : 0; - var position = view.Position[i]; - var velocity = view.HasVelocity ? view.Velocity[i] : default; - - _daemonBodies.Add(new YmirPhysicsBody - { - id = DaemonEntityBodyPrefix + daemonEntityIndex, - position = new YmirVec2 { x = position.x, y = position.z }, - velocity = view.HasVelocity - ? new YmirVec2 { x = velocity.x, y = velocity.z } - : default, - direction = new YmirVec2 { x = Mathf.Sin(rotation), y = Mathf.Cos(rotation) }, - angularVelocity = 0, - torque = 0, - momentOfInertia = 1, - radius = radius, - mass = Mathf.Max(mass, 0.001f), - isStatic = view.HasPhysicsInverseMass && inverseMass <= 0, - restitution = 0 - }); - } - - if (_daemonBodies.Count == 0) - return false; - - world = new YmirWorld - { - time = Time.time, - bodies = _daemonBodies.ToArray(), - fields = Array.Empty() - }; - return true; - } - - private static int TargetDaemonEntityIndex(EntityInstance target) - { - return target != null && target.Entity != null ? target.Entity.DaemonEntityIndex : -1; - } - - private static bool TryResolveTargetDaemonHull( - EntityInstance target, - string bodyId, - out HullCollider hull) - { - hull = null; - if (target == null || - target.HullColliders == null || - !TryParseDaemonEntityBodyId(bodyId, out var daemonEntityIndex) || - TargetDaemonEntityIndex(target) != daemonEntityIndex) - { - return false; - } - - for (var i = 0; i < target.HullColliders.Length; i++) - { - hull = target.HullColliders[i]; - if (hull != null) - return true; - } - - hull = null; - return false; - } - - private static bool TryResolveDaemonEntityHull( - ZoneRenderer zoneRenderer, - string bodyId, - out HullCollider hull) - { - hull = null; - if (zoneRenderer == null || !TryParseDaemonEntityBodyId(bodyId, out var daemonEntityIndex)) - return false; - - if (!zoneRenderer.TryGetEntityInstance(daemonEntityIndex, out var instance) || - instance == null || - instance.HullColliders == null) - { - return false; - } - - for (var i = 0; i < instance.HullColliders.Length; i++) - { - hull = instance.HullColliders[i]; - if (hull != null) - return true; - } - - hull = null; - return false; - } - - private static bool TryParseDaemonEntityBodyId(string bodyId, out int daemonEntityIndex) - { - daemonEntityIndex = -1; - return !string.IsNullOrWhiteSpace(bodyId) && - bodyId.StartsWith(DaemonEntityBodyPrefix, StringComparison.Ordinal) && - int.TryParse( - bodyId.Substring(DaemonEntityBodyPrefix.Length), - out daemonEntityIndex); - } - - private AetheriaDaemonObserver ResolveDaemonObserver() - { - if (DaemonObserver != null) - return DaemonObserver; - - DaemonObserver = FindAnyObjectByType(); - return DaemonObserver; - } - - private bool TryOverlapSphere( - YmirSphereQueryBody[] bodies, - Vector3 center, - float radius, - string failureContext, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || bodies == null || bodies.Length == 0 || radius <= 0) - return false; - - try - { - var result = YmirPhysicsQueries.OverlapSphere(new YmirSphereOverlapRequest - { - center = ToVec3(center), - radius = radius, - bodies = bodies - }); - hits = result.hits ?? Array.Empty(); - return true; - } - catch (Exception error) - { - Debug.LogWarning($"{failureContext} failed: {error.Message}"); - return false; - } - } - - private bool TryCastSphere( - YmirSphereCastRequest request, - string failureContext, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || request == null || request.bodies == null || request.bodies.Length == 0 || request.distance <= 0 || request.radius < 0) - return false; - - try - { - var result = YmirPhysicsQueries.CastSphere(request); - hits = result.hits ?? Array.Empty(); - return true; - } - catch (Exception error) - { - Debug.LogWarning($"{failureContext} failed: {error.Message}"); - return false; - } - } - - private bool TryOverlapCircle( - YmirCircleOverlapRequest request, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || request == null || request.world == null || request.world.bodies == null || request.world.bodies.Length == 0 || request.radius <= 0) - return false; - - try - { - var result = YmirPhysicsQueries.OverlapCircle(request); - hits = result.hits ?? Array.Empty(); - return true; - } - catch (Exception error) - { - Debug.LogWarning($"Ymir circle overlap query failed: {error.Message}"); - return false; - } - } - - private bool TryCastCircle( - YmirCircleCastRequest request, - string failureContext, - out IReadOnlyList hits) - { - hits = Array.Empty(); - if (!EnableProjectileCutover || request == null || request.world == null || request.world.bodies == null || request.world.bodies.Length == 0 || request.distance <= 0 || request.radius < 0) - return false; - - try - { - var result = YmirPhysicsQueries.CastCircle(request); - hits = result.hits ?? Array.Empty(); - return true; - } - catch (Exception error) - { - Debug.LogWarning($"{failureContext} failed: {error.Message}"); - return false; - } - } - - private static YmirSphereQueryBody[] CopySphereQueryBodies(IReadOnlyList bodies) - { - var copy = new YmirSphereQueryBody[bodies.Count]; - for (var i = 0; i < copy.Length; i++) - copy[i] = bodies[i]; - return copy; - } - - private static YmirPhysicsBody FindBody(YmirWorld world, string bodyId) - { - foreach (var body in world.bodies ?? Array.Empty()) - { - if (string.Equals(body.id, bodyId, StringComparison.Ordinal)) - return body; - } - - return null; - } - - private static ShieldManager ResolveShield(HullCollider hull) - { - var instance = hull != null ? hull.GetComponentInParent() : null; - return instance != null ? instance.Shield : null; - } - - private static YmirVec2 ToVec2(Vector3 value) => new YmirVec2 { x = value.x, y = value.z }; - - private static YmirVec2 ToVec2(CultMath.float2 value) => new YmirVec2 { x = value.x, y = value.y }; - private static YmirVec3 ToVec3(Vector3 value) => new YmirVec3 { x = value.x, y = value.y, z = value.z }; - private static Vector3 ToVector3(YmirVec3 value) => new Vector3(value.x, value.y, value.z); - - private static Bounds ObjectBounds(GameObject gameObject, Vector3 fallbackCenter) - { - var renderers = gameObject.GetComponentsInChildren(); - if (renderers.Length == 0) - return new Bounds(fallbackCenter, Vector3.one); - - var bounds = renderers[0].bounds; - for (var i = 1; i < renderers.Length; i++) - bounds.Encapsulate(renderers[i].bounds); - - return bounds; - } -} - -public interface IYmirDaemonBodySource -{ - bool TryAppendDaemonBodies( - Entity sourceEntity, - int? onlyDaemonEntityIndex, - List bodies); -} - -public readonly struct AetheriaYmirOverlapHit -{ - public AetheriaYmirOverlapHit(HullCollider hull, Vector3 point, Vector3 normal, float penetration, float distance) - { - Hull = hull; - Point = point; - Normal = normal; - Penetration = penetration; - Distance = distance; - } - - public HullCollider Hull { get; } - public Vector3 Point { get; } - public Vector3 Normal { get; } - public float Penetration { get; } - public float Distance { get; } -} - -public readonly struct AetheriaYmirCastHit -{ - public AetheriaYmirCastHit(HullCollider hull, ShieldManager shield, Vector3 point, Vector3 normal, float distance) - { - Hull = hull; - Shield = shield; - Point = point; - Normal = normal; - Distance = distance; - } - - public HullCollider Hull { get; } - public ShieldManager Shield { get; } - public Vector3 Point { get; } - public Vector3 Normal { get; } - public float Distance { get; } } public readonly struct AetheriaYmirClickableHit diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs b/Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs deleted file mode 100644 index 0e47dac49..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs +++ /dev/null @@ -1,106 +0,0 @@ -using UnityEngine; - -public class ConstantLaser : MonoBehaviour -{ - public AnimationCurve StartCurve; - public AnimationCurve EndCurve; - public AnimationCurve IntensityCurve; - public float WidthMultiplier = 1; - public float StartDuration; - public float FadeDuration; - public float CycleDuration; - public LineRenderer LineRenderer; - - public float ImpactIntensity { get; set; } = 1; - public Entity SourceEntity { get; set; } - public ZoneRenderer ZoneRenderer { get; set; } - public float Range { get; set; } - - private float _intensity; - private float _stopIntensity; - private bool _starting; - private bool _stopping; - private float _startTime; - private float _cycleStartTime; - private readonly Vector3[] _zeros = {Vector3.zero, Vector3.zero}; - - private void OnEnable() - { - _stopping = false; - _starting = true; - _startTime = Time.time; - LineRenderer.SetPositions(_zeros); - } - - private void Update() - { - if (_stopping) - { - var lerp = (Time.time - _startTime) / FadeDuration; - LineRenderer.widthMultiplier = EndCurve.Evaluate(lerp) * _stopIntensity * WidthMultiplier; - - if (lerp > 1) - { - GetComponent().ReturnToPool(); - return; - } - } - else - { - var lerp = (Time.time - _startTime) / StartDuration; - if (lerp > 1) - { - if (_starting) - { - _starting = false; - _cycleStartTime = Time.time; - } - _intensity = IntensityCurve.Evaluate((Time.time - _cycleStartTime) / CycleDuration % CycleDuration); - LineRenderer.widthMultiplier = _intensity * WidthMultiplier; - } - else - { - LineRenderer.widthMultiplier = StartCurve.Evaluate(lerp) * WidthMultiplier; - } - } - - LineRenderer.SetPosition(0, transform.position); - var hitFound = false; - if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls( - ZoneRenderer, - SourceEntity, - transform.position, - transform.forward, - Range, - 0, - out var hits)) - { - foreach (var hit in hits) - { - var hull = hit.Hull; - var entity = hull.Entity; - if (entity.Shield != null && entity.Shield.Item.Active.Value) - { - hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity)); - LineRenderer.SetPosition(1, hit.Point); - hitFound = true; - break; - } - - LineRenderer.SetPosition(1, hit.Point); - hitFound = true; - break; - } - } - - if(!hitFound) - LineRenderer.SetPosition(1, transform.position + transform.forward * Range); - } - - public void Stop() - { - _stopping = true; - _stopIntensity = _intensity; - _startTime = Time.time; - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs.meta deleted file mode 100644 index e7b8751f5..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLaser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0fdff1d9c6e4a574f987f8cecdb87f36 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 90 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs b/Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs deleted file mode 100644 index a1853c1f2..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ConstantLaserManager : ConstantWeaponEffectManager -{ - public Prototype LaserPrototype; - - private Dictionary _lasers = new Dictionary(); - - public override void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) - { - var p = LaserPrototype.Instantiate(); - p.SourceEntity = source.Entity; - p.ZoneRenderer = source.ZoneRenderer; - var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; - var barrel = source.GetBarrel(hp); - p.Range = weapon.Range; - var t = p.transform; - t.SetParent(barrel); - t.forward = barrel.forward; - t.position = barrel.position; - p.ImpactIntensity = 1; - _lasers.Add(item, p); - } - - public override void StopFiring(EquippedItem item) - { - _lasers[item].Stop(); - _lasers.Remove(item); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs.meta deleted file mode 100644 index ad5d9e741..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1a62592df67e114d880374819659914 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs b/Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs deleted file mode 100644 index f2fad96f0..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs +++ /dev/null @@ -1,87 +0,0 @@ -using UnityEngine; - -public class ConstantLightning : MonoBehaviour -{ - public LightningCompute Lightning; - public float HitRadius; - public AnimationCurve FadeCurve; - public float StartWidth = 1; - public float EndWidth = 1; - public float FadeDuration; - - public Transform Barrel { get; set; } - public float ImpactIntensity { get; set; } = 1; - public EntityInstance Source { get; set; } - public float Range { get; set; } - - private bool _stopping; - private float _startTime; - - private void OnEnable() - { - _stopping = false; - Lightning.StartAnimation(); - } - - private void Update() - { - if (Barrel == null) return; - if (_stopping) - { - var lerp = (Time.time - _startTime) / FadeDuration; - Lightning.StartWidth = FadeCurve.Evaluate(lerp) * StartWidth; - Lightning.EndWidth = FadeCurve.Evaluate(lerp) * EndWidth; - - if (lerp > 1) - { - GetComponent().ReturnToPool(); - return; - } - } - else - { - Lightning.StartWidth = StartWidth; - Lightning.EndWidth = EndWidth; - } - - Lightning.FixedEndpoint = false; - if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls( - Source?.ZoneRenderer, - Source?.Entity, - Barrel.position, - Barrel.forward, - Range, - HitRadius, - out var hits)) - { - foreach (var hit in hits) - { - var hull = hit.Hull; - var entity = hull.Entity; - if (entity.Shield != null && entity.Shield.Item.Active.Value) - { - hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity)); - } - else - { - } - - Lightning.FixedEndpoint = true; - Lightning.EndPosition = hit.Point; - - break; - } - } - - if(!Lightning.FixedEndpoint) - Lightning.EndPosition = Barrel.position + Barrel.forward * Range; - - Lightning.StartPosition = Barrel.position; - } - - public void Stop() - { - _stopping = true; - _startTime = Time.time; - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs.meta deleted file mode 100644 index 814bc1a49..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLightning.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b184352ea3694b8d892f1402b8d51153 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 55 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs b/Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs deleted file mode 100644 index 9372f2f47..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Serialization; - -public class ConstantLightningManager : ConstantWeaponEffectManager -{ - public Prototype LightningPrototype; - - private Dictionary _bolts = new Dictionary(); - - public override void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) - { - var p = LightningPrototype.Instantiate(); - p.Source = source; - var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; - var barrel = source.GetBarrel(hp); - p.Barrel = barrel; - p.Range = weapon.Range; - p.ImpactIntensity = 1; - _bolts.Add(item, p); - } - - public override void StopFiring(EquippedItem item) - { - _bolts[item].Stop(); - _bolts.Remove(item); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs.meta deleted file mode 100644 index f96c814ec..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantLightningManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ecabe4f078a147459bba6172582d7bc8 -timeCreated: 1612491892 \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs b/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs deleted file mode 100644 index dcaee68f7..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Linq; -using UnityEngine; - -public class ConstantParticleWeapon : MonoBehaviour -{ - public ParticleSystem[] Particles; - public float CastRadius = 0.25f; - - public float Range { get; set; } - public EntityInstance Source { get; set; } - public EntityInstance Target { get; set; } - - private bool _stopping; - - private void OnEnable() - { - foreach(var p in Particles) - { - var emission = p.emission; - emission.enabled = true; - } - _stopping = false; - } - - public void Initialize() - { - foreach(var p in Particles) - { - var main = p.main; - main.simulationSpace = ParticleSystemSimulationSpace.Custom; - main.customSimulationSpace = Source.LocalSpace; - } - } - - private void Update() - { - if (Source == null) return; - if (_stopping && Particles.All(p=>p.particleCount == 0)) - { - GetComponent().ReturnToPool(); - return; - } - - if (_stopping || Target == null || Range <= 0) - return; - - if (AetheriaYmirPhysicsBridge.Instance.TryCastTargetHulls( - Target, - transform.position, - transform.forward, - Range, - CastRadius, - out var hits)) - { - foreach (var hit in hits) - { - break; - } - } - } - - public void Stop() - { - foreach(var p in Particles) - { - var emission = p.emission; - emission.enabled = false; - } - _stopping = true; - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs.meta deleted file mode 100644 index 1657416b3..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 200b7ae77af3480e98184bdffe2c0103 -timeCreated: 1612570252 \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs b/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs deleted file mode 100644 index 406d63631..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ConstantParticleWeaponManager : ConstantWeaponEffectManager -{ - public Prototype WeaponPrototype; - - private Dictionary _weapons = new Dictionary(); - - public override void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) - { - var p = WeaponPrototype.Instantiate(); - p.Source = source; - p.Target = target; - var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; - var barrel = source.GetBarrel(hp); - var t = p.transform; - t.SetParent(barrel); - t.forward = barrel.forward; - t.position = barrel.position; - p.Range = weapon.Range; - _weapons.Add(item, p); - p.Initialize(); - } - - public override void StopFiring(EquippedItem item) - { - _weapons[item].Stop(); - _weapons.Remove(item); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs.meta deleted file mode 100644 index e15a13e51..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeaponManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 7559cc5b68bf4495ae2643dc8d1b742b -timeCreated: 1612570303 \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs b/Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs deleted file mode 100644 index 265640da3..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public abstract class ConstantWeaponEffectManager : MonoBehaviour -{ - public abstract void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target); - public abstract void StopFiring(EquippedItem item); -} diff --git a/Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs.meta deleted file mode 100644 index 22d1e2c7b..000000000 --- a/Assets/Scripts/Gameplay/Weapons/ConstantWeaponEffectManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 38df809a0cf4b7748bad88620bb7b3ab -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs b/Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs deleted file mode 100644 index 109d6eeb8..000000000 --- a/Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs +++ /dev/null @@ -1,89 +0,0 @@ -using UnityEngine; - -public class HitscanEffect : MonoBehaviour -{ - public float Duration; - public AnimationCurve IntensityCurve; - public LineRenderer Line; - public ParticleSystem LineEffect; - public Prototype HitEffect; - - public float ImpactIntensity { get; set; } = 1; - public Entity SourceEntity { get; set; } - public ZoneRenderer ZoneRenderer { get; set; } - public float Range { get; set; } - - private float _startTime; - private bool _active = false; - - public void Fire() - { - _startTime = Time.time; - var hitFound = false; - if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls( - ZoneRenderer, - SourceEntity, - transform.position, - transform.forward, - Range, - 0, - out var hits)) - { - foreach (var hit in hits) - { - var hull = hit.Hull; - var entity = hull.Entity; - if (entity.Shield != null && entity.Shield.Item.Active.Value) - { - hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity)); - hitFound = true; - } - else - { - hitFound = true; - } - - if (hitFound && HitEffect != null) - { - var ht = HitEffect.Instantiate(); - ht.SetParent(hull.transform); - ht.position = hit.Point; - } - - var length = (hit.Point - transform.position).magnitude; - Line.SetPosition(1, Vector3.forward * length); - var emission = LineEffect.emission; - emission.rateOverTimeMultiplier = length; - var shape = LineEffect.shape; - shape.position = Vector3.forward * (length / 2); - shape.scale = Vector3.one * (length / 2); - break; - } - } - - if(!hitFound) - { - Line.SetPosition(1, Vector3.forward * Range); - var emission = LineEffect.emission; - emission.rateOverTimeMultiplier = Range; - var shape = LineEffect.shape; - shape.position = Vector3.forward * (Range / 2); - shape.scale = Vector3.one * (Range / 2); - } - LineEffect.Play(true); - _active = true; - } - - void Update() - { - if (!_active) return; - var lerp = (Time.time - _startTime) / Duration; - if (lerp > 1) - { - GetComponent().ReturnToPool(); - return; - } - - Line.widthMultiplier = IntensityCurve.Evaluate(lerp); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs.meta b/Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs.meta deleted file mode 100644 index 11ca8595c..000000000 --- a/Assets/Scripts/Gameplay/Weapons/HitscanEffect.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f8555514e892b2c438fe085da1fdf89d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/HitscanManager.cs b/Assets/Scripts/Gameplay/Weapons/HitscanManager.cs deleted file mode 100644 index 711acc3ad..000000000 --- a/Assets/Scripts/Gameplay/Weapons/HitscanManager.cs +++ /dev/null @@ -1,23 +0,0 @@ -using UnityEngine; - -public class HitscanManager : InstantWeaponEffectManager -{ - public Prototype Prototype; - public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) - { - var p = Prototype.Instantiate(); - p.SourceEntity = source.Entity; - p.ZoneRenderer = source.ZoneRenderer; - var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; - var barrel = source.GetBarrel(hp); - var t = p.transform; - t.SetParent(barrel, false); - t.localRotation = Quaternion.identity; - t.localPosition = Vector3.zero; - // t.position = barrel.position; - // t.forward = barrel.forward; - p.Range = weapon.Range; - p.ImpactIntensity = 1; - p.Fire(); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/HitscanManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/HitscanManager.cs.meta deleted file mode 100644 index 07d32998b..000000000 --- a/Assets/Scripts/Gameplay/Weapons/HitscanManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 90fe995fff18457987112f6f96b45a17 -timeCreated: 1611954267 \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Weapons/Laser.cs b/Assets/Scripts/Gameplay/Weapons/Laser.cs deleted file mode 100644 index ce1f002ae..000000000 --- a/Assets/Scripts/Gameplay/Weapons/Laser.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -public class Laser : MonoBehaviour -{ - public AnimationCurve IntensityCurve; - public float Duration; - public LineRenderer LineRenderer; - - public float ImpactIntensity { get; set; } = 1; - public Entity SourceEntity { get; set; } - public ZoneRenderer ZoneRenderer { get; set; } - public float Range { get; set; } - - private float _startTime; - private readonly Vector3[] _zeros = {Vector3.zero, Vector3.zero}; - - private void OnEnable() - { - _startTime = Time.time; - LineRenderer.SetPositions(_zeros); - } - - private void Update() - { - var lerp = (Time.time - _startTime) / Duration; - if (lerp > 1) - { - GetComponent().ReturnToPool(); - return; - } - - LineRenderer.SetPosition(0, transform.position); - var hitFound = false; - if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls( - ZoneRenderer, - SourceEntity, - transform.position, - transform.forward, - Range, - 0, - out var hits)) - { - foreach (var hit in hits) - { - var hull = hit.Hull; - var entity = hull.Entity; - if (entity.Shield != null && entity.Shield.Item.Active.Value) - { - hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity)); - LineRenderer.SetPosition(1, hit.Point); - hitFound = true; - break; - } - - LineRenderer.SetPosition(1, hit.Point); - hitFound = true; - break; - } - } - - if(!hitFound) - LineRenderer.SetPosition(1, transform.position + transform.forward * Range); - - LineRenderer.widthMultiplier = IntensityCurve.Evaluate(lerp); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/Laser.cs.meta b/Assets/Scripts/Gameplay/Weapons/Laser.cs.meta deleted file mode 100644 index 325a1e75f..000000000 --- a/Assets/Scripts/Gameplay/Weapons/Laser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 166b726996e49bd4b87608739a5af815 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 80 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/LaserManager.cs b/Assets/Scripts/Gameplay/Weapons/LaserManager.cs deleted file mode 100644 index 371638453..000000000 --- a/Assets/Scripts/Gameplay/Weapons/LaserManager.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class LaserManager : InstantWeaponEffectManager -{ - public Prototype ProjectilePrototype; - - public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) - { - var p = ProjectilePrototype.Instantiate(); - var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; - var barrel = source.GetBarrel(hp); - var t = p.transform; - t.SetParent(barrel); - t.forward = barrel.forward; - t.position = barrel.position; - p.SourceEntity = source.Entity; - p.ZoneRenderer = source.ZoneRenderer; - p.Range = weapon.Range; - p.ImpactIntensity = 1; - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/LaserManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/LaserManager.cs.meta deleted file mode 100644 index f3251dcc4..000000000 --- a/Assets/Scripts/Gameplay/Weapons/LaserManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5745a5be5f0c02b4b88bd094ea609c13 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/Lightning.cs b/Assets/Scripts/Gameplay/Weapons/Lightning.cs deleted file mode 100644 index 46082bc3d..000000000 --- a/Assets/Scripts/Gameplay/Weapons/Lightning.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using UnityEngine; - -public class Lightning : MonoBehaviour -{ - public LightningCompute LightningCompute; - public float HitRadius; - - public float ImpactIntensity { get; set; } = 1; - public EntityInstance Source { get; set; } - public float Range { get; set; } - public EntityInstance Target { get; set; } - public Transform Barrel { get; set; } - - private bool _colliderHit; - private Vector3 _colliderLocalPosition; - private Transform _colliderTransform; - private Vector3 _endpoint; - - public void Fire() - { - _colliderHit = false; - LightningCompute.OnLeaderComplete = null; - LightningCompute.FixedEndpoint = false; - _endpoint = Barrel.position + Barrel.forward * Range; - if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls( - Source?.ZoneRenderer, - Source?.Entity, - Barrel.position, - Barrel.forward, - Range, - HitRadius, - out var hits)) - { - foreach (var hit in hits) - { - var hull = hit.Hull; - var entity = hull.Entity; - if (entity.Shield != null && entity.Shield.Item.Active.Value) - { - LightningCompute.OnLeaderComplete = () => - { - hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity)); - }; - } - else - { - LightningCompute.OnLeaderComplete = null; - } - - _colliderHit = true; - _colliderLocalPosition = hull.transform.InverseTransformPoint(hit.Point); - _colliderTransform = hull.transform; - LightningCompute.FixedEndpoint = true; - _endpoint = hit.Point; - break; - } - } - - LightningCompute.OnPulseComplete = () => - GetComponent().ReturnToPool(); - LightningCompute.StartAnimation(); - } - - private void Update() - { - if (Barrel == null) return; - - if (_colliderHit) - { - if (_colliderTransform) _endpoint = _colliderTransform.TransformPoint(_colliderLocalPosition); - } - - LightningCompute.EndPosition = _endpoint; - LightningCompute.StartPosition = Barrel.position; - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/Lightning.cs.meta b/Assets/Scripts/Gameplay/Weapons/Lightning.cs.meta deleted file mode 100644 index 1a055a34d..000000000 --- a/Assets/Scripts/Gameplay/Weapons/Lightning.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5c75d76a7b418d3479761187b2d420bc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 54 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs b/Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs deleted file mode 100644 index c27f03d66..000000000 --- a/Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class LightningGunManager : InstantWeaponEffectManager -{ - public Prototype Prototype; - - public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target) - { - var p = Prototype.Instantiate(); - var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; - var barrel = source.GetBarrel(hp); - p.Barrel = barrel; - p.Source = source; - p.Range = weapon.Range; - p.ImpactIntensity = 1; - p.Target = target; - p.Fire(); - } -} diff --git a/Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs.meta b/Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs.meta deleted file mode 100644 index 8682c9f04..000000000 --- a/Assets/Scripts/Gameplay/Weapons/LightningGunManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9aff863873a6a6d41a619e63a0898c3d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/docs/aetheria-current-codebase-model.md b/docs/aetheria-current-codebase-model.md index 35c953cc4..1d1bb53fd 100644 --- a/docs/aetheria-current-codebase-model.md +++ b/docs/aetheria-current-codebase-model.md @@ -156,24 +156,18 @@ Current Ymir control flow: - The fossil `Projectile`, `GuidedProjectile`, their managers, Unity-side Ymir stepping adapter, and dedicated proof tests are deleted. EveUnity lowers ordinary weapon travel from daemon `shot.receipt` facts. -- Target/zone hit queries call `TryOverlapTargetHulls`, `TryCastTargetHulls`, - `TryOverlapZoneHulls`, or `TryCastZoneHulls`. -- `TryBuildDaemonWorld` builds Ymir bodies from `AetheriaDaemonRenderNativeView` - rather than from Unity `HullCollider` geometry. -- Ymir step/overlap/cast requests execute through the typed - `YmirPhysicsQueries` surface in `YmirPhysicsContracts.cs`. -- Query results are resolved back to Unity presentation hulls through daemon - entity ids, so visual effects still have a GameObject to attach to. +- Fossil laser, lightning, hitscan, and constant weapon effect managers are + also deleted. They no longer cast against Ymir from Unity to choose endpoints + or shield responses; EveUnity consumes the receipt trajectory, impact kind, + intensity, and provider presentation-role assets. +- The remaining Unity `AetheriaYmirPhysicsBridge` lowers clickable presentation + bounds into `YmirPhysicsQueries.CastSphere`; it knows nothing about daemon + entities, hulls, shields, targets, zones, or combat. -This is the right authority direction: Ymir receives bodies derived from daemon -SoA, and Unity hulls are presentation targets. Remaining debt: +This is the right authority direction: daemon physics enters Ymir from daemon +state, while Unity only asks Ymir a local presentation-picking question. +Remaining debt: -- `AetheriaYmirPhysicsBridge` requires daemon `EntityIndex` and - `PhysicsBodyRadius` columns before it builds Ymir bodies; stable entity - identity is required for daemon/Ymir correspondence. -- Ymir query requests no longer use Unity-owned JSON endpoint calls. The - remaining durable target is exposing the same typed query semantics through - CultNet/CultMesh query handles. - Clickable raycasts still construct query bodies from Unity click bounds. That is presentation picking, not simulation authority, but it should stay clearly labeled as renderer/UI picking.