Esempio n. 1
0
 public HighlightStructure(UpdateHandler updateHandler, object toHighlight, RgbaColor color)
 {
     this.updateHandler = updateHandler;
     this.toHighlight   = toHighlight;
     this.color         = color;
     DetermineType();
     InitializeSuffixes();
     stale   = true;
     enabled = true;
     updateHandler.AddObserver(this);
 }
Esempio n. 2
0
 public HighlightStructure(UpdateHandler updateHandler, object toHighlight, RgbaColor color)
 {
     this.updateHandler = updateHandler;
     this.toHighlight   = toHighlight;
     this.color         = color;
     DetermineType();
     InitializeSuffixes();
     stale   = true;
     enabled = true;
     updateHandler.AddObserver(this);
     GameEvents.onStageSeparation.Add(OnHighlightStaleEvent);
     GameEvents.onVesselPartCountChanged.Add(OnHighlightStaleEvent);
 }
Esempio n. 3
0
        public void SetShow(BooleanValue newShowVal)
        {
            if (newShowVal)
            {
                if (line == null || hat == null)
                {
                    lineObj  = new GameObject("vecdrawLine");
                    hatObj   = new GameObject("vecdrawHat");
                    labelObj = new GameObject("vecdrawLabel", typeof(GUIText));

                    line = lineObj.AddComponent <LineRenderer>();
                    hat  = hatObj.AddComponent <LineRenderer>();
                    //TODO: 1.1 TODO
                    label = labelObj.GetComponent <GUIText>();

                    line.useWorldSpace = false;
                    hat.useWorldSpace  = false;

                    GetShipCenterCoords();

                    line.material = new Material(Shader.Find("Particles/Additive"));
                    hat.material  = new Material(Shader.Find("Particles/Additive"));

                    // This is how font loading would work if other fonts were available in KSP:
                    // Font lblFont = (Font)Resources.Load( "Arial", typeof(Font) );
                    // SafeHouse.Logger.Log( "lblFont is " + (lblFont == null ? "null" : "not null") );
                    // _label.font = lblFont;

                    label.text   = labelStr;
                    label.anchor = TextAnchor.MiddleCenter;

                    PutAtShipRelativeCoords();
                    RenderValues();
                }
                updateHandler.AddObserver(this);
                line.enabled  = true;
                hat.enabled   = true;
                label.enabled = true;
            }
            else
            {
                updateHandler.RemoveObserver(this);
                if (label != null)
                {
                    label.enabled = false;
                    label         = null;
                }
                if (hat != null)
                {
                    hat.enabled = false;
                    hat         = null;
                }
                if (line != null)
                {
                    line.enabled = false;
                    line         = null;
                }
                labelObj = null;
                hatObj   = null;
                lineObj  = null;
            }

            enable = newShowVal;
        }
Esempio n. 4
0
        public void SetShow(BooleanValue newShowVal)
        {
            if (newShowVal)
            {
                if (line == null || hat == null || labelCanvasObj == null)
                {
                    lineObj = new GameObject("vecdrawLine");
                    hatObj  = new GameObject("vecdrawHat");

                    line = lineObj.AddComponent <LineRenderer>();
                    hat  = hatObj.AddComponent <LineRenderer>();

                    line.useWorldSpace = false;
                    hat.useWorldSpace  = false;

                    GetShipCenterCoords();

                    // Note the Shader name string below comes from Kerbal's packaged shaders the
                    // game ships with - there's many to choose from but they're not documented what
                    // they are.  This was settled upon via trial and error:
                    // Additionally, Note that in KSP 1.8 because of the Unity update, some of these
                    // shaders Unity previously supplied were removed from Unity's DLLs.  SQUAD packaged them
                    // inside its own DLLs in 1.8 for modders who had been using them.  But because of that,
                    // mods have to use this different path to get to them:
                    Shader vecShader = Shader.Find("Particles/Alpha Blended"); // for when KSP version is < 1.8
                    if (vecShader == null)
                    {
                        vecShader = Shader.Find("Legacy Shaders/Particles/Alpha Blended"); // for when KSP version is >= 1.8
                    }
                    line.material = new Material(vecShader);
                    hat.material  = new Material(vecShader);

                    // This is how font loading would work if other fonts were available in KSP:
                    // Font lblFont = (Font)Resources.Load( "Arial", typeof(Font) );
                    // SafeHouse.Logger.Log( "lblFont is " + (lblFont == null ? "null" : "not null") );
                    // _label.font = lblFont;
                    CreateLabelHolder();

                    label.text      = labelStr;
                    label.alignment = TextAnchor.MiddleCenter;

                    PutAtShipRelativeCoords();
                    RenderValues();
                }
                updateHandler.AddObserver(this);
                line.enabled  = true;
                hat.enabled   = Pointy;
                label.enabled = true;
            }
            else
            {
                updateHandler.RemoveObserver(this);
                if (label != null)
                {
                    label.enabled = false;
                    label         = null;
                }
                if (hat != null)
                {
                    hat.enabled = false;
                    hat         = null;
                }
                if (line != null)
                {
                    line.enabled = false;
                    line         = null;
                }
                labelCanvasObj = null;
                hatObj         = null;
                lineObj        = null;
            }

            enable = newShowVal;
        }
