Skip to content

Commit

Permalink
Merge pull request #3520 from CombatExtended-Continued/verb-remove-un…
Browse files Browse the repository at this point in the history
…used-code

Remove unused verb-related code
  • Loading branch information
N7Huntsman authored Nov 26, 2024
2 parents 983bb6a + c85aefb commit fc80189
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 106 deletions.
21 changes: 0 additions & 21 deletions Source/CombatExtended/CombatExtended/Verbs/VerbPropertiesCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;

Expand All @@ -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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -1291,34 +1270,6 @@ private bool CanHitFromCellIgnoringRange(Vector3 shotSource, LocalTargetInfo tar
return false;
}

private bool IntercepterBlockingTarget(Vector3 source, Vector3 target)
{
List<Thing> list = Caster.Map.listerThings.ThingsInGroup(ThingRequestGroup.ProjectileInterceptor);
for (int i = 0; i < list.Count; i++)
{
Thing thing = list[i];
CompProjectileInterceptor interceptor = thing.TryGetComp<CompProjectileInterceptor>();
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)
{
Expand Down
35 changes: 0 additions & 35 deletions Source/CombatExtended/CombatExtended/Verbs/Verb_ShootCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompSuppressable>()?.isSuppressed ?? false;

Expand Down Expand Up @@ -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;
}

/// <summary>
/// Checks to see if enemy is blind before shooting
/// </summary>
Expand Down

0 comments on commit fc80189

Please sign in to comment.