diff --git a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE_CIWS.cs b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE_CIWS.cs index d54ae9ae47..c35fc71fa6 100644 --- a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE_CIWS.cs +++ b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE_CIWS.cs @@ -51,6 +51,15 @@ public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) public virtual float CollideDistance => (def.projectile as ProjectilePropertiesCE)?.collideDistance ?? 1f; public virtual float ImpactChance => (def.projectile as ProjectilePropertiesCE)?.impactChance ?? 1f; + protected override bool ShouldCollideWithSomething => ExactPosition.y <= 0f; + + public override Quaternion DrawRotation + { + get + { + return Quaternion.LookRotation((NextPositions.FirstOrDefault() - ExactPosition).Yto0()); + } + } public override void Tick() { ticksToImpact++; //do not allow it hit zero @@ -83,16 +92,7 @@ protected override bool CanCollideWith(Thing thing, out float dist) return false; } - - public override Quaternion DrawRotation - { - get - { - return Quaternion.LookRotation((NextPositions.FirstOrDefault() - ExactPosition).Yto0()); - } - } - - protected override bool ShouldCollideWithSomething => ExactPosition.y <= 0f; + public override void Impact(Thing hitThing) { hitThing?.TryGetComp()?.OnImpact(this, DamageInfo); diff --git a/Source/CombatExtended/CombatExtended/Things/Building_CIWS_CE.cs b/Source/CombatExtended/CombatExtended/Things/Building_CIWS_CE.cs index 0b9abc89dd..07d21fcefe 100644 --- a/Source/CombatExtended/CombatExtended/Things/Building_CIWS_CE.cs +++ b/Source/CombatExtended/CombatExtended/Things/Building_CIWS_CE.cs @@ -27,6 +27,14 @@ public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) } #endregion + private List ignoredDefs = new List(); + public IEnumerable IgnoredDefsSettings + { + get + { + return ignoredDefs ??= new List(); + } + } public override void ExposeData() { base.ExposeData(); @@ -45,15 +53,7 @@ public override IEnumerable GetGizmos() defaultLabel = "Dialog_ManageCIWS".Translate(), }; } - - private List ignoredDefs = new List(); - public IEnumerable IgnoredDefsSettings - { - get - { - return ignoredDefs ??= new List(); - } - } + public override void Tick() { base.Tick(); diff --git a/Source/CombatExtended/CombatExtended/Things/Building_Turret_MultiVerbs.cs b/Source/CombatExtended/CombatExtended/Things/Building_Turret_MultiVerbs.cs index d8bc521758..56dabb1c95 100644 --- a/Source/CombatExtended/CombatExtended/Things/Building_Turret_MultiVerbs.cs +++ b/Source/CombatExtended/CombatExtended/Things/Building_Turret_MultiVerbs.cs @@ -11,13 +11,9 @@ namespace CombatExtended public class Building_Turret_MultiVerbs : Building_TurretGunCE { - public override void ExposeData() - { - base.ExposeData(); - Scribe_References.Look(ref activeVerb, nameof(activeVerb)); - } - Verb activeVerb; + IEnumerable cachedVerbsWithTargetSearcher; + public override Verb AttackVerb { get @@ -25,7 +21,6 @@ public override Verb AttackVerb return activeVerb ?? GunCompEq.AllVerbs.FirstOrDefault(x=>x.state == VerbState.Bursting) ?? base.AttackVerb; } } - IEnumerable cachedVerbsWithTargetSearcher; protected IEnumerable VerbsWithTargetSearcher => cachedVerbsWithTargetSearcher ??= GunCompEq.AllVerbs.OfType().ToList(); public override void DrawExtraSelectionOverlays() { @@ -86,5 +81,10 @@ public override IEnumerable GetGizmos() } } } + public override void ExposeData() + { + base.ExposeData(); + Scribe_References.Look(ref activeVerb, nameof(activeVerb)); + } } } diff --git a/Source/CombatExtended/CombatExtended/Verbs/VerbCIWS.cs b/Source/CombatExtended/CombatExtended/Verbs/VerbCIWS.cs index 524679b20e..956f758202 100644 --- a/Source/CombatExtended/CombatExtended/Verbs/VerbCIWS.cs +++ b/Source/CombatExtended/CombatExtended/Verbs/VerbCIWS.cs @@ -17,11 +17,15 @@ public abstract class VerbCIWS : Verb_ShootCE, ITargetSearcher, IVerbDisableable { protected bool debug; protected Texture2D icon; + protected int maximumPredectionTicks = 40; + public virtual bool HoldFire { get; set; } public VerbProperties_CIWS Props => verbProps as VerbProperties_CIWS; public virtual string HoldFireLabel => Props.holdFireLabel; public virtual string HoldFireDesc => Props.holdFireDesc; + public Building_CIWS_CE Turret => Caster as Building_CIWS_CE; + public virtual Texture2D HoldFireIcon { get @@ -76,7 +80,6 @@ public virtual void ShowTrajectories() return (new Vector2(firstPos.x, firstPos.z), new Vector2(secondPos.x, secondPos.z)); } - public Building_CIWS_CE Turret => Caster as Building_CIWS_CE; public override ThingDef Projectile { get @@ -91,7 +94,6 @@ public override ThingDef Projectile } } - protected int maximumPredectionTicks = 40; public override bool TryCastShot() { @@ -114,6 +116,11 @@ public override bool Available() } public abstract class VerbCIWS : VerbCIWS where TargetType : Thing { + public abstract IEnumerable Targets { get; } + protected abstract IEnumerable TargetNextPositions(TargetType target); + + + public override bool TryFindNewTarget(out LocalTargetInfo target) { @@ -148,9 +155,7 @@ public override bool TryFindNewTarget(out LocalTargetInfo target) return false; } protected virtual bool IsFriendlyTo(TargetType thing) => !thing.HostileTo(Caster); - public abstract IEnumerable Targets { get; } //public override bool ValidateTarget(LocalTargetInfo target, bool showMessages = true) => target.Thing is TargetType && TryFindCEShootLineFromTo(Caster.Position, target, out _, out _) && base.ValidateTarget(target, showMessages); - protected abstract IEnumerable TargetNextPositions(TargetType target); public override bool TryFindCEShootLineFromTo(IntVec3 root, LocalTargetInfo targetInfo, out ShootLine resultingLine, out Vector3 targetPos) { diff --git a/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs b/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs index e02a6f4f8b..9185662260 100644 --- a/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs +++ b/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs @@ -349,10 +349,6 @@ public override void WarmupComplete() ); } - public virtual Vector3 GetTargetLoc(LocalTargetInfo target, int sinceTicks) - { - return target.Thing?.TrueCenter() ?? target.Cell.ToVector3Shifted(); //report.targetPawn != null ? report.targetPawn.DrawPos + report.targetPawn.Drawer.leaner.LeanOffset * 0.5f : report.target.Cell.ToVector3Shifted(); - } public virtual float GetTargetHeight(LocalTargetInfo target, Thing cover, bool roofed, Vector3 targetLoc) { float targetHeight = 0f;