Missile_lockedonto, second attempt#2042
Conversation
|
|
||
| //Check to make sure we are still being tracked. | ||
| radarsTracking.removeIf(tracker -> !tracker.isValid || (!tracker.aircraftOnRadar.contains(this) && !tracker.groundersOnRadar.contains(this))); | ||
| gunsLockedOn.removeIf(gun -> !gun.isValid || (gun.engineTarget != null && gun.engineTarget.vehicleOn != this)); |
There was a problem hiding this comment.
For this condition, what if the gun's engine target is null (doesn't exist). This logic will not remove it since it returns false.
There was a problem hiding this comment.
Made a commit that changed it a little
| /** | ||
| * Unregisters this gun from the previous target vehicle's gunsLockedOn list. | ||
| */ | ||
| private void unregisterFromPreviousTargetVehicle() { |
There was a problem hiding this comment.
So, I don't see a need to have this, and the code that checks for the gun states to run at the same time. Either the gun can handle registeration internally when things change, or it won't handle it and the vehicle should. Is there a reason you have it check for gun targeting on the vehicle? Did something get de-synced during testing?
There was a problem hiding this comment.
Nuked it and it seems to work fine both singleplayer and dedicated server
| // Check if engine target changed | ||
| if (engineTarget != prevEngineTarget) { | ||
| prevEngineTarget = engineTarget; | ||
| registerWithTargetVehicle(); |
There was a problem hiding this comment.
One final request here. I see that you put this code into a sub-routine, but that doesn't get called from anywhere else. I feel it would be cleaner to just put that sub-routine code here. Once that's done this should be good to merge.
There was a problem hiding this comment.
It is called for though? Or did i misunderstand you?

Variable for when any gun is locked onto your vehicle. Please check it thoroughly because i have no coding knowledge and i relied on AI slopmastery to make it. Also it might have been messed up along the way, but it is functional both single and multi player