Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed May 29, 2014
1 parent 16961b2 commit 32aa97b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 43 deletions.
18 changes: 7 additions & 11 deletions ModelMultiParticlePersistFX.cs
Expand Up @@ -27,7 +27,9 @@

using System;
using System.Collections.Generic;

using SmokeScreen;

using UnityEngine;

[EffectDefinition("MODEL_MULTI_PARTICLE_PERSIST")]
Expand Down Expand Up @@ -127,7 +129,7 @@ public class ModelMultiParticlePersistFX : EffectBehaviour
// The size at time t after emission will be approximately
// (Log(logarithmicGrowth * t + 1) + 1) * initialSize, assuming grow = 0.
public MultiInputCurve logGrow;

// Those 2 curve are related to the angle and distance to cam
public FXCurve angle = new FXCurve("angle", 1f);

Expand All @@ -146,6 +148,7 @@ public class ModelMultiParticlePersistFX : EffectBehaviour
private static readonly List<ModelMultiParticlePersistFX> list = new List<ModelMultiParticlePersistFX>();

private float singleTimerEnd = 0;

private float timeModuloDelta = 0;

public static List<ModelMultiParticlePersistFX> List
Expand Down Expand Up @@ -241,8 +244,6 @@ public void FixedUpdate()

SmokeScreenConfig.UpdateParticlesCount();



//RaycastHit vHit = new RaycastHit();
//Ray vRay = Camera.main.ScreenPointToRay(Input.mousePosition);
//if(Physics.Raycast(vRay, out vHit))
Expand All @@ -251,7 +252,6 @@ public void FixedUpdate()
// if (Physics.Raycast(vHit.point + vHit.normal * 10, -vHit.normal, out vHit2))
// Debug.Log(vHit2.collider.name);
//}


PersistentKSPParticleEmitter[] persistentKspParticleEmitters = persistentEmitters.ToArray();
for (int i = 0; i < persistentKspParticleEmitters.Length; i++)
Expand All @@ -261,8 +261,7 @@ public void FixedUpdate()
persistentKspParticleEmitter.EmitterOnUpdate(this.hostPart.rb.velocity + Krakensbane.GetFrameVelocity());
}
}



private void UpdateInputs(float power)
{
if (overRideInputs)
Expand Down Expand Up @@ -318,7 +317,6 @@ private void UpdateInputs(float power)
inputs[(int)MultiInputCurve.Inputs.parttemp] = partTemp;
inputs[(int)MultiInputCurve.Inputs.externaltemp] = externalTemp;
inputs[(int)MultiInputCurve.Inputs.time] = time;

}

public void UpdateEmitters(float power)
Expand Down Expand Up @@ -355,7 +353,6 @@ public void UpdateEmitters(float power)
pkpe.pe.shape2D = pkpe.scale2DBase * currentScale;
pkpe.pe.shape3D = pkpe.scale3DBase * currentScale;


pkpe.sizeClamp = sizeClamp;
pkpe.randomInitalVelocityOffsetMaxRadius = randomInitalVelocityOffsetMaxRadius;

Expand All @@ -377,8 +374,7 @@ public void UpdateEmitters(float power)
// Bad code is bad
try
{
pkpe.pe.particleRenderMode =
(ParticleRenderMode)Enum.Parse(typeof(ParticleRenderMode), renderMode);
pkpe.pe.particleRenderMode = (ParticleRenderMode)Enum.Parse(typeof(ParticleRenderMode), renderMode);
}
catch (ArgumentException)
{
Expand Down Expand Up @@ -725,7 +721,7 @@ private float minInput(int id)

return min;
}

private float maxInput(int id)
{
float max = emission.maxInput[id];
Expand Down
3 changes: 2 additions & 1 deletion MultiInputCurve.cs
Expand Up @@ -26,6 +26,7 @@
*/

using System;

using UnityEngine;

// This class Serialization DOES NOT WORK in Unity
Expand Down Expand Up @@ -226,4 +227,4 @@ private static void print(String s)
{
MonoBehaviour.print("[MultiInputCurve] " + s);
}
}
}
24 changes: 11 additions & 13 deletions PersistentEmitterManager.cs
Expand Up @@ -10,18 +10,16 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

using UnityEngine;

