Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDorob committed Nov 28, 2024
1 parent 28b16ac commit 97e18f1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<CompCIWSImpactHandler>()?.OnImpact(this, DamageInfo);
Expand Down
18 changes: 9 additions & 9 deletions Source/CombatExtended/CombatExtended/Things/Building_CIWS_CE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
}
#endregion

private List<ThingDef> ignoredDefs = new List<ThingDef>();
public IEnumerable<ThingDef> IgnoredDefsSettings
{
get
{
return ignoredDefs ??= new List<ThingDef>();
}
}
public override void ExposeData()
{
base.ExposeData();
Expand All @@ -45,15 +53,7 @@ public override IEnumerable<Gizmo> GetGizmos()
defaultLabel = "Dialog_ManageCIWS".Translate(),
};
}

private List<ThingDef> ignoredDefs = new List<ThingDef>();
public IEnumerable<ThingDef> IgnoredDefsSettings
{
get
{
return ignoredDefs ??= new List<ThingDef>();
}
}

public override void Tick()
{
base.Tick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ 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<ITargetSearcher> cachedVerbsWithTargetSearcher;

public override Verb AttackVerb
{
get
{
return activeVerb ?? GunCompEq.AllVerbs.FirstOrDefault(x=>x.state == VerbState.Bursting) ?? base.AttackVerb;
}
}
IEnumerable<ITargetSearcher> cachedVerbsWithTargetSearcher;
protected IEnumerable<ITargetSearcher> VerbsWithTargetSearcher => cachedVerbsWithTargetSearcher ??= GunCompEq.AllVerbs.OfType<ITargetSearcher>().ToList();
public override void DrawExtraSelectionOverlays()
{
Expand Down Expand Up @@ -86,5 +81,10 @@ public override IEnumerable<Gizmo> GetGizmos()
}
}
}
public override void ExposeData()
{
base.ExposeData();
Scribe_References.Look(ref activeVerb, nameof(activeVerb));
}
}
}
13 changes: 9 additions & 4 deletions Source/CombatExtended/CombatExtended/Verbs/VerbCIWS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -91,7 +94,6 @@ public override ThingDef Projectile
}
}

protected int maximumPredectionTicks = 40;

public override bool TryCastShot()
{
Expand All @@ -114,6 +116,11 @@ public override bool Available()
}
public abstract class VerbCIWS<TargetType> : VerbCIWS where TargetType : Thing
{
public abstract IEnumerable<TargetType> Targets { get; }
protected abstract IEnumerable<Vector3> TargetNextPositions(TargetType target);




public override bool TryFindNewTarget(out LocalTargetInfo target)
{
Expand Down Expand Up @@ -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<TargetType> 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<Vector3> TargetNextPositions(TargetType target);
public override bool TryFindCEShootLineFromTo(IntVec3 root, LocalTargetInfo targetInfo, out ShootLine resultingLine, out Vector3 targetPos)
{

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

0 comments on commit 97e18f1

Please sign in to comment.