blowfishpro / b9partswitch Goto Github PK
View Code? Open in Web Editor NEWA Kerbal Space Program plugin designed to implement switching of part meshes, resources, and nodes
License: GNU Lesser General Public License v3.0
A Kerbal Space Program plugin designed to implement switching of part meshes, resources, and nodes
License: GNU Lesser General Public License v3.0
In some situations it would be very handy to have a greater degree of precision when adjusting the amount of resources in a tank while working in the VAB/SPH. Right now the increments are (IIRC) 1/6th the tank's volume, which is particularly problematic when trying to adjust the mass of heavier tanks.
Two examples where this would be useful:
The latter example is of particular interest to me, as I've been working on a set of mass simulator parts. The initial version is nearly ready to go, but without the ability to fine-tune the mass, they're not of much use. I'm already using this mod since it allows switching between different ballast materials, and also displays the exact mass of the parts via ModuleB9PartInfo.
I don't know any C#, otherwise I'd make a pull request. Looking at the official API documentation, it seems like this might be possible to implement using the stepIncrement
property of UI_FloatRange
, though I'm pretty far out of my element here.
Hi, thank you for your KSP modding efforts. This is my favorite part switch mod and I would like to see localisation support in it.
KSP now supports many languages and, even if this plugin has not much text in it, it would be really nice to be able to translate it. So everyone can have a UI in their language without mixed words here
and there.
Thank you in advance (even if you are not interested in such a feature) and keep up the good work.
Currently displays all meshes
my simplified reproduction:
I tested with the TweakScale dev version. It worked until B9PartSwitch v1.3.1 and broke in version v1.4.0.
This is risky but potentially incredibly useful. As far as I can tell there are two patterns
Useful to be able to re-order subtypes without breaking craft. Determining the subtype would go like this:
Index would be something like -1 to begin with.
Should also add a uniqueness constraint on subtype names.
.. from 2000-->20
Need to multiply the position by the scale factor
When switching (i.e. from UI), old subtype should just be given a message to deactivate. It will deactivate transforms and nodes and remove resources.
New subtype will be given a similar method to activate.
First time subtype setup will be similar to current methods. Switcher module should probably still hold logic for removing managed but not active resources.
This should fix #22
May or may not be possible
While using a ladder transform/collider as a switcher target works very well in the flight scene, in the VAB the colliders used to specify the ladder become collidable and affect surface attachment.
Repro steps:
I've originally posted bugs on KSP bugtracker, but then realized that the only mod that causes this issue is B9PartSwitch (with many configurations of mods adding B9PartSwitch causes bugs, removing it makes KSP run perfectly).
There are logs, sampling, used mods and other info:
http://bugs.kerbalspaceprogram.com/issues/9721
http://bugs.kerbalspaceprogram.com/issues/9725
This reproduces on OSX (all info is in those invalid bugreports for vanilla KSP).
If you need more info, ask me.
Removing modules (ModuleB9PartInfo for example) causes index mismatch errors if another module occupies the missing module's indexed location. (anything after the missing module is shifted upwards).
When it appears in the prefab but is missing in flight mode, KSP tries to compensate by relocating the loaded modules to another location but this can be disastrous if there was more than one module by that name (multiple generator modules for example. KSP sees that the loaded module occupies a spot that MB9PI occupied in the prefab so it looks for a slot with an identically named module and loads into the first eligible slot that it finds)
If there IS more than one module by that name then they end up getting the wrong data loaded in.
So as an alternative to removing modules outright, how about just disabling it? You can save someone maybe five days worth of troubleshooting.....
The current download has:
"KSP_VERSION" : {
"MAJOR" : 1,
"MINOR" : 5,
"PATCH" :
}
PATCH is missing. This causes an error if you try to parse it:
Unexpected character encountered while parsing value: }. Path 'KSP_VERSION.PATCH', line 18, position 2.
It can probably be removed entirely by putting the code in different places
Easy to reproduce. Create a B9_TANK_TYPE with a resource that does not exist and start KSP. The first exception is thrown at B9PartSwitch.B9TankSettings.ModuleManagerPostLoad()
and there after every part containing a ModuleB9PartSwitch fails to load with System.InvalidOperationException: The tank definitions have not been loaded yet (done after game database load). Perhaps ModuleManager is missing or out of date?
.
I'm hesitant to call this a bug, better to make the game unplayable and force the problem to be fixed, however when the parts fail to load any vessels inflight containing those parts are unloaded potentially ruining a save game. Perhaps it could fail a bit more gracefully. Users commonly overlook dependencies which may contain the needed resource definitions when installing mods.
It needs to take into account the unitsPerVolume of each resource as well, so line 61 should be:
public float ResourceUnitCost => resources.Sum(r => (r.resourceDefinition.unitCost) * (r.unitsPerVolume) );
Need to come up with a UI to warn when dumping resources
It's well known to me by now that B9PS crashes when it determines that it's attempting to assign subtypes to any ModuleB9PartSwitch before the associated tank type exists (in which case, B9PS finds itself adding a null or otherwise invalid subtype). My humble request is for an indication of at least:
Currently, KSP.log is dumped on with a load of ๐ bones lol
Should probably be tied to upgrade nodes
Maybe look into what can happen if the user tries to load a craft with subtypes that aren't unlocked
Just getting around to playing with this feature - very nicely done.
One gripe. In the editor normal and expected behavior when switching types should be filling tanks (unless the type is specifically setup not to be filled), but in flight I can't think of any scenario where filling tanks with a resource that was not already present is desirable. This is basically a cheat since tanks can be refilled by switching. I realize I could avoid this by defining the tank types to be empty by default, but that would leave the user with the annoyance of having to manually fill tanks in the editor.
So I noticed that the actual mod doesn't work AT ALL...
From what i saw in the logs, despite the fact it was in the GameData folder, it did not load at all, as if it didn't exist...
It would be useful to have an option in the module to hide the switcher behind the Advanced Tweakables mode.
This would facilitate complex multi switcher setups and reduce PAW clutter.
Drag cube currently only rendered for initial state, so animating meshes won't work with stock aero
In the stock 1.4 mesh switching, switches that change a node's location rebuild the rocket to reconnect the nodes (instead of leaving them at the original offset). This functionality has been duplicated by DMagic for the Universal Storage plugin, and would be useful for B9 Part Switch.
In the editor, rendering drag cubes for a part or any part above it in the hierarchy will cause its texture switches to get reset. It doesn't change the subtype, and switching to a different subtype and back corrects it.
Reason is that we reset texture switches before the part is cloned, and the part is cloned to produce drag cubes. When the part is cloned normally in the editor, KSP calls OnCopy
which then tells the original to re-apply its texture switches, but this doesn't happen when rendering drag cubes.
Should I be concerned about this?
[WRN 19:53:49.699] [WARNING] [Part bluedog.Apollo.AARDV.Cargo] [ModuleB9PartSwitch 'cargoSwitch'] Only one subtype found, this may lead to unexpected behavior
We use Ore as a placeholder to define the volume on cargo parts. What gets added to the SUBTYPE's depends on what life support mods are installed, if any are.
When list is cleared, clean up components with same gameObject as parent. Also remove ScriptableObject instances if copy flag is set.
Might be breaking the delta-v simulator as it is.
Very long term, somewhat limited use cases but potentially useful and probably not too hard to implement.
Only one module would be able to do this of course.
STR
O
D
Explanation: The second resource already exists, so it is left alone, then the first resource is added to the end of the list, so it appears after
It currently does a fuzzy match. This causes some issues.
Issue reported, we'll see if it gets fixed
Useful to see part's current info:
maxTemp
, if managed by any moduleskinMaxTemp
, if managed by any modulecrashTolerance
, if managed by any moduleSteps to Reproduce
ModuleJettison
affecting drag cubes and ModuleB9PartSwitch
affecting drag cubesModuleJettison
node (so that the jettison object will appear)Observed
Desired
Notes
ModuleJettison
now moves the jettison object to the attached part when the scene loads rather than when it detaches. This means that it cannot affect drag cubes if they are re-rendered, but also since it's outside the part's hierarchy, it won't get duplicated for rendering drag cubes and AssumeDragCubePosition
will disable/enable the real one, causing it to get disabled.Currently it throws exceptions and messes with other stuff
Here:
Identified based on discussion in #78
It doesn't take much time to begin with, but nice to have them all loaded first, rather than when the first object of that type needs to load
When switching back to the default attach node, the orientation read from the prefab is wrong
Can get the previous subtype using the previous value passed when updating. Symmetry can use a special method.
It would be useful to change the stackSymmetry
parameter when using different Subtypes, a PART
-level variable which defines the symmetry number that is used when stack attaching to a part.
This would allow better functionality for symmetric engine clusters with variable node counts, which currently must be set to the lowest common denominator of all available variants for symmetry to work even partially.
ValueParseMap
may not even be necessary
Requested by @ChrisAdderley
When launching the game, I get this warning:
The game does seem to function fine after loading, however.
Relevant portion of the log file:
PartLoader: Compiling Part 'NearFutureConstruction/Parts/Truss/truss-spinal/truss-spinal-01/truss-spinal-01'
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
DontDestroyOnLoad only work for root GameObjects or components on root GameObjects.
(Filename: Line: 481)
Warning on PartSubtype: Subtype has no name
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Warning on PartSubtype: Subtype has no name
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Warning on PartSubtype: Subtype has no name
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
DontDestroyOnLoad only work for root GameObjects or components on root GameObjects.
(Filename: Line: 481)
[ERROR] [Part truss-spinal-01] [ModuleB9PartSwitch 'meshSwitch3'] Duplicate subtype names detected: System.String[]
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Warning on PartSubtype: Subtype has no name
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Warning on PartSubtype: Subtype has no name
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Warning on PartSubtype: Subtype has no name
I can provide the full log if you want it, should I also bring this up with NearFutureConstuction?
STR
Physics now break and the ModuleB9PartSwitch has no subtypes.
Will have to investigate if root parts are loaded differently.
Current workaround: use something else as the root part.
Keeps number of subtypes down on many switchers, aids ease-of-use
Current thinking: each child module registers itself to the "parent" to which it adds volume. Subtype changes on the child trigger a volume update on the parent.
Things to consider
Start()
so that OnStart()
will be run on all modules firstvolumeAddedToParent
field that specifies the volume it adds to the parent (different from its actual volume)A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.