[KSPAddon(KSPAddon.Startup.EveryScene, false)]
class PersistentEmitterManager : MonoBehaviour
internal class PersistentEmitterManager : MonoBehaviour
{

public static PersistentEmitterManager Instance { get; private set; }

private static List<PersistentKSPParticleEmitter> persistentEmitters;


private void Awake()
{
PersistentEmitterManager.Instance = this;
Expand All @@ -36,8 +34,8 @@ private void OnDestroy()
GameEvents.onGameSceneLoadRequested.Remove(new EventData<GameScenes>.OnEvent(this.OnSceneChange));
}

static public void Add(PersistentKSPParticleEmitter pkpe)
{
public static void Add(PersistentKSPParticleEmitter pkpe)
{
persistentEmitters.Add(pkpe);
EffectBehaviour.AddParticleEmitter(pkpe.pe);
}
Expand All @@ -48,12 +46,14 @@ private void OnSceneChange(GameScenes scene)
{
EffectBehaviour.RemoveParticleEmitter(persistentEmitters[i].pe);
if (persistentEmitters[i].go.transform.parent == null)
{
Destroy(persistentEmitters[i].go);
}
}
persistentEmitters = new List<PersistentKSPParticleEmitter>();
}

void FixedUpdate()
public void FixedUpdate()
{
var persistentEmittersCopy = persistentEmitters.ToArray();
for (int i = 0; i < persistentEmittersCopy.Length; i++)
Expand All @@ -63,7 +63,7 @@ void FixedUpdate()
persistentEmittersCopy[i].EmissionStop();
}

if (persistentEmittersCopy[i].go == null || persistentEmittersCopy[i].go.transform.parent == null)
if (persistentEmittersCopy[i].go == null || persistentEmittersCopy[i].go.transform.parent == null)
{
persistentEmittersCopy[i].EmitterOnUpdate(Vector3.zero);

Expand All @@ -72,7 +72,9 @@ void FixedUpdate()
EffectBehaviour.RemoveParticleEmitter(persistentEmittersCopy[i].pe);
persistentEmitters.Remove(persistentEmittersCopy[i]);
if (persistentEmittersCopy[i].go != null)
{
Destroy(persistentEmittersCopy[i].go);
}
}
}
}
Expand All @@ -82,8 +84,4 @@ private void Print(string s)
{
MonoBehaviour.print(this.GetType().Name + " : " + s);
}


}


}
6 changes: 5 additions & 1 deletion Properties/AssemblyInfo.cs
Expand Up @@ -5,6 +5,7 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("SmokeScreen")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +18,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("6879e39e-17f5-44d4-9d52-a25bd0851b7f")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +35,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
2 changes: 1 addition & 1 deletion SmokeScreenConfig.cs
Expand Up @@ -137,4 +137,4 @@ private void Save()
topNode.Save(path);
}
}
}
}
2 changes: 1 addition & 1 deletion SmokeScreenUI.cs
Expand Up @@ -110,4 +110,4 @@ private void windowGUI(int ID)
GUI.DragWindow();
}
}
}
}
28 changes: 13 additions & 15 deletions SmokeScreenUtil.cs
Expand Up @@ -24,16 +24,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmokeScreen
{
using System;
using System.Collections.Generic;
using System.Text;

using UnityEngine;

static class SmokeScreenUtil
internal static class SmokeScreenUtil
{
public static string WriteRootNode(ConfigNode node)
{
Expand All @@ -50,6 +50,7 @@ public static string WriteRootNode(ConfigNode node)
}
return builder.ToString();
}

public static void WriteNodeString(ConfigNode node, ref StringBuilder builder, string indent)
{
builder.AppendLine(string.Concat(indent, node.name));
Expand Down Expand Up @@ -79,7 +80,7 @@ public static void RecurseFormat(List<string[]> cfg, ref int index, ConfigNode n
{
while (index < cfg.Count)
{
if ((int)cfg[index].Length == 2)
if (cfg[index].Length == 2)
{
node.values.Add(new ConfigNode.Value(cfg[index][0], cfg[index][1]));
index = index + 1;
Expand Down Expand Up @@ -116,7 +117,7 @@ public static void RecurseFormat(List<string[]> cfg, ref int index, ConfigNode n
public static bool NextLineIsOpenBrace(List<string[]> cfg, int index)
{
int num = index + 1;
if (num < cfg.Count && (int)cfg[num].Length == 1 && cfg[num][0] == "{")
if (num < cfg.Count && cfg[num].Length == 1 && cfg[num][0] == "{")
{
return true;
}
Expand All @@ -125,7 +126,7 @@ public static bool NextLineIsOpenBrace(List<string[]> cfg, int index)

public static List<string[]> PreFormatConfig(string[] cfgData)
{
if (cfgData == null || (int)cfgData.Length < 1)
if (cfgData == null || cfgData.Length < 1)
{
Debug.LogError("Error: Empty part config file");
return null;
Expand Down Expand Up @@ -207,10 +208,10 @@ public static List<string[]> PreFormatConfig(string[] cfgData)
for (int i = 0; i < strs.Count; i++)
{
string item = strs[i];
string[] strArrays1 = item.Split(new char[] { '=' }, 2, StringSplitOptions.None);
if (strArrays1 != null && (int)strArrays1.Length != 0)
string[] strArrays1 = item.Split(new[] { '=' }, 2, StringSplitOptions.None);
if (strArrays1 != null && strArrays1.Length != 0)
{
for (int j = 0; j < (int)strArrays1.Length; j++)
for (int j = 0; j < strArrays1.Length; j++)
{
strArrays1[j] = strArrays1[j].Trim();
}
Expand All @@ -220,7 +221,6 @@ public static List<string[]> PreFormatConfig(string[] cfgData)
return strArrays;
}


// The whole pad object is named "ksp_pad_launchPad"
public const string LaunchPadGrateColliderName = "Launch Pad Grate";

Expand Down Expand Up @@ -294,11 +294,9 @@ public static bool AddLaunchPadColliders(RaycastHit hit)
return true;
}


private static void print(String s)
{
MonoBehaviour.print("[SmokeScreenUtil] " + s);
}

}
}
}

0 comments on commit 32aa97b

Please sign in to comment.