-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIWS v2 #3534
base: Development
Are you sure you want to change the base?
CIWS v2 #3534
Conversation
Count warmup time when trying to predict position Not tested yet (as well as everything else about CIWS)
MultiVerb turret
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12074143163.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12074185893.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12087826645.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12087876448.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12089209302.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12097015705.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12097281167.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12097480056.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-12097511410.zip |
float speedGain, | ||
float maxSpeed, | ||
int flightTicks) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: It might simplify things to pack all these parameters into a ref struct
and pass that around instead. Right now the full parameter list has to be spelled out in a lot of places.
Pawn pawn = thing2 as Pawn; | ||
if (pawn != null) | ||
{ | ||
if (pawn.RaceProps.Humanlike) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (thing2 is Pawn pawn && pawn.RaceProps.Humanlike)
private Thing TryDropThing(Thing thing, Map map, IntVec3 position) | ||
{ | ||
var contents = (parent as IActiveDropPod)?.Contents; | ||
Rot4 rot = (contents?.setRotation != null) ? contents.setRotation.Value : Rot4.North; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could return early if contents
are null
here and spare a lot of null checks down the line
return targetHeight; | ||
} | ||
protected virtual bool LockRotationAndAngle => numShotsFired > 0; | ||
public virtual void ShiftTarget(ShiftVecReport report, bool calculateMechanicalOnly = false, bool isInstant = false, bool midBurst = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: midBurst
is now unused and could be removed, that could also allow getting rid of the override.
var _target = Targets.Where(x => Props.Interceptable(x.def) && !Props.Ignored.Contains(x.def) && !Turret.IgnoredDefsSettings.Contains(x.def)).Where(x => !IsFriendlyTo(x)).FirstOrDefault(t => | ||
{ | ||
var verb = this; | ||
if (Caster.Map.GetComponent<TurretTracker>().CIWS.Any(turret => turret.currentTargetInt.Thing == t) || ProjectileCE_CIWS.ProjectilesAt(Caster.Map).Any(x => x.intendedTarget.Thing == t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: may need to profile this to ensure the linq isn't an issue
} | ||
targetList.Add(parent); | ||
} | ||
public override void PostDeSpawn(Map map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: does this cover the case where the map itself gets reaped (incident maps)?
return Targets(map).Where(x => x.HasComp<T>()); | ||
} | ||
|
||
public CompProperties_CIWSTarget Props => props as CompProperties_CIWSTarget; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: props getters should always use a (cast)
expression since a type mismatch here would be an unrecoverable error. that also reduces the chance of people then treating the props as nullable and adding unnecessary null checks elsewhere.
} | ||
return targetHeight; | ||
} | ||
protected virtual bool LockRotationAndAngle => numShotsFired > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the previous name MidBurst
is I think more descriptive since this property is used also in shootline checks where it has nothing to do with ballistics. Also this should move up to live alongside the other property declarations.
@@ -969,43 +1046,16 @@ public override bool TryCastShot() | |||
// 6: Interruptible -> stop shooting | |||
// 7: Not interruptible -> shoot along previous line | |||
// 8: else -> stop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these should move into the newly extracted method
} | ||
else // We cannot hit the current target | ||
{ | ||
if (midBurst) // Case 2,3,6,7 | ||
if (!KeepBurstOnNoShootLine(suppressing, out shootLine)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: merge into enclosing block
Additions
Describe new functionality added by your code
Changes
Describe adjustments to existing features made in this merge
References
ToDo
Testing
Check tests you have performed:
Examples
Turrets should use projectiles with thingClass ProjectileCE_CIWS.
You can specify CIWS version in def with CIWSVersion node like this:
CIWS must use Building_CIWS_CE as thingClass
Gun of such CIWS may have few attack verbs unlike usual turret.
Usual attack verb (non CIWS) must be specified first (otherwise turret may ignore it).
Also you may specify CompVerbDisabler in comps to make CIWS disablable.
Example of such gun:
Example of smart rocket, that use specific trajectory worker