Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » Stars! Nova - Development » Item.Mass - should this be an abstract property?
Item.Mass - should this be an abstract property? Tue, 07 February 2012 14:51 Go to previous message
ekolis is currently offline ekolis

 
Petty Officer 2nd Class
Stars! Nova developer
Stars! Nova developer

Messages: 51
Registered: May 2006
Location: Cincinnati, OH, USA

As I was looking through the code, I found that lots of things inherit from the Item class, which has a public Mass field. This includes fleets and fleet intel, which makes the field somewhat problematic. After all, the mass of a fleet is a computed value - the sum of the masses of all constituent ships. But this is never initialized, so fleets and fleet intel have zero mass! This is even handled inconsistently in the GUI: a fleet report shows its mass as zero, but the "my fleets" list shows the appropriate mass, so the calculation is being done - it's just being done inconsistently.

I think this could be solved by making Item's Mass field an abstract property instead. Then ships could implement it by checking their design, and designs could implement it by summing the masses of their components, and fleets could implement it by summing the masses of their ships.

If this causes performance issues, the values could always be lazy-loaded and cached, but I doubt this will be a problem to begin with.

Also, Item has a number of other public fields which I haven't looked into, but I suspect some of them might warrant similar refactoring.

Thoughts? Concerns?



Mr. Flibble says...
Game over, boys!

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Production classes - IProductionUnit and derivates
Next Topic: Spam posts
Goto Forum:
  


Current Time: Fri Mar 29 11:29:37 EDT 2024