forked from illectro/BDArmory
-
Notifications
You must be signed in to change notification settings - Fork 32
TurretAxisManager + Bugfixes #787
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
Draft
BillNyeTheIE
wants to merge
18
commits into
BrettRyland:dev
Choose a base branch
from
BillNyeTheIE:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e81a3ca
Turret Axis Manager
BillNyeTheIE 75a6a7c
Further Work on TurretAxisManager
BillNyeTheIE af0567a
More SendTargetDataToMissile Fixes
BillNyeTheIE 484126d
Remove Factor of 2 for Ping Time
BillNyeTheIE 2855a2b
More Features for Axis Manager
BillNyeTheIE ead935c
Set Up Edge Case Handling for Axis Manager
BillNyeTheIE 01309db
Turret Audio Error Handling
BillNyeTheIE 4f6cc16
Fix MML MissileReferenceTransform Handling
BillNyeTheIE b3390a3
Correct Incorrect Usage of ammoCount in MMR
BillNyeTheIE 3803e83
Fix Team Icon Viewing Dist = Unlimited
BillNyeTheIE 266a9aa
Fix TurretAxisManager Conditional
BillNyeTheIE 6684390
Expand RWR MissileLock Array + Reduce Ping Slot Usage
BillNyeTheIE 7b74f33
Better IR PD Implementation
BillNyeTheIE 838ba91
Fix Various Deficiencies in PD and GMR
BillNyeTheIE ef32775
Use MissileReferenceTransform Where Appropriate
BillNyeTheIE d1cbef8
Re-Organized UpdateRadarTarget
BillNyeTheIE 8b13abc
Fix Some Bullet Detonation Routines
BillNyeTheIE 6c68f04
Merge branch 'dev' into dev
BillNyeTheIE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,7 @@ public bool slavedGuard | |
| [KSPField] public bool deployBlocksYaw = false; // Turret must deploy before yawing, turret must return to yaw standby position to stow/"undeploy". | ||
| [KSPField] public bool deployBlocksPitch = false; // Turret must deploy before pitching, turret must return to pitch standby position to stow/"undeploy". | ||
| public bool isReloading = false; | ||
| float _reloadUntil = 0; | ||
| [KSPField] public bool startsDeployed = false; //Turret starts in deployed position and only uses deploy anim for relaoding. TODO: proper reload anim support for turrets independent of deployAnim | ||
|
|
||
| //animation | ||
|
|
@@ -112,7 +113,7 @@ public bool isDeployed() | |
| //special | ||
| [KSPField] public bool activeMissileOnly = false; | ||
|
|
||
| MissileFire WeaponManager | ||
| public MissileFire WeaponManager | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why |
||
| { | ||
| get | ||
| { | ||
|
|
@@ -123,6 +124,54 @@ MissileFire WeaponManager | |
| } | ||
| MissileFire _weaponManager; | ||
|
|
||
| public float DeployIfBlocking(bool yaw) | ||
| { | ||
| if (!hasDeployAnimation) | ||
| { | ||
| turret.SetDeployFlag(true, true); | ||
| return 0; | ||
| } | ||
|
|
||
| // If not blocking, return 0 without doing anything | ||
| if (!(yaw ? deployBlocksYaw : deployBlocksPitch)) | ||
| { | ||
| if (yaw) | ||
| { | ||
| turret.SetYawDeployFlag(true); | ||
| } | ||
| else | ||
| { | ||
| turret.SetPitchDeployFlag(true); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| bool reloadBlock = deployBlocksReload && isReloading; | ||
|
|
||
| // If no deploy animation or deployed and not reloading | ||
| if (!(deployAnimState.normalizedTime < 1 || reloadBlock)) return 0; | ||
|
|
||
| // If not blocked by reload | ||
| if (!reloadBlock) | ||
| { | ||
| if (deployAnimRoutine != null) | ||
| { | ||
| StopCoroutine(deployAnimRoutine); | ||
| } | ||
|
|
||
| deployAnimRoutine = StartCoroutine(DeployAnimation(true)); | ||
|
|
||
| hasReturned = false; | ||
|
|
||
| return deployAnimState.length - deployAnimState.time; | ||
| } | ||
| else | ||
| { | ||
| // If blocked by reload, return time that reload completes at | ||
| return _reloadUntil - Time.fixedDeltaTime; | ||
| } | ||
| } | ||
|
|
||
| IEnumerator DeployAnimation(bool forward) | ||
| { | ||
| var wait = new WaitForFixedUpdate(); | ||
|
|
@@ -137,13 +186,19 @@ IEnumerator DeployAnimation(bool forward) | |
| } | ||
|
|
||
| deployAnimState.normalizedTime = 1; | ||
|
|
||
| // Unblock turret | ||
| turret.SetDeployFlag(true, true); | ||
| } | ||
| else | ||
| { | ||
| deployAnimState.speed = 0; | ||
|
|
||
| yield return new WaitWhileFixed(() => pausingAfterShot); | ||
|
|
||
| // Block turret prior to undeploy | ||
| turret.SetDeployFlag(!deployBlocksYaw, !deployBlocksPitch); | ||
|
|
||
| while (deployAnimState.normalizedTime > 0) | ||
| { | ||
| deployAnimState.speed = -deployAnimationSpeed; | ||
|
|
@@ -279,7 +334,7 @@ IEnumerator ReturnRoutine() | |
| bool pitch = !turretEnabled || (deployBlocksPitch && deployBlocksReload); | ||
| bool yaw = !turretEnabled || (deployBlocksYaw && deployBlocksReload); | ||
|
|
||
| while (turret != null && !turret.ReturnTurret(pitch, yaw)) | ||
| while (turret != null && !turret.ReturnTurret(pitch, yaw, isReloading)) | ||
| { | ||
| UpdateMissilePositions(); | ||
| yield return new WaitForFixedUpdate(); | ||
|
|
@@ -325,6 +380,7 @@ public override void OnStart(StartState state) | |
| if (tur.Current == null) continue; | ||
| if (tur.Current.turretID != turretID) continue; | ||
| turret = tur.Current; | ||
| turret.turretMissile = this; | ||
| break; | ||
| } | ||
| tur.Dispose(); | ||
|
|
@@ -473,12 +529,34 @@ public void SetSlavedGuard(bool slavedGuard, MissileBase ml) | |
| } | ||
| } | ||
|
|
||
| public bool IsCurrentWMMissile() | ||
| { | ||
| MissileFire wm; | ||
| if (!(wm = WeaponManager)) return false; | ||
|
|
||
| if (!wm.CurrentMissile) return false; | ||
|
|
||
| return slavedGuard || wm.CurrentMissile.GetPartName() == activeMissile.GetPartName(); | ||
| } | ||
|
|
||
| public void SlavedAim() | ||
| { | ||
| if (pausingAfterShot) return; | ||
| bool deployCond = hasDeployAnimation && (deployAnimState.normalizedTime < 1 || isReloading); | ||
| bool deployCond = hasDeployAnimation && (deployAnimState.normalizedTime < 1 || (deployBlocksReload && isReloading)); | ||
|
|
||
| turret.AimToTarget(slavedTargetPosition, !(deployCond && deployBlocksPitch), !(deployCond && deployBlocksYaw), IsCurrentWMMissile()); | ||
| } | ||
|
|
||
| public void SetReloadBlock(float duration) | ||
| { | ||
| // Deploy must block reload and a deploy animation must exist before we block the turret | ||
| if (!(deployBlocksReload && hasDeployAnimation)) return; | ||
|
|
||
| _reloadUntil = Time.fixedDeltaTime + duration; | ||
|
|
||
| turret.AimToTarget(slavedTargetPosition, !(deployCond && deployBlocksPitch), !(deployCond && deployBlocksYaw)); | ||
| // We only block if the respective toggle is also enabled | ||
| if (deployBlocksPitch && turret.pitchAxisManager) turret.pitchAxisManager.SetTurretBlock(_reloadUntil); | ||
| if (deployBlocksYaw && turret.yawAxisManager) turret.yawAxisManager.SetTurretBlock(_reloadUntil); | ||
| } | ||
|
|
||
| const int mouseAimLayerMask = (int)(LayerMasks.Parts | LayerMasks.Scenery | LayerMasks.EVA | LayerMasks.Unknown19 | LayerMasks.Unknown23 | LayerMasks.Wheels); | ||
|
|
@@ -523,8 +601,8 @@ void MouseAim() | |
| FlightCamera.fetch.mainCamera.transform.position; | ||
| } | ||
|
|
||
| bool deployCond = hasDeployAnimation && (deployAnimState.normalizedTime < 1 || isReloading); | ||
| turret.AimToTarget(targetPosition, !(deployCond && deployBlocksPitch), !(deployCond && deployBlocksYaw)); | ||
| bool deployCond = hasDeployAnimation && (deployAnimState.normalizedTime < 1 || (deployBlocksReload && isReloading)); | ||
| turret.AimToTarget(targetPosition, !(deployCond && deployBlocksPitch), !(deployCond && deployBlocksYaw), IsCurrentWMMissile()); | ||
| } | ||
|
|
||
| public void UpdateMissileChildren() | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the reasoning for these being
2 * dataCountas opposed to some other length?(I don't really understand what you're using these for, but hard-coded array sizes are suspicious.)