2026-08-10 14:57:50 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using CultMath;
|
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
|
|
|
|
using CultMath.UnityBridge;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using static CultMath.math;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using Random = UnityEngine.Random;
|
|
|
|
|
|
|
|
|
|
|
|
public class Mine : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public GridObject GridObject;
|
|
|
|
|
|
public MeshRenderer MeshRenderer;
|
|
|
|
|
|
public int EmissionSubmesh;
|
|
|
|
|
|
public AnimationCurve EmissionCurve;
|
|
|
|
|
|
public float ActiveCycleDuration;
|
|
|
|
|
|
public float ArmedCycleDuration;
|
|
|
|
|
|
public float ActiveEmission;
|
|
|
|
|
|
public float ArmedEmission;
|
|
|
|
|
|
public Prototype HitEffect;
|
|
|
|
|
|
public float Lifetime;
|
|
|
|
|
|
|
|
|
|
|
|
public float ActivationDelay;
|
|
|
|
|
|
public float BlastRange;
|
|
|
|
|
|
public float BlastDelay;
|
|
|
|
|
|
|
|
|
|
|
|
private float _startTime;
|
|
|
|
|
|
private float _blastTime;
|
|
|
|
|
|
private bool _blastCountdown;
|
|
|
|
|
|
private bool _active;
|
|
|
|
|
|
private Material _material;
|
|
|
|
|
|
private float _pulseLerp;
|
|
|
|
|
|
private float _emission;
|
|
|
|
|
|
public float Damage { get; set; }
|
|
|
|
|
|
public DamageType DamageType { get; set; }
|
|
|
|
|
|
public EntityInstance Source { get; set; }
|
|
|
|
|
|
public float Range { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
_material = MeshRenderer.materials[EmissionSubmesh];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
_startTime = Time.time;
|
|
|
|
|
|
_blastCountdown = false;
|
|
|
|
|
|
_active = false;
|
|
|
|
|
|
_emission = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
var position = transform.position;
|
|
|
|
|
|
|
|
|
|
|
|
if (Time.time - _startTime > ActivationDelay && !_active)
|
|
|
|
|
|
{
|
|
|
|
|
|
_active = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(_active)
|
|
|
|
|
|
{
|
|
|
|
|
|
_emission = lerp(_emission, _blastCountdown ? ArmedEmission : ActiveEmission, Time.deltaTime * 10);
|
|
|
|
|
|
_pulseLerp += Time.deltaTime / (_blastCountdown ? ArmedCycleDuration : ActiveCycleDuration);
|
|
|
|
|
|
_pulseLerp %= 1;
|
|
|
|
|
|
if(!_blastCountdown)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var collider in Physics.OverlapSphere(position, BlastRange, 1))
|
|
|
|
|
|
{
|
|
|
|
|
|
var hull = collider.GetComponent<HullCollider>();
|
|
|
|
|
|
if (hull)
|
|
|
|
|
|
{
|
|
|
|
|
|
_blastCountdown = true;
|
|
|
|
|
|
_blastTime = Time.time + BlastDelay;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((position - Source.transform.position).magnitude > Range ||
|
|
|
|
|
|
Time.time - _startTime > Lifetime ||
|
|
|
|
|
|
_blastCountdown && Time.time > _blastTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
Explode();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
_material.SetFloat("_Emission", _emission * EmissionCurve.Evaluate(_pulseLerp));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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, Q7): the arming OverlapSphere above stays -- that is contact detection,
|
2026-09-26 01:17:19 +02:00
|
|
|
|
// not hit detection. Blast damage is not: it goes through the same FireControl.Detonate every blast-shaped
|
|
|
|
|
|
// weapon uses now (12.4(b) renamed Splash), over the zone's own planar entities, not a Unity collider
|
|
|
|
|
|
// query. Presentation (ShowHit) goes with the query it depended on -- nothing here decides who was hit any
|
|
|
|
|
|
// more, so nothing here can point a hit effect at them; a future pass can rebuild that off
|
|
|
|
|
|
// FireControl-published state if the mine ever ships (R9 keeps it regardless). F12-6: BlastRange stays a
|
|
|
|
|
|
// presentation-side input -- Mine has no catalog weapon record carrying Fuse/BlastRadius.
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public void Explode()
|
|
|
|
|
|
{
|
|
|
|
|
|
var position = transform.position;
|
2026-09-26 01:17:19 +02:00
|
|
|
|
FireControl.Detonate(Source.Entity.Zone, position.ToCultMath().xz, BlastRange, Damage, DamageType);
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
var ht = HitEffect.Instantiate<Transform>();
|
|
|
|
|
|
ht.position = position;
|
|
|
|
|
|
GetComponent<Prototype>().ReturnToPool();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|