From c85aefb121bc8d3b14174ff05c444866dccd5b32 Mon Sep 17 00:00:00 2001 From: mszabo Date: Wed, 30 Oct 2024 00:53:48 +0100 Subject: [PATCH] Remove unused verb-related code Verb classes contain a good deal of unused code. Remove it to avoid confusion. --- .../CombatExtended/Verbs/VerbPropertiesCE.cs | 21 -------- .../Verbs/Verb_LaunchProjectileCE.cs | 51 +------------------ .../CombatExtended/Verbs/Verb_ShootCE.cs | 35 ------------- 3 files changed, 1 insertion(+), 106 deletions(-) diff --git a/Source/CombatExtended/CombatExtended/Verbs/VerbPropertiesCE.cs b/Source/CombatExtended/CombatExtended/Verbs/VerbPropertiesCE.cs index 525a9b5aba..21312e035f 100644 --- a/Source/CombatExtended/CombatExtended/Verbs/VerbPropertiesCE.cs +++ b/Source/CombatExtended/CombatExtended/Verbs/VerbPropertiesCE.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using RimWorld; using Verse; using UnityEngine; @@ -15,29 +14,9 @@ public class VerbPropertiesCE : VerbProperties public float recoilAmount = 0; public float indirectFirePenalty = 0; public float circularError = 0; - public float meleeArmorPenetration = 0; - public float firingOffset = 0.19f; public int ticksToTruePosition = 5; public bool ejectsCasings = true; public bool ignorePartialLoSBlocker = false; public bool interruptibleBurst = true; - - public float AdjustedArmorPenetrationCE(Verb ownerVerb, Pawn attacker) - { - var toolCE = (ToolCE)ownerVerb.tool; - if (ownerVerb.verbProps != this) - { - Log.ErrorOnce("Tried to calculate armor penetration for a verb with different verb props. verb=" + ownerVerb, 9865767); - return 0f; - } - if (ownerVerb.EquipmentSource != null && ownerVerb.EquipmentSource.def.IsWeapon) - { - return toolCE.armorPenetration * ownerVerb.EquipmentSource.GetStatValue(CE_StatDefOf.MeleePenetrationFactor); - } - else - { - return toolCE.armorPenetration; - } - } } } diff --git a/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs b/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs index b77b26fccd..5336478f0d 100644 --- a/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs +++ b/Source/CombatExtended/CombatExtended/Verbs/Verb_LaunchProjectileCE.cs @@ -17,14 +17,6 @@ namespace CombatExtended { public class Verb_LaunchProjectileCE : Verb { - #region Constants - - // Cover check constants - private const float distToCheckForCover = 3f; // How many cells to raycast on the cover check - private const float segmentLength = 0.2f; // How long a single raycast segment is - //private const float shotHeightFactor = 0.85f; // The height at which pawns hold their guns - - #endregion #region Fields @@ -75,14 +67,6 @@ public class Verb_LaunchProjectileCE : Verb public Pawn ShooterPawn => CasterPawn ?? CE_Utility.TryGetTurretOperator(caster); public Thing Shooter => ShooterPawn ?? caster; - public override float EffectiveRange - { - get - { - return base.EffectiveRange; - } - } - public override int ShotsPerBurst { get @@ -1276,12 +1260,7 @@ private bool CanHitFromCellIgnoringRange(Vector3 shotSource, LocalTargetInfo tar goodDest = IntVec3.Invalid; return false; } - // DISABLED: reason is testing a better alternative.. - //if (ShooterPawn != null && !Caster.Faction.IsPlayerSafe() && IntercepterBlockingTarget(shotSource, targ.CenterVector3)) - //{ - // goodDest = IntVec3.Invalid; - // return false; - //} + if (CanHitCellFromCellIgnoringRange(shotSource, targ.Cell, targ.Thing)) { goodDest = targ.Cell; @@ -1291,34 +1270,6 @@ private bool CanHitFromCellIgnoringRange(Vector3 shotSource, LocalTargetInfo tar return false; } - private bool IntercepterBlockingTarget(Vector3 source, Vector3 target) - { - List list = Caster.Map.listerThings.ThingsInGroup(ThingRequestGroup.ProjectileInterceptor); - for (int i = 0; i < list.Count; i++) - { - Thing thing = list[i]; - CompProjectileInterceptor interceptor = thing.TryGetComp(); - if (!interceptor.Active) - { - continue; - } - float d1 = Vector3.Distance(source, thing.Position.ToVector3()); - if (d1 < interceptor.Props.radius + 1) - { - continue; - } - if (Vector3.Distance(target, thing.Position.ToVector3()) < interceptor.Props.radius) - { - return true; - } - if (thing.Position.ToVector3().DistanceToSegment(source, target, out _) < interceptor.Props.radius) - { - return true; - } - } - return false; - } - // Added targetThing to parameters so we can calculate its height protected virtual bool CanHitCellFromCellIgnoringRange(Vector3 shotSource, IntVec3 targetLoc, Thing targetThing = null) { diff --git a/Source/CombatExtended/CombatExtended/Verbs/Verb_ShootCE.cs b/Source/CombatExtended/CombatExtended/Verbs/Verb_ShootCE.cs index fdae41ceb4..dc1b5636d5 100644 --- a/Source/CombatExtended/CombatExtended/Verbs/Verb_ShootCE.cs +++ b/Source/CombatExtended/CombatExtended/Verbs/Verb_ShootCE.cs @@ -123,14 +123,6 @@ public float AimAngle } } - public float SpreadDegrees - { - get - { - return (EquipmentSource?.GetStatValue(CE_StatDefOf.ShotSpread) ?? 0) * (projectilePropsCE != null ? projectilePropsCE.spreadMult : 0f); - } - } - // Whether our shooter is currently under suppressive fire private bool IsSuppressed => ShooterPawn?.TryGetComp()?.isSuppressed ?? false; @@ -268,33 +260,6 @@ public override void VerbTickCE() } } - public virtual ShiftVecReport SimulateShiftVecReportFor(LocalTargetInfo target, AimMode aimMode) - { - IntVec3 targetCell = target.Cell; - ShiftVecReport report = new ShiftVecReport(); - - report.target = target; - report.aimingAccuracy = AimingAccuracy; - report.sightsEfficiency = SightsEfficiency; - if (ShooterPawn != null && !ShooterPawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight)) - { - report.sightsEfficiency = 0; - } - report.shotDist = (targetCell - caster.Position).LengthHorizontal; - report.maxRange = EffectiveRange; - report.lightingShift = CE_Utility.GetLightingShift(Shooter, LightingTracker.CombatGlowAtFor(caster.Position, targetCell)); - - if (!caster.Position.Roofed(caster.Map) || !targetCell.Roofed(caster.Map)) //Change to more accurate algorithm? - { - report.weatherShift = 1 - caster.Map.weatherManager.CurWeatherAccuracyMultiplier; - } - report.shotSpeed = ShotSpeed; - report.swayDegrees = SwayAmplitudeFor(aimMode); - float spreadmult = projectilePropsCE != null ? projectilePropsCE.spreadMult : 0f; - report.spreadDegrees = (EquipmentSource?.GetStatValue(CE_StatDefOf.ShotSpread) ?? 0) * spreadmult; - return report; - } - /// /// Checks to see if enemy is blind before shooting ///