Jump to content

[WIP] Advanced Reaction Control


Recommended Posts

I'm looking to try and improve the stock reaction control systems, specifically by adding more diverse thrusters and to allow some tweaking to their performance. So far I've modeled and textured a set of RCS thrusters that I am reasonably satisfied with, and are fairly similar to the stock variants in terms of polygon count, size, and texture resolution. I've kind of hit a wall as far as modeling and texturing is concerned, so it would help me out to have some feedback on what I've done so far.

Javascript is disabled. View full album

I've yet to do anything with the reaction wheels, but I'm starting to work on writing a plugin to handle tweaking of the RCS thrusters. I'm not familiar with Assembly yet, so I'm currently only using a modified version of TweakableRCS by Toadicus. It probably won't even work as it is now, but I thought I'd include it in case someone would be interested (or willing to offer any tips).

// TweakableRCS © 2014 toadicus
//
// This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a
// copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

using KSP;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace AdvancedRCS
{
public class ModuleAdvancedRCS : PartModule
{
protected ModuleRCS RCSModule;

// Stores whether the RCS block should start enabled or not.
[KSPField(isPersistant = true, guiName = "Thruster", guiActive = false, guiActiveEditor = true)]
[UI_Toggle(enabledText = "Enabled", disabledText = "Disabled")]
public bool startEnabled;
// Stores the last state of startEnabled so we can tell if it's changed.
protected bool startEnabledState;

// Stores our ISP modifier for the reaction control thruster.
[KSPField(isPersistant = true, guiName = "Catalyst Mass", guiActiveEditor = true, guiActive = true)]
[UI_FloatRange(minValue = 0.005f, maxValue = 0.025f, stepIncrement = 0.005f)]
public float catalystMass;

// Stores our thrust modifier for the reaction control thruster.
[KSPField(isPersistant = true, guiName = "Thruster Upgrade Factor", guiActiveEditor = true, guiActive = true)]
[UI_FloatRange(minValue = 0.25f, maxValue = 2.00f, stepIncrement = 0.25f)]
public float thrustModifier;

protected float baseThrusterISP;
protected float baseThrusterPower;
protected float baseThrusterMass;

// Stores the initial values for the ISP and thrust modifiers.
public ModuleAdvancedRCS()
{
this.startEnabled = true;
this.catalystMass = 0.015f;
this.thrustModifier = 1.00f;
}

public override void OnStart(StartState state)
{
base.OnStart(state);

this.RCSModule = base.part.Modules.OfType<ModuleRCS>().FirstOrDefault();

this.startEnabledState = !this.startEnabled;

this.baseThrusterPower = this.RCSModule.thrusterPower;
this.baseThrusterISP = this.RCSModule.thrusterISP0;
this.baseThrusterMass = this.RCSModule.thrusterMass;
}

// Runs late in the update cycle
public void LateUpdate()
{
// If we're in the editor...
if (HighLogic.LoadedSceneIsEditor)
{
// ...and if our startEnabled state has changed...
if (this.startEnabled != this.startEnabledState)
{
// ...refresh startEnabledState
this.startEnabledState = this.startEnabled;

// ...and if we're starting enabled...
if (this.startEnabled)
{
// ...set the reaction control module to active
this.RCSModule.isEnabled = true;
}
// ...otherwise, we're starting disabled...
else
{
// ...set the reaction control module to disabled
this.RCSModule.isEnabled = false;
}
}
}

if (HighLogic.LoadedSceneIsFlight)
{
this.RCSModule.thrusterPower = this.baseThrusterPower * this.thrustModifier;
// The ISP modifier is a logrithmic function, with a range from approximately 75.3% to 111.5% of the original value.
this.RCSModule.thrusterISP0 = this.baseThrusterISP0 * (LN(this.catalystMass) * 0.225f + 1.945f);
// Overrides the thruster mass based on a linear function of the chosen options.
this.RCSModule.thrusterMass = this.baseThrusterMass * (this.thrustModifier * 0.6f + 0.4f) + (this.catalystMass - 0.015f);

foreach (FXGroup fx in this.RCSModule.thrusterFX)
{
fx.Power *= this.thrustModifier / 2.0f;
}
}
}
}
}

Cheers!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...