Aetheria/Assets/Scripts/Gameplay/Weapons/ConstantParticleWeapon.cs

63 lines
1.7 KiB
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
Fire control Cut 4, part 2: the last five weapon kinds join FireControl Deletes the last live Physics.* hit queries and every remaining SendHit/ SendSplash call in Assets/Scripts/Gameplay/Weapons: ConstantLaser's RaycastAll, ConstantLightning's SphereCastAll, ConstantParticleWeapon's trigger-collider plumbing, HitscanEffect's RaycastAll, and Mine's blast OverlapSphere. Each becomes presentation only, the same convention Cut 3 gave Projectile/GuidedProjectile/Laser/Lightning: ConstantLaser/ ConstantLightning/HitscanEffect draw to TargetTransform (or out to Range with no target); ConstantParticleWeapon keeps only its visual emission. ConstantWeapon.Execute (previous commit) already rolled the damage before any of these ever draw. Mine keeps its proximity-arming OverlapSphere (Q7: contact detection, not hit detection) but Explode() now calls FireControl.Splash instead of walking colliders and calling SendSplash itself. HullCollider.Hit/Splash/SendHit/SendSplash and their event-arg classes are deleted outright -- their last callers are gone. HullCollider is now purely a physics surface for ship-on-ship collision impulse; no Physics.* query decides damage anywhere in Assets/Scripts/Gameplay/Weapons except Mine's own named exception. Every manager (ConstantLaserManager, ConstantLightningManager, ConstantParticleWeaponManager, HitscanManager) is updated to match: no more Damage/Penetration/Spread/DamageType plumbing into a presentation component that no longer decides anything with it, and HitscanManager now passes ShotId and TargetTransform the way LaserManager already does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 15:17:17 +02:00
// Cut 4 (docs/fire-control-cut.md): the trigger-collider plumbing and SendSplash are deleted -- FireControl
// already rolls this weapon's damage once per GameplaySettings.BeamResolveInterval (ConstantWeapon.Execute)
// before these particles ever collide with anything (R8). What is left is pure visual emission; nothing here
// decides or applies damage any more.
public class ConstantParticleWeapon : MonoBehaviour
{
public ParticleSystem[] Particles;
Fire control Cut 4, part 2: the last five weapon kinds join FireControl Deletes the last live Physics.* hit queries and every remaining SendHit/ SendSplash call in Assets/Scripts/Gameplay/Weapons: ConstantLaser's RaycastAll, ConstantLightning's SphereCastAll, ConstantParticleWeapon's trigger-collider plumbing, HitscanEffect's RaycastAll, and Mine's blast OverlapSphere. Each becomes presentation only, the same convention Cut 3 gave Projectile/GuidedProjectile/Laser/Lightning: ConstantLaser/ ConstantLightning/HitscanEffect draw to TargetTransform (or out to Range with no target); ConstantParticleWeapon keeps only its visual emission. ConstantWeapon.Execute (previous commit) already rolled the damage before any of these ever draw. Mine keeps its proximity-arming OverlapSphere (Q7: contact detection, not hit detection) but Explode() now calls FireControl.Splash instead of walking colliders and calling SendSplash itself. HullCollider.Hit/Splash/SendHit/SendSplash and their event-arg classes are deleted outright -- their last callers are gone. HullCollider is now purely a physics surface for ship-on-ship collision impulse; no Physics.* query decides damage anywhere in Assets/Scripts/Gameplay/Weapons except Mine's own named exception. Every manager (ConstantLaserManager, ConstantLightningManager, ConstantParticleWeaponManager, HitscanManager) is updated to match: no more Damage/Penetration/Spread/DamageType plumbing into a presentation component that no longer decides anything with it, and HitscanManager now passes ShotId and TargetTransform the way LaserManager already does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 15:17:17 +02:00
public EntityInstance Source { get; set; }
public EntityInstance Target { get; set; }
private bool _stopping;
private float _emission;
private void Start()
{
_emission = Particles[0].emission.rateOverTime.constant;
}
private void OnEnable()
{
foreach(var p in Particles)
p.enableEmission = true;
_stopping = false;
}
public void Initialize()
{
foreach(var p in Particles)
{
var main = p.main;
main.simulationSpace = ParticleSystemSimulationSpace.Custom;
main.customSimulationSpace = Source.LocalSpace;
}
Fire control Cut 4, part 2: the last five weapon kinds join FireControl Deletes the last live Physics.* hit queries and every remaining SendHit/ SendSplash call in Assets/Scripts/Gameplay/Weapons: ConstantLaser's RaycastAll, ConstantLightning's SphereCastAll, ConstantParticleWeapon's trigger-collider plumbing, HitscanEffect's RaycastAll, and Mine's blast OverlapSphere. Each becomes presentation only, the same convention Cut 3 gave Projectile/GuidedProjectile/Laser/Lightning: ConstantLaser/ ConstantLightning/HitscanEffect draw to TargetTransform (or out to Range with no target); ConstantParticleWeapon keeps only its visual emission. ConstantWeapon.Execute (previous commit) already rolled the damage before any of these ever draw. Mine keeps its proximity-arming OverlapSphere (Q7: contact detection, not hit detection) but Explode() now calls FireControl.Splash instead of walking colliders and calling SendSplash itself. HullCollider.Hit/Splash/SendHit/SendSplash and their event-arg classes are deleted outright -- their last callers are gone. HullCollider is now purely a physics surface for ship-on-ship collision impulse; no Physics.* query decides damage anywhere in Assets/Scripts/Gameplay/Weapons except Mine's own named exception. Every manager (ConstantLaserManager, ConstantLightningManager, ConstantParticleWeaponManager, HitscanManager) is updated to match: no more Damage/Penetration/Spread/DamageType plumbing into a presentation component that no longer decides anything with it, and HitscanManager now passes ShotId and TargetTransform the way LaserManager already does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 15:17:17 +02:00
var trigger = Particles[0].trigger;
while(trigger.colliderCount > 0)
trigger.RemoveCollider(0);
}
private void Update()
{
if (Source == null) return;
if (_stopping && Particles.All(p=>p.particleCount == 0))
{
GetComponent<Prototype>().ReturnToPool();
return;
}
}
public void Stop()
{
foreach(var p in Particles)
p.enableEmission = false;
_stopping = true;
}
}