Skip to content
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

Open
wants to merge 129 commits into
base: Development
Choose a base branch
from
Open

CIWS v2 #3534

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
1752cf0
Comps for CIWS (used my comps from vanilla CIWS - https://github.com/…
MaxDorob Jul 27, 2024
898c4a9
Different projectile def for CIWS-targets
MaxDorob Jul 27, 2024
d7115a0
Moved some code to base class
MaxDorob Jul 27, 2024
e085a99
Projectile movement improvments
MaxDorob Jul 28, 2024
f686568
Virtual check collision between
MaxDorob Jul 28, 2024
3cf9ab5
Moved unused calculations to Init
MaxDorob Jul 28, 2024
793cda2
Invoking OnImpact of CIWSTarget
MaxDorob Aug 11, 2024
87b8ab3
Moved moving-forward code to ProjectilePropertiesCE
MaxDorob Aug 11, 2024
5c7a14b
Moved NextPositions to ProjectilePropetiesCE
MaxDorob Aug 11, 2024
f7c929d
Returned NextPositions to ProjectileCE
MaxDorob Aug 15, 2024
10ae251
2D segments intersection check
MaxDorob Aug 15, 2024
343c4cd
NextPosition Changes
MaxDorob Aug 15, 2024
c9d620c
Initial commit for CIWS verb
MaxDorob Aug 15, 2024
b4b8bd1
Initial commit for CIWS projectile and turret
MaxDorob Aug 15, 2024
ed04020
Name fix
MaxDorob Aug 15, 2024
45f241c
Another name fix
MaxDorob Aug 15, 2024
6b84eb7
Temp CalculatePointForPreemptiveFire
MaxDorob Aug 15, 2024
afc4458
Improved base ciws tick
MaxDorob Aug 15, 2024
5746b92
TryFindShotLine for projectile
MaxDorob Aug 15, 2024
c3ca285
Development merge
MaxDorob Oct 31, 2024
725c3db
Moved PenetrationAmount to ProjectileCE again
MaxDorob Oct 31, 2024
c2d4704
Moved "MoveForward" logic to ProjectilePropetiesCE again
MaxDorob Oct 31, 2024
d23f77d
CompCIWSTarget targeting method call
MaxDorob Oct 31, 2024
315718d
selecting CIWS projectile if possible for CIWS verbs
MaxDorob Oct 31, 2024
6638563
Warning about wrong projectile
MaxDorob Oct 31, 2024
4da40bd
Comp -> Verb
MaxDorob Oct 31, 2024
ee992cf
IgnoredDefs changes
MaxDorob Oct 31, 2024
e6007a7
Projectile -> ProjectileCE
MaxDorob Oct 31, 2024
ffc8f51
Validate target moved to base class
MaxDorob Oct 31, 2024
c082f99
Moved projectile code
MaxDorob Oct 31, 2024
b40bea4
One more check
MaxDorob Oct 31, 2024
b55d9d1
Another rename
MaxDorob Nov 1, 2024
269efab
Active verb selecting
MaxDorob Nov 1, 2024
0a6db24
PrimaryVerb -> AttackVerb
MaxDorob Nov 1, 2024
29f2db2
Corrected check
MaxDorob Nov 1, 2024
62a2671
Not calling base findLine
MaxDorob Nov 2, 2024
95befe3
Seconds -> ticks
MaxDorob Nov 2, 2024
de887b6
Fixed reneder issue with shells
MaxDorob Nov 4, 2024
acc4576
Do not return target for deafult CIWS target
MaxDorob Nov 5, 2024
3a7be12
ExactPosToDrawPos method
MaxDorob Nov 5, 2024
8cc5b29
Corrected projectile targeting
MaxDorob Nov 5, 2024
25e3a95
Moved warmup ticks to property
MaxDorob Nov 5, 2024
043ee13
Corrected skip ticks (not sure if it's needed cuz it's always 0)
MaxDorob Nov 6, 2024
177b345
Test CIWS turret
MaxDorob Nov 6, 2024
a3f4c65
Splited CompCIWSTarget to targeting and impact handle comps
MaxDorob Nov 6, 2024
0889401
Splited impact logic
MaxDorob Nov 6, 2024
dac1499
Access modifier
MaxDorob Nov 6, 2024
1248f5c
Collision logic
MaxDorob Nov 6, 2024
01b9b93
Virtual CanCollideWith
MaxDorob Nov 6, 2024
5d5c713
Removed CIWS code from base projectile
MaxDorob Nov 6, 2024
96e7fcc
Additional check (not sure if'll help)
MaxDorob Nov 6, 2024
70e129e
Revert "Different projectile def for CIWS-targets"
MaxDorob Nov 6, 2024
be59f64
Projectile targeting fix
MaxDorob Nov 6, 2024
8d9b630
XML - Impact handler for bullets
MaxDorob Nov 6, 2024
2866d22
Missing class
MaxDorob Nov 6, 2024
a30bbc7
Moved trajectory code to special worker
MaxDorob Nov 7, 2024
b60ad5b
Debug things
MaxDorob Nov 7, 2024
dbbd4c2
Another ballistic changes
MaxDorob Nov 7, 2024
3fcdf67
Some manipulations with tick offset
MaxDorob Nov 7, 2024
f1152d5
Draw CIWS projectile exactly where it is
MaxDorob Nov 7, 2024
14464e1
Fixed turret not using default verb
MaxDorob Nov 7, 2024
79afc9d
TurretTop rotation fix
MaxDorob Nov 7, 2024
f6fb81d
Impact and vfx position fix
MaxDorob Nov 7, 2024
576961e
Draw pos of skyfallers
MaxDorob Nov 8, 2024
e69476f
Code reuse for skyfallers
MaxDorob Nov 8, 2024
82bfe0b
Overrided ShiftTarget variable calculations
MaxDorob Nov 8, 2024
5e49c86
Removed log
MaxDorob Nov 8, 2024
085f5d8
Unlocked rotation for CIWS
MaxDorob Nov 8, 2024
2d4eeba
Moved GetFlightTime and DistanceTraveled to trajecory worker
MaxDorob Nov 14, 2024
ee6f093
Moved some calculations to separate methods
MaxDorob Nov 14, 2024
bdaa20f
Trajectory worker with exactpos drawing
MaxDorob Nov 14, 2024
5423f86
Do not aim if CIWS
MaxDorob Nov 14, 2024
42dfe71
ImpactSomething condition property
MaxDorob Nov 14, 2024
842b1b5
Original ShiftTarget
MaxDorob Nov 14, 2024
66fccb2
Angle and rotation now calculated w/o ShiftReport
MaxDorob Nov 15, 2024
73f5a18
Corrected ticksToSkip calculations
MaxDorob Nov 15, 2024
3da4d58
Shot rotation now use variable instead of field
MaxDorob Nov 15, 2024
4056655
Target projectile height included
MaxDorob Nov 15, 2024
bc15746
Parameters change
MaxDorob Nov 15, 2024
b053b76
Aim CIWS-trajectory point instead of intersection point
MaxDorob Nov 16, 2024
e7bca9d
Moved GetTargetHeight to base class
MaxDorob Nov 16, 2024
a4c8d45
Skyfaller impact handler patch
MaxDorob Nov 16, 2024
5bd107f
Returning more accurate position from TryFindCEShootLineFromTo (can b…
MaxDorob Nov 16, 2024
c0694fd
Corrected shoot position if no shootLine found
MaxDorob Nov 17, 2024
719332d
Hold fire for CIWS
MaxDorob Nov 18, 2024
49cbf31
Targeting by CompCIWSTarget + CompCIWSTarget_Skyfaller (not tested)
MaxDorob Nov 18, 2024
8b32cc7
Changed folder of verbs
MaxDorob Nov 18, 2024
369e91a
Ignored defs
MaxDorob Nov 19, 2024
8f6032b
Effecter
MaxDorob Nov 19, 2024
0553cca
CIWS settings dialog
MaxDorob Nov 20, 2024
7c4c72a
Fixed non-lerped moving (not sure if even worked before).
MaxDorob Nov 21, 2024
414eb6f
Moved rotation and angle calculations to trajectory worker
MaxDorob Nov 25, 2024
9fafa61
Some optimizations
MaxDorob Nov 25, 2024
4064638
Small mortar fix
MaxDorob Nov 27, 2024
994dc3d
Speed gain
MaxDorob Nov 27, 2024
e2b55f6
Fixed prediction
MaxDorob Nov 27, 2024
d096114
Direct shooting version
MaxDorob Nov 27, 2024
8e3e106
Rotation fix
MaxDorob Nov 28, 2024
8601c76
Speed fix
MaxDorob Nov 28, 2024
a3027de
Removed useless class
MaxDorob Nov 28, 2024
28b16ac
Disabled debug
MaxDorob Nov 28, 2024
97e18f1
Some cleanup
MaxDorob Nov 28, 2024
4f3bc13
reverted change for other branch
MaxDorob Nov 28, 2024
38c6d7a
Backward compatibility for vehicles
MaxDorob Nov 28, 2024
0a7de3b
Whitespace
MaxDorob Nov 28, 2024
b377260
Swap thingClass and trajectory workers if not CIWS projectile (can be…
MaxDorob Nov 29, 2024
ba5e06a
Whitespace
MaxDorob Nov 29, 2024
3989b82
Health points
MaxDorob Nov 29, 2024
94293e4
Shadow rotation fix
MaxDorob Nov 30, 2024
79a7393
Removed tryPredict
MaxDorob Nov 30, 2024
d62426d
Checks for if Verb available (will be used with #3575 PR)
MaxDorob Nov 30, 2024
ea64d73
Development merge
MaxDorob Nov 30, 2024
b7af0ea
CIWS icons
MaxDorob Nov 30, 2024
e2f2864
CIWS text
MaxDorob Nov 30, 2024
8a20185
Fixed warning
MaxDorob Nov 30, 2024
1ddbee5
Default values for hold fire
MaxDorob Nov 30, 2024
fd9c036
KPV now able to target skyfallers
MaxDorob Nov 30, 2024
dec17b4
Fixed whitespaces
MaxDorob Nov 30, 2024
6d99b3d
TryDropThing cleanup
MaxDorob Dec 2, 2024
945b9f1
Another cleanup
MaxDorob Dec 2, 2024
373edb0
typo
MaxDorob Dec 2, 2024
ab5151a
convert -> cast
MaxDorob Dec 3, 2024
db11cc0
Variable names
MaxDorob Dec 3, 2024
ea5b006
Created MidBurst property
MaxDorob Dec 3, 2024
22060a6
Removed unused param
MaxDorob Dec 3, 2024
87e172f
Moved new properties to other properties
MaxDorob Dec 3, 2024
87d2cf3
Moved comments
MaxDorob Dec 3, 2024
c617309
Cleanup
MaxDorob Dec 3, 2024
9cc2ed9
Removed linq
MaxDorob Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Defs/Ammo/Advanced/8x35mmCharged.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<defName>Bullet_8x35mmCharged</defName>
<label>8x35mm Charged bullet</label>
<projectile Class="CombatExtended.ProjectilePropertiesCE">
<CIWSVersion>Bullet_8x35mmChargedCIWS</CIWSVersion>
<damageAmountBase>19</damageAmountBase>
<secondaryDamage>
<li>
Expand Down Expand Up @@ -142,6 +143,24 @@
</projectile>
</ThingDef>

<ThingDef Name="Bullet_8x35mmChargedCIWS" ParentName="Base8x35mmChargedBullet">
<defName>Bullet_8x35mmChargedCIWS</defName>
<thingClass>CombatExtended.ProjectileCE_CIWS</thingClass>
<label>8x35mm Charged bullet</label>
<projectile Class="CombatExtended.ProjectilePropertiesCE">
<damageAmountBase>19</damageAmountBase>
<secondaryDamage>
<li>
<def>Bomb_Secondary</def>
<amount>6</amount>
</li>
</secondaryDamage>
<armorPenetrationSharp>16</armorPenetrationSharp>
<armorPenetrationBlunt>57.6</armorPenetrationBlunt>
<trajectoryWorker>CombatExtended.LerpedTrajectoryWorker_ExactPosDrawing</trajectoryWorker>
</projectile>
</ThingDef>

<!-- ==================== Recipes ========================== -->

<RecipeDef ParentName="ChargeAmmoRecipeBase">
Expand Down
5 changes: 5 additions & 0 deletions Defs/Ammo/AmmoBases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
<projectile Class="CombatExtended.ProjectilePropertiesCE">
<explosionDamageFalloff>true</explosionDamageFalloff>
</projectile>
<comps>
<li Class="CombatExtended.CompProperties_CIWSImpactHandler">
<compClass>CombatExtended.CompCIWSImpactHandler_Projectile</compClass>
</li>
</comps>
</ThingDef>

<ThingDef Class="CombatExtended.AmmoDef" Name="BaseFragment" ParentName="BaseBulletCE" Abstract="True">
Expand Down
59 changes: 59 additions & 0 deletions Defs/ThingDefs_Buildings/Building_CIWS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<!--=============== Blaster CIWS ===============-->

<ThingDef ParentName="TurretAutoBase">
<defName>CIWS_Blaster</defName>
<thingClass>CombatExtended.Building_CIWS_CE</thingClass>
<label>charge blaster CIWS</label>
<constructionSkillPrerequisite>8</constructionSkillPrerequisite>
<graphicData>
<texPath>Things/Building/Turrets/MachineGunBase</texPath>
<shadowData>
<volume>(0.27,0.25,0.27)</volume>
<offset>(0,0,0)</offset>
</shadowData>
</graphicData>
<uiIconPath>UI/Icons/Turrets/ChargeBlaster_uiIcon</uiIconPath>
<statBases>
<WorkToBuild>23000</WorkToBuild>
<MaxHitPoints>150</MaxHitPoints>
<Mass>20</Mass>
<Bulk>25</Bulk>
<AimingAccuracy>0.75</AimingAccuracy>
<ShootingAccuracyTurret>1.25</ShootingAccuracyTurret>
<NightVisionEfficiency>0.5</NightVisionEfficiency>
</statBases>
<techLevel>Spacer</techLevel>
<comps>
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>400</basePowerConsumption>
</li>
</comps>
<description>Automatic turret equipped with a charge blaster.</description>
<costList>
<Steel>125</Steel>
<Plasteel>40</Plasteel>
<ComponentIndustrial>6</ComponentIndustrial>
<ComponentSpacer>1</ComponentSpacer>
</costList>
<building>
<turretGunDef>Gun_CIWSBlasterTurret</turretGunDef>
<ai_combatDangerous>true</ai_combatDangerous>
</building>
<designatorDropdown>CE_AutoTurrets</designatorDropdown>
<placeWorkers>
<li>PlaceWorker_TurretTop</li>
<li>PlaceWorker_ShowTurretRadius</li>
</placeWorkers>
<researchPrerequisites>
<li>CE_ChargeTurret</li>
</researchPrerequisites>
<minifiedDef>MinifiedThing</minifiedDef>
</ThingDef>



</Defs>
1 change: 1 addition & 0 deletions Defs/ThingDefs_Buildings/Buildings_Turrets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
<ThingDef ParentName="TurretMannedBuildableBase">
<defName>Turret_KPV</defName>
<label>KPV machine gun</label>
<thingClass>CombatExtended.Building_CIWS_CE</thingClass>
<constructionSkillPrerequisite>7</constructionSkillPrerequisite>
<graphicData>
<texPath>Things/Building/Turrets/KPV_base</texPath>
Expand Down
82 changes: 82 additions & 0 deletions Defs/ThingDefs_Misc/Weapons_CIWS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Defs>

<!-- ================== Blaster Turret ================== -->

<ThingDef ParentName="BaseAutoTurretGun">
<defName>Gun_CIWSBlasterTurret</defName>
<label>blaster turret gun</label>
<graphicData>
<texPath>Things/Building/Turrets/BlasterTurret_Top</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
<description>Charge blaster attached to a turret mount.</description>
<soundInteract>Interact_ChargeRifle</soundInteract>
<statBases>
<SightsEfficiency>1</SightsEfficiency>
<ShotSpread>0.06</ShotSpread>
<SwayFactor>0.86</SwayFactor>
<RangedWeapon_Cooldown>0.36</RangedWeapon_Cooldown>
<Mass>10</Mass>
</statBases>
<verbs>
<li Class="CombatExtended.VerbPropertiesCE">
<recoilAmount>0.90</recoilAmount>
<verbClass>CombatExtended.Verb_ShootCE</verbClass>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_8x35mmCharged</defaultProjectile>
<warmupTime>1.3</warmupTime>
<range>55</range>
<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
<burstShotCount>10</burstShotCount>
<soundCast>Shot_ChargeBlaster</soundCast>
<soundCastTail>GunTail_Heavy</soundCastTail>
<muzzleFlashScale>9</muzzleFlashScale>
<recoilPattern>Mounted</recoilPattern>
</li>
<li Class="CombatExtended.VerbProperties_CIWSProjectile">
<verbClass>CombatExtended.VerbCIWSProjectile</verbClass>
<recoilAmount>0.90</recoilAmount>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_8x35mmCharged</defaultProjectile>
<warmupTime>0.4</warmupTime>
<range>105</range>
<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
<burstShotCount>10</burstShotCount>
<soundCast>Shot_ChargeBlaster</soundCast>
<soundCastTail>GunTail_Heavy</soundCastTail>
<muzzleFlashScale>9</muzzleFlashScale>
<recoilPattern>Mounted</recoilPattern>
<holdFireLabel>HoldCloseInProjectilesFire</holdFireLabel>
<holdFireDesc>HoldCloseInProjectilesFireDesc</holdFireDesc>
</li>
<li Class="CombatExtended.VerbProperties_CIWSSkyfaller">
<verbClass>CombatExtended.VerbCIWSSkyfaller</verbClass>
<recoilAmount>0.90</recoilAmount>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_8x35mmCharged</defaultProjectile>
<warmupTime>0.4</warmupTime>
<range>105</range>
<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
<burstShotCount>10</burstShotCount>
<soundCast>Shot_ChargeBlaster</soundCast>
<soundCastTail>GunTail_Heavy</soundCastTail>
<muzzleFlashScale>9</muzzleFlashScale>
<recoilPattern>Mounted</recoilPattern>
<holdFireLabel>HoldCloseInSkyfallersFire</holdFireLabel>
</li>
</verbs>
<comps>
<li Class="CombatExtended.CompProperties_AmmoUser">
<magazineSize>100</magazineSize>
<reloadTime>7.8</reloadTime>
<ammoSet>AmmoSet_8x35mmCharged</ammoSet>
</li>
<li>
<compClass>CombatExtended.CompVerbDisabler</compClass>
</li>
</comps>
</ThingDef>


</Defs>
17 changes: 17 additions & 0 deletions Defs/ThingDefs_Misc/Weapons_Turrets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@
<muzzleFlashScale>16</muzzleFlashScale>
<recoilPattern>Mounted</recoilPattern>
</li>
<li Class="CombatExtended.VerbProperties_CIWSSkyfaller">
<verbClass>CombatExtended.VerbCIWSSkyfaller</verbClass>
<recoilAmount>1.43</recoilAmount>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_145x114mm_FMJ</defaultProjectile>
<warmupTime>0.8</warmupTime>
<range>125</range>
<ticksBetweenBurstShots>6</ticksBetweenBurstShots>
<burstShotCount>15</burstShotCount>
<soundCast>HeavyMG</soundCast>
<soundCastTail>GunTail_Heavy</soundCastTail>
<muzzleFlashScale>16</muzzleFlashScale>
<recoilPattern>Mounted</recoilPattern>
</li>
</verbs>
<comps>
<li Class="CombatExtended.CompProperties_AmmoUser">
Expand All @@ -297,6 +311,9 @@
<aimedBurstShotCount>5</aimedBurstShotCount>
<aiAimMode>SuppressFire</aiAimMode>
</li>
<li>
<compClass>CombatExtended.CompVerbDisabler</compClass>
</li>
</comps>
<modExtensions>
<li Class="CombatExtended.GunDrawExtension">
Expand Down
12 changes: 12 additions & 0 deletions Languages/English/Keyed/Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,17 @@
<!-- Shield Information -->
<CE_Shield_Coverage>Shield coverage</CE_Shield_Coverage>
<CE_Shield_Coverage_Desc>Body parts protected from ranged and melee attacks by the shield.</CE_Shield_Coverage_Desc>

<!--CIWS-->
<CIWSSettings_Copy>Copy</CIWSSettings_Copy>
<CIWSSettings_Paste>Paste</CIWSSettings_Paste>
<CIWSSettings_AvailableTargets>Available targets</CIWSSettings_AvailableTargets>
<CIWSSettings_IgnoredTargets>Ignored targets</CIWSSettings_IgnoredTargets>
<HoldCloseInProjectilesFire>Hold fire - projectiles</HoldCloseInProjectilesFire>
<HoldCloseInProjectilesFireDesc>Ignore incoming projectiles</HoldCloseInProjectilesFireDesc>
<HoldCloseInSkyfallersFire>Hold fire - skyfallers</HoldCloseInSkyfallersFire>
<HoldCloseInSkyfallersFireDesc>Ignore landing skyfallers and drop pods</HoldCloseInSkyfallersFireDesc>
<Dialog_ManageCIWS>Configure CIWS</Dialog_ManageCIWS>
<Dialog_ManageCIWSDesc>Change available and ignored targets for selected CIWS</Dialog_ManageCIWSDesc>

</LanguageData>
13 changes: 13 additions & 0 deletions Languages/Russian/Keyed/Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,17 @@
<!--<CE_NoLineOfSight>Нет прямой видимости</CE_NoLineOfSight>-->
<!--<CE_MakeLoadout>Снарядить</CE_MakeLoadout>-->


<!--CIWS-->
<CIWSSettings_Copy>Копировать</CIWSSettings_Copy>
<CIWSSettings_Paste>Вставить</CIWSSettings_Paste>
<CIWSSettings_AvailableTargets>Доступные цели</CIWSSettings_AvailableTargets>
<CIWSSettings_IgnoredTargets>Игнорировать</CIWSSettings_IgnoredTargets>
<HoldCloseInProjectilesFire>Остановить огонь - снаряды</HoldCloseInProjectilesFire>
<HoldCloseInProjectilesFireDesc>Игнорировать летящие снаряды</HoldCloseInProjectilesFireDesc>
<HoldCloseInSkyfallersFire>Остановить огонь - транспорт</HoldCloseInSkyfallersFire>
<HoldCloseInSkyfallersFireDesc>Игнорировать транспорт и другие летящие объекты</HoldCloseInSkyfallersFireDesc>
<Dialog_ManageCIWS>Настройка ПВО</Dialog_ManageCIWS>
<Dialog_ManageCIWSDesc>Настроить доступные и игнорируемые цели</Dialog_ManageCIWSDesc>

</LanguageData>
25 changes: 25 additions & 0 deletions Patches/Core/Skyfallers/SkyfallerBase.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Patch>

<!-- Skyfallers -->

<Operation Class="PatchOperationConditional">
<xpath>Defs/ThingDef[@Name="SkyfallerBase"]/comps</xpath>
<nomatch Class="PatchOperationAdd">
<xpath>Defs/ThingDef[@Name="SkyfallerBase"]</xpath>
<value>
<comps />
</value>
</nomatch>
</Operation>

<Operation Class="PatchOperationAdd">
<xpath>Defs/ThingDef[@Name="SkyfallerBase"]/comps</xpath>
<value>
<li Class="CombatExtended.CompProperties_CIWSImpactHandler">
<compClass>CombatExtended.CompCIWSImpactHandler_Skyfaller</compClass>
<HP>22</HP>
</li>
</value>
</Operation>
</Patch>
91 changes: 91 additions & 0 deletions Source/CombatExtended/CombatExtended/CE_Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,35 @@ public static float DistanceToSegment(this Vector3 point, Vector3 lineStart, Vec
return Mathf.Sqrt(dx * dx + dz * dz);
}

/// <summary>
/// Finds intersection point for two segments
/// </summary>
/// <param name="A">First point of first segment</param>
/// <param name="B">Second point of first segment</param>
/// <param name="C">First point of second segment</param>
/// <param name="D">Second point of second segment</param>
/// <param name="result">Intersection point or <see cref="Vector2.negativeInfinity"/></param>
/// <returns>True if intersects, false if not</returns>
public static bool TryFindIntersectionPoint(Vector2 A, Vector2 B, Vector2 C, Vector2 D, out Vector2 result)
{
float x1 = A.x, y1 = A.y, x2 = B.x, y2 = B.y, x3 = C.x, y3 = C.y, x4 = D.x, y4 = D.y;
var det = ((x4 - x3) * (y2 - y1) - (y4 - y3) * (x2 - x1));
if (Mathf.Abs(det) < 0.0000001f)
{
result = Vector2.negativeInfinity;
return false;
}
var alpha = ((x4 - x3) * (y3 - y1) - (y4 - y3) * (x3 - x1)) / det;
var beta = ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / det;
if (alpha < 0.0f || alpha > 1.0f || beta < 0.0f || beta > 1.0f)
{
result = Vector2.negativeInfinity;
return false;
}
result = new Vector2(x1 + alpha * (x2 - x1), y1 + alpha * (y2 - y1));
return true;
}

public static Vector3 ToVec3Gridified(this Vector3 originalVec3)
{
Vector2 tempVec2 = new Vector2(originalVec3.normalized.x, originalVec3.normalized.z);
Expand Down Expand Up @@ -1696,5 +1725,67 @@ public static object LaunchProjectileCE(ThingDef projectileDef,
}

public static FactionStrengthTracker GetStrengthTracker(this Faction faction) => Find.World.GetComponent<WorldStrengthTracker>().GetFactionTracker(faction);

internal static IEnumerable<Thing> ContainedThings(this IThingHolder thingHolder)
{
if (thingHolder == null)
{
yield break;
}
var heldThings = thingHolder.GetDirectlyHeldThings();
if (heldThings != null)
{
foreach (var thing in heldThings)
{
if (thing is IThingHolder childThingHolder && (thing is Skyfaller || thing is IActiveDropPod))
{
foreach (var childThing in ContainedThings(childThingHolder))
{
yield return childThing;
}
if (thing is IActiveDropPod dropPod)
{
foreach (var childThing in ContainedThings(dropPod.Contents))
{
yield return childThing;
}
}
}
else if (thing != null)
{
yield return thing;
}
}
}
}
internal static T ElementAtOrLast<T>(this IEnumerable<T> enumerable, int index)
{
var source = enumerable.GetEnumerator();
T current = source.Current;
for (int i = 0; i < index; i++)
{
if (!source.MoveNext())
{
break;
}
current = source.Current;
}
return current;
}
public static Vector3 DrawPosSinceTicks(this Skyfaller thing, int ticksAmount)
{
thing.ticksToImpact -= ticksAmount;
var result = thing.DrawPos;
thing.ticksToImpact += ticksAmount;
return result;
}
public static IEnumerable<Vector3> DrawPositions(this Skyfaller skyfaller)
{
int max = skyfaller.ticksToImpact;
for (int i = 1; i <= max; i++)
{
yield return skyfaller.DrawPosSinceTicks(i);
}
}
}
}
Loading
Loading