Jump to content

jgjiscool

Members
  • Posts

    846
  • Joined

  • Last visited

Posts posted by jgjiscool

  1. Finally it will be possible! You will be able to shut down engines when you don\'t need them, and start them back up when you do... WITHOUT JUST STOPPING THE THRUST!!! Big Red Button Pressers presents to you:

    Start-Stop Plugin

    It\'s still a work in progress, but here it is so far:

    F8Vcl.jpg

    Download Links:

    https://dl.dropbox.com/u/59317800/BRBP_LFEControl.dll

    This version hopefully works for 0.16. I haven\'t tested it so let me know if it works or not.

    http://dl.dropbox.com/u/59317800/BRBP%20LFE%20Control%20Part%20Class%20Only.zip

    This version creates a new part class that stops the override of the main engines. Use this if you use another plugin to control your engines or you don\'t want this ridiculous function on the other engines.

    http://dl.dropbox.com/u/59317800/BRBP%20LFE%20Complete%20Override.zip

    This version creates a complete override of the existing LiquidEngine part class giving Start-Stop functions to any engine. It does not appear to work with other plugins that take exclusive control of the engines.

    by_nc_sa.gif

    License: Attribution-Noncommercial-Share Alike (BY-NC-SA)


    using System;
    using System.Collections.Generic;

    /*
    LIQUID ENGINE CONTROL PLUGIN
    Created By: Jayson Grieve (jgjiscool)
    Credit to: N3X15
    Cephei

    Description: This is the part for the budding plane engineers! It allows you to disable parts that you aren\'t using
    and reactivate them later!

    License: Creative Commons Attribution ShareAlike 3.0
    */

    // The Separate Part Class has LiquidEngineControlONLY instead of LiquidEngine
    public class LiquidEngine : Part
    {
    private Rect windowPos;
    protected float inFL;
    public float maxThrust = 200f;
    public float fuelConsumption = 8f;
    public float heatProduction = 370f;
    public float gimbalRange = 2.5f;
    public Vector3 thrustVector = Vector3.up;
    public float minThrust;
    public float gimbalAngleH;
    public float gimbalAngleV;
    protected Vector3 thrVector;
    private RaycastHit hit;
    public bool thrustVectoringCapable;
    protected float thrust;
    private FXGroup activeGroup;
    private VInfoBox tempIndicator;
    protected Part fuelSource;
    protected Transform gimbal;
    protected Quaternion initRot;
    protected static int guiQueueSpot = 2;
    private int myguiQueueSpot;
    private void WindowGUI(int windowID)
    {
    GUI.DragWindow(new Rect(0, 0, 10000, 20));
    GUIStyle mySty = new GUIStyle(GUI.skin.button);
    mySty.normal.textColor = mySty.focused.textColor = Color.white;
    mySty.hover.textColor = mySty.active.textColor = Color.yellow;
    mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green;
    mySty.padding = new RectOffset(8, 8, 8, 8);
    GUILayout.BeginVertical();
    if (GUILayout.Button('Stop', mySty, GUILayout.ExpandWidth(true)))
    {
    this.deactivate();
    }
    if (GUILayout.Button('Start', mySty, GUILayout.ExpandWidth(true)))
    {
    this.force_activate();
    }
    if (GUILayout.Button('Close', mySty, GUILayout.ExpandWidth(true)))
    {
    RenderingManager.RemoveFromPostDrawQueue(myguiQueueSpot, new Callback(drawGUI));
    }
    GUILayout.EndVertical();

    }
    protected override void onCtrlUpd(FlightCtrlState ctrlState)
    {
    this.thrust = (this.maxThrust - this.minThrust) * ctrlState.mainThrottle + this.minThrust;
    this.gimbalAngleH = ctrlState.yaw * this.gimbalRange;
    this.gimbalAngleV = ctrlState.pitch * this.gimbalRange;
    }
    private void drawGUI()
    {
    GUI.skin = HighLogic.Skin;
    windowPos = GUILayout.Window(1, windowPos, WindowGUI, 'Engine Control', GUILayout.MinWidth(150));
    }
    void OnMouseUpAsButton() {
    if (inFL == 1f)
    {
    RenderingManager.AddToPostDrawQueue(myguiQueueSpot, new Callback(drawGUI));
    }
    }
    protected override bool onPartActivate()
    {
    if ((UnityEngine.Object)this.fuelSource == (UnityEngine.Object)null)
    { this.deactivate(); inFL = 0; RenderingManager.RemoveFromPostDrawQueue(myguiQueueSpot, new Callback(drawGUI)); }
    this.stackIcon.SetIconColor(XKCDColors.AcidGreen);
    return true;
    }
    protected override void onActiveFixedUpdate()
    {
    if (fuelSource.GetType().Name == 'FuelTank')
    {

    }
    else if ((this.parent.parent.name) == 'FuelTank')
    {
    if (this.parent.fuelCrossFeed == true)
    {
    this.fuelSource = this.parent.parent;
    }
    }

    this.activeGroup.Power = Mathf.Max(Mathf.Min(this.thrust / (this.maxThrust * 0.5f), 1.75f), 0.5f);
    if (!this.RequestFuel((Part)this, (float)((double)this.fuelConsumption * (double)Time.deltaTime * ((double)this.thrust / (double)this.maxThrust)), Part.getFuelReqId()) && !this.RequestFuel((Part)this, (float)((double)this.fuelConsumption * (double)Time.deltaTime * ((double)this.thrust / (double)this.maxThrust)), Part.getFuelReqId()))
    {
    this.deactivate();
    }
    else
    {
    this.thrVector = this.transform.rotation * this.thrustVector;
    if (this.thrustVectoringCapable)
    this.thrustVectoring();
    if ((double)this.thrust > 0.0)
    {
    this.Rigidbody.AddForceAtPosition(this.thrVector * this.thrust, this.transform.position, ForceMode.Force);
    Debug.DrawRay(this.transform.position + this.Rigidbody.velocity * Time.deltaTime, -this.thrVector, XKCDColors.RedOrange);
    if (Physics.Raycast(this.transform.position, -this.thrVector, out this.hit, 10f, 524289) && (bool)((UnityEngine.Object)this.hit.collider.transform.root.GetComponent<Part>()))
    {
    MonoBehaviour.print((object)('Exhaust damage on ' + this.hit.collider.transform.root.gameObject.name));
    this.hit.collider.transform.root.GetComponent<Part>().temperature += this.heatProduction * (this.thrust / this.maxThrust) * Time.deltaTime;
    this.hit.rigidbody.AddForceAtPosition(-this.thrVector * this.thrust, this.hit.point, ForceMode.Force);
    FlightLogger.ReportEvent(new EventReport(FlightEvents.SPLASHDAMAGE, (Part)this, this.hit.collider.transform.root.gameObject.name, this.name, 0, string.Empty));
    }
    }
    LiquidEngine liquidengine = this;
    double num = (double)liquidengine.temperature + (double)this.heatProduction * ((double)this.thrust / (double)this.maxThrust) * (double)Time.deltaTime;
    liquidengine.temperature = (float)num;
    if ((double)this.thrust == 0.0)
    {
    if (this.activeGroup.Active)
    this.activeGroup.setActive(false);
    }
    else if (!this.activeGroup.Active)
    this.activeGroup.setActive(true);
    if ((double)this.temperature / (double)this.maxTemp >= 0.699999988079071)
    {
    if (this.tempIndicator == null)
    {
    this.tempIndicator = this.stackIcon.DisplayInfo();
    XKCDColors.NextColorAlpha = 0.6f;
    this.tempIndicator.SetMsgBgColor(XKCDColors.DarkRed);
    this.tempIndicator.SetMsgTextColor(XKCDColors.OrangeYellow);
    this.tempIndicator.SetMessage('Overheat!');
    this.tempIndicator.SetProgressBarBgColor(XKCDColors.DarkRed);
    this.tempIndicator.SetProgressBarColor(XKCDColors.OrangeYellow);
    XKCDColors.NextColorAlpha = 1f;
    }
    this.tempIndicator.SetValue(this.temperature / this.maxTemp, 0.7f, 1f);
    }
    else
    {
    if (this.tempIndicator == null)
    return;
    this.stackIcon.RemoveInfo(this.tempIndicator);
    this.tempIndicator = (VInfoBox)null;
    }
    }
    }
    protected void onDeactivate()
    {
    RenderingManager.RemoveFromPostDrawQueue(myguiQueueSpot, new Callback(drawGUI));
    this.stackIcon.SetIconColor(XKCDColors.Blue);
    this.stackIcon.ClearInfoBoxes();
    this.tempIndicator = (VInfoBox)null;
    }
    protected override void onFlightStart()
    {
    inFL = 1f;
    myguiQueueSpot = guiQueueSpot;
    guiQueueSpot += 1;
    this.activeGroup = this.findFxGroup('active');
    this.gimbal = this.transform.FindChild('model').FindChild('obj_gimbal');
    if ((UnityEngine.Object)this.gimbal != (UnityEngine.Object)null)
    this.initRot = this.gimbal.localRotation;
    this.fuelSource = this.parent;
    }
    protected override void onPartStart()
    {
    this.stackIcon.SetIcon(DefaultIcons.LIQUID_ENGINE);
    print('Liquid Engine Control Plugin Part Loaded');
    if ((windowPos.x == 0) && (windowPos.y == 0))
    {
    windowPos = new Rect(Screen.width / 2, Screen.height / 2, 10, 10);
    }
    }
    protected override void onPartDestroy()
    {
    RenderingManager.RemoveFromPostDrawQueue(myguiQueueSpot, new Callback(drawGUI));
    }
    protected override void onDecouple(float breakForce)
    {
    inFL = 0;
    this.deactivate();
    RenderingManager.RemoveFromPostDrawQueue(myguiQueueSpot, new Callback(drawGUI));
    }
    private void thrustVectoring()
    {
    this.thrVector = Quaternion.AngleAxis(this.gimbalAngleV, this.localRoot.transform.right) * this.thrVector;
    this.thrVector = Quaternion.AngleAxis(this.gimbalAngleH, this.localRoot.transform.forward) * this.thrVector;
    using (List<GameObject>.Enumerator enumerator = this.activeGroup.fxEmitters.GetEnumerator())
    {
    while (enumerator.MoveNext())
    enumerator.Current.transform.up = this.thrVector;
    }
    if (!((UnityEngine.Object)this.gimbal != (UnityEngine.Object)null))
    return;
    this.gimbal.localRotation = this.initRot * Quaternion.AngleAxis(this.gimbalAngleV, this.gimbal.InverseTransformDirection(this.localRoot.transform.right)) * Quaternion.AngleAxis(this.gimbalAngleH, this.gimbal.InverseTransformDirection(this.localRoot.transform.forward));
    }

    public override void OnDrawStats()
    {
    object[] objArray = new object[8];
    int index1 = 0;
    string str1 = 'Max Thrust: ';
    objArray[index1] = (object)str1;
    int index2 = 1;
    objArray[index2] = (object)(ValueType)this.maxThrust;
    int index3 = 2;
    string str2 = '\nMin Thrust: ';
    objArray[index3] = (object)str2;
    int index4 = 3;
    objArray[index4] = (object)(ValueType)this.minThrust;
    int index5 = 4;
    string str3 = '\nBurn rate: ';
    objArray[index5] = (object)str3;
    int index6 = 5;
    objArray[index6] = (object)(ValueType)this.fuelConsumption;
    int index7 = 6;
    string str4 = '\nThrust Vectoring: ';
    objArray[index7] = (object)str4;
    int index8 = 7;
    string str5 = !this.thrustVectoringCapable ? 'No' : 'Yes\nGimbal Range: ' + this.gimbalRange.ToString('0.0');
    objArray[index8] = (object)str5;
    string text = string.Concat(objArray);
    GUILayoutOption[] guiLayoutOptionArray = new GUILayoutOption[1];
    int index9 = 0;
    GUILayoutOption guiLayoutOption = GUILayout.ExpandHeight(true);
    guiLayoutOptionArray[index9] = guiLayoutOption;
    GUILayout.TextArea(text, guiLayoutOptionArray);
    }
    }



    using UnityEngine;

    KNOWN ISSUES:

    * Does not work with tri-couplers (FIXED) *

    * Can not spawn multiple windows *

    Good Luck Kerbalnauts!!!

    P.s. DO NOT TRY TO OPEN MULTIPLE WINDOWS!!! CLOSE THEM BEFORE YOU OPEN ANOTHER ONE!!!

  2. Now you may be asking, how to create a projectile on the fly eh? Its going to be a little complicated because you need to create everything purely in script. But it can be done. You need to first create a 'GameObject' and attach to it everything that it requires. Such as a visual model, a physics collider and particle effects. Once you have built the game object, you can create clones of it with the 'Instantiate' command of unity.

    Or I can export a prefab out of unity itself?

  3. Nuclear rocket power could still be a good idea. It would overheat lots and you would have to create a power generator key set, but it could be effective (and deadly). *Gets a plugin idea*

  4. Is it ok to revive an old topic? I\'d better.....thread......carefully.

    Sorry.

    I\'m just upset that I wanted to go to Norway but can\'t a-fjord it.....

    HAHAHAHAHAHA!!! Of course you can revive it! I\'d forgotten all about it and I think everyone else did too! There are some crackup jokes in here! Welcome to the second life of the Jokes thread!

×
×
  • Create New...