Esempio n. 5
0
        public void SetShow(BooleanValue newShowVal)
        {
            if (newShowVal)
            {
                if (line == null || hat == null)
                {
                    lineObj  = new GameObject("vecdrawLine");
                    hatObj   = new GameObject("vecdrawHat");
                    labelObj = new GameObject("vecdrawLabel", typeof(GUIText));

                    line  = lineObj.AddComponent <LineRenderer>();
                    hat   = hatObj.AddComponent <LineRenderer>();
                    label = labelObj.GetComponent <GUIText>();

                    line.useWorldSpace = false;
                    hat.useWorldSpace  = false;

                    GetShipCenterCoords();

                    // Note the Shader name string below comes from Kerbal's packaged shaders the
                    // game ships with - there's many to choose from but they're not documented what
                    // they are.  This was settled upon via trial and error:
                    line.material = new Material(Shader.Find("Particles/Alpha Blended"));
                    hat.material  = new Material(Shader.Find("Particles/Alpha Blended"));

                    // This is how font loading would work if other fonts were available in KSP:
                    // Font lblFont = (Font)Resources.Load( "Arial", typeof(Font) );
                    // SafeHouse.Logger.Log( "lblFont is " + (lblFont == null ? "null" : "not null") );
                    // _label.font = lblFont;

                    label.text   = labelStr;
                    label.anchor = TextAnchor.MiddleCenter;

                    PutAtShipRelativeCoords();
                    RenderValues();
                }
                updateHandler.AddObserver(this);
                line.enabled  = true;
                hat.enabled   = Pointy;
                label.enabled = true;
            }
            else
            {
                updateHandler.RemoveObserver(this);
                if (label != null)
                {
                    label.enabled = false;
                    label         = null;
                }
                if (hat != null)
                {
                    hat.enabled = false;
                    hat         = null;
                }
                if (line != null)
                {
                    line.enabled = false;
                    line         = null;
                }
                labelObj = null;
                hatObj   = null;
                lineObj  = null;
            }

            enable = newShowVal;
        }
Esempio n. 6
0
        public void SetShow(BooleanValue newShowVal)
        {
            if (newShowVal)
            {
                if (line == null || hat == null)
                {
                    lineObj  = new GameObject("vecdrawLine");
                    hatObj   = new GameObject("vecdrawHat");
                    labelObj = new GameObject("vecdrawLabel", typeof(GUIText));

                    line = lineObj.AddComponent <LineRenderer>();
                    hat  = hatObj.AddComponent <LineRenderer>();
                    // Deliberately not fixing the following deprecation warning for using GUIText, because I want this
                    // codebase to be back-portable to older KSP versions for RO/RP-1 without too much hassle.  Eventually
                    // it might not work and we may be forced to change this, but the KSP1 lifecycle may be done
                    // by then, so I don't want to make the effort prematurely.
#pragma warning disable CS0618 // ^^^ see above comment about why this is disabled.
                    label = labelObj.GetComponent <GUIText>();
#pragma warning restore CS0618

                    line.useWorldSpace = false;
                    hat.useWorldSpace  = false;

                    GetShipCenterCoords();

                    // Note the Shader name string below comes from Kerbal's packaged shaders the
                    // game ships with - there's many to choose from but they're not documented what
                    // they are.  This was settled upon via trial and error:
                    // Additionally, Note that in KSP 1.8 because of the Unity update, some of these
                    // shaders Unity previously supplied were removed from Unity's DLLs.  SQUAD packaged them
                    // inside its own DLLs in 1.8 for modders who had been using them.  But because of that,
                    // mods have to use this different path to get to them:
                    Shader vecShader = Shader.Find("Particles/Alpha Blended"); // for when KSP version is < 1.8
                    if (vecShader == null)
                    {
                        vecShader = Shader.Find("Legacy Shaders/Particles/Alpha Blended"); // for when KSP version is >= 1.8
                    }
                    line.material = new Material(vecShader);
                    hat.material  = new Material(vecShader);

                    // This is how font loading would work if other fonts were available in KSP:
                    // Font lblFont = (Font)Resources.Load( "Arial", typeof(Font) );
                    // SafeHouse.Logger.Log( "lblFont is " + (lblFont == null ? "null" : "not null") );
                    // _label.font = lblFont;

                    label.text   = labelStr;
                    label.anchor = TextAnchor.MiddleCenter;

                    PutAtShipRelativeCoords();
                    RenderValues();
                }
                updateHandler.AddObserver(this);
                line.enabled  = true;
                hat.enabled   = Pointy;
                label.enabled = true;
            }
            else
            {
                updateHandler.RemoveObserver(this);
                if (label != null)
                {
                    label.enabled = false;
                    label         = null;
                }
                if (hat != null)
                {
                    hat.enabled = false;
                    hat         = null;
                }
                if (line != null)
                {
                    line.enabled = false;
                    line         = null;
                }
                labelObj = null;
                hatObj   = null;
                lineObj  = null;
            }

            enable = newShowVal;
        }