-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Implement radar code as a separate component #804
base: master
Are you sure you want to change the base?
Conversation
Add missing return. Other minor fixes.
Introduce the concept of components.
Yes, I like moving things to components. It makes a lot of sense. |
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.
Nice! I'm excited about this new componentized approach. I think that this is what we've been needing for a long time. I look forward to seeing where it goes.
Some of the refactors I have in mind will also be considerably easier if Unit doesn't inherit from 50 million things LOL
Also, convert radar to component standard
Disable radar energy draw for now - game doesn't support it yet.
Cones are in radian and aren't linear. They can't be stores in Resource.
PR is ready for testing. If you intend to test it, please modify aeraturretadvtorpedo in units.json to reduce Max_Cone to 300000000 (300k km). I'll test it over the weekend. @BenjamenMeyer, @stephengtuggy - WRT to the explicit keyword in the constructor above, I'd like more guidance. I've looked at https://stackoverflow.com/a/121163/5276890 and I think I understand. If I have
Also, my example was really of an implicit casting from int to double. Can you think of a scenario where an actual constructor is called? One where we don't want this to work. I'm not seeing the gotcha, that is surely there. |
@royfalk the |
I'm really on the fence here. On the one hand, it is considered good practice. On the other hand, the whole point of Resource is to elegantly wrap int/double. We have a whole bunch of overloaded operators for exactly that reason. I'll think about it some more. |
for now, let's skip the |
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.
I can't play-test but things look okay to me
Pending #1016 merge. |
- Add support for fixing radar - Make max_range a resource - Add better support for int and long resources
I'm going to hold off on merging this until Sunday or so to give people a chance to play test. @evertvorster , @kheckwrecker |
Safe to merge on top of PR #1036 for play testing? |
return true; | ||
} | ||
break; | ||
|
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.
NOTE: This is where Polymorphism helps out since you could just do:
if (unit->Damaged()) {
unit->Repair();
return true;
}
return false;
since of having all the various switch cases. Now the generic Unit
class probably isn't the right level to have that, perhaps a Component
class would be. Hopefully that's where we're eventually heading.
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.
Sort of, but it's a lot more complicated. This code is for components, which sub-class from Component
, not Unit
. What we need is for Component
itself to be a sub-class of Cargo
for this to work.
Except, even then, you'd probably need similar code to tie the GUI element to the Component
.
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.
Actually, I think this is an example of preferring composition over inheritance, which I have seen recommended in several places recently.
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.
Sort of, but it's a lot more complicated. This code is for components, which sub-class from
Component
, notUnit
. What we need is forComponent
itself to be a sub-class ofCargo
for this to work. Except, even then, you'd probably need similar code to tie the GUI element to theComponent
.
yes, Unit
certainly is the right place; it would be good if we could have this pointing at Component
instead so we could do that. I'm sure we'll get there eventually.
@stephengtuggy for the language we work in (C/C++) inheritance is the right tool; we just need to get the codebase to where we can move away from everything using Unit
and using more specific sub-classes appropriate to the different areas - in this case as @royfalk pointed out it's probably Component
.
I do a lot of Go for other stuff; and Go uses Composition instead; at the end of the day it isn't really any different other than that the compiler has to enforce interface more. You can still end up with the same exact issues.
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.
incorrect float implementation
Done. Looks good to me. The only comment I have is that the sensor (radar?) loses focus on occasion. For example, if I hit "n" to navigate to Serenity and start autopiloting there, my VDU would stay on that destination. With this version, it will occasionally switch off to targeting ships that are nearby. It's easy enough to switch back to my planned destination, but it's new behavior, so I thought best to report it. Otherwise, from flying around Cephid-17, looks good. Also, repairing and buying components for my ship worked as expected, as did Basic Repair and Refuel. |
I've seen this as well. I'll have to think about it some more. |
Discovered a new problem while testing. Loaded my saved game, went to Ship Upgrade and my shields show damaged (at 99%) and the fix costs .70. Click on the fix button, and the credits are deducted, but the fix never happens. Can click on fix repeatedly and the credits go down each time, but the repair never happens. Saved game attached. Edit: Just loaded saved game , and the fix on my shields worked fine this time. However, now my Llama is basically unflyable. I was on Atarxia and I picked a patrol mission. I had to scan Atarxia (the military base), but when I launched I was about 800 kilometers away (which was weird), so I turned around to point directly at it and engaged autopilot, with it showing in my VDU. My speed was jumping up and down like crazy, and I was actually accelerating away from my target, while pointed directly at it. So I turned around so it was behind me, but I continued to accelerate away from it at the same speed. |
I think the game can't really lock on serenity because it's too far away (as it should) and when something closer comes along, it auto locks to it. Open an issue so we can make an exception to navigable stuff.
Using your save game, I show damage but no fix button.
I'm not sure how you were able to do this, but I think I know what happened. The shield is somehow saved as 149/150/150. That means that it is currently 149 but it is not damaged. The code incorrectly uses the 149/150 percent to check if damaged. I'll fix this and see if it works for you. WRT to auto pilot, this stuff sometimes happens but is unrelated to the current changes I made to the code. I was unable to reproduce. However, I often overshot Atraxia and the auto pilot had to turn around to get to it. I'm not sure why. |
Will do.
Okay. Every time it happens now (and it happens regularly), I'm able to fix my shield back to 100%. Please let me know when the fix is ready for testing.
Not reliably, unfortunately. I've seen it once more, but then it stopped in the middle of a flight and autopilot resumed as normal. I'll keep watching and see if I can spot a pattern. |
- Calculate percent operational from shield damage and not shield strength. By shield damage I mean that the actual generator sustained damage and is not operating at a 100%. By shield strength I mean the value of the shields after they absorb damage. - Calculate damaged from operational and not call percent. Operational is an internal variable that reports the percent the component is undamaged. Percent is a function that returns an average of the shield strength at the moment.
OK, so I think I figured out what happened. When you dock your ship, it automatically refuels and maxes out your capacitors (including FTL) and shields. I fixed it so illegal values like this will not impact the game. Please test. |
This PR introduces the concept of components - reactor, radar, cloaking device, etc.This allows us to more elegantly move code from unit to components.
It will also allow for the removal of unit superclasses (e.g. movable) and easier upgrade, buy, sell, damage and fix components.
Let's use this to PR (and the cloaking one) discuss the concept of using components as a way forward.Implement radar as a component.
Please answer the following:
Code Changes:
Issues:
I think radar numbers are different from master. Need to verify this.Fixed.The ship loses lock easy. This may have to do with the point above. If the lock cone is no longer 360 degrees, that would probably happen.Fixed.The game crashes on startup. Game randomly crashes on new campaign startup (Radar PR) #1021. aeraturretadvtorpedo (also navpoint.blank and eject.template) have max radar range of 3b and not 300m.