20,741
edits
No edit summary |
|||
| Line 189: | Line 189: | ||
—[[User:5H1N0B1|5H1N0B1]] ([[User_talk:5H1N0B1|Talk]] | [[Special:Contributions/5H1N0B1|contribs]]) 10:40, 05 November 2014 (UTC) | —[[User:5H1N0B1|5H1N0B1]] ([[User_talk:5H1N0B1|Talk]] | [[Special:Contributions/5H1N0B1|contribs]]) 10:40, 05 November 2014 (UTC) | ||
: That sounds good to me - for the sake of simplicity, I would merely add a new method, e.g. "setReferenceFrameCallback()" which takes a callback for getting the origin as a geo.Coord - i.e. usually geo.aircraft_position.latlon() - but could also be an arbitrary AI node instead. To simplify mission specs handling, I'd suggest to use a generic hash for all specs and use the missile name as the identifier, analogous to the ND styles hash, e.g.: | |||
<syntaxhighlight lang="nasal"> | |||
var MissileSpecs = { | |||
## specs for the Aim7 | |||
'Aim-7': { | |||
models: {default:'AIM-7.xml', with_smoke:'AIM-7_smoke.xml' }, | |||
'max-detection-range-nm': 9, | |||
'fov-deg': 25 | |||
}, | |||
## specs for the Aim9 | |||
'Aim9': { | |||
models: {default:'aim-9.xml', with_smoke:'aim-9_smoke.xml' }, | |||
# ... | |||
}, | |||
## you can add other missiles here | |||
}; | |||
</syntaxhighlight> | |||
As you can see, you would have one outer hash named "MissileSpecs", which would contain embedded hashes with specs for missile - all using identical keys, so that you can look up arbitrary specs by doing this: var fov_deg = MissileSpecs['Aim-7']['fov-deg']; | |||
All the if/getprop logic in missile.nas and Load_Missiles.nas can then be removed, and you can add arbitrary other state there, too. | |||
--[[User:Hooray|Hooray]] ([[User talk:Hooray|talk]]) 23:35, 5 November 2014 (UTC) | |||