Skip to content

Commit

Permalink
Renamed the files too.
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Mar 15, 2014
1 parent 8b53dce commit 60962d0
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 119 deletions.
160 changes: 80 additions & 80 deletions PersistantEmitterManager.cs → PersistentEmitterManager.cs
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
/*
* Author: Sébastien GAGGINI AKA Sarbian, France
* License: Attribution 4.0 International (CC BY 4.0): http://creativecommons.org/licenses/by/4.0/
*
* Thanks to Nothke for all the feature ideas, testing and feedback
*
*/

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


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

public static PersistentEmitterManager Instance { get; private set; }

private static List<PersistentKSPParticleEmitter> persistentEmitters;


private void Awake()
{
PersistentEmitterManager.Instance = this;

persistentEmitters = new List<PersistentKSPParticleEmitter>();

GameEvents.onGameSceneLoadRequested.Add(new EventData<GameScenes>.OnEvent(this.OnSceneChange));
}

private void OnDestroy()
{
GameEvents.onGameSceneLoadRequested.Remove(new EventData<GameScenes>.OnEvent(this.OnSceneChange));
}

static public void Add(PersistentKSPParticleEmitter pkpe)
{
persistentEmitters.Add(pkpe);
EffectBehaviour.AddParticleEmitter(pkpe.pe);
}

private void OnSceneChange(GameScenes scene)
{
for (int i = 0; i < persistentEmitters.Count; i++)
{
EffectBehaviour.RemoveParticleEmitter(persistentEmitters[i].pe);
if (persistentEmitters[i].go.transform.parent == null)
Destroy(persistentEmitters[i].go);
}
persistentEmitters = new List<PersistentKSPParticleEmitter>();
}


void FixedUpdate()
{
List<PersistentKSPParticleEmitter> persistentEmittersCopy = new List<PersistentKSPParticleEmitter>(persistentEmitters);
for (int i = 0; i < persistentEmittersCopy.Count; i++)
{
if (persistentEmittersCopy[i].go.transform.parent == null && persistentEmittersCopy[i].pe.pe.particles.Count() == 0)
{
EffectBehaviour.RemoveParticleEmitter(persistentEmittersCopy[i].pe);
persistentEmitters.Remove(persistentEmittersCopy[i]);
Destroy(persistentEmittersCopy[i].go);
}
}

}

private void print(String s)
{
MonoBehaviour.print(this.GetType().Name + " : " + s);
}


}

/*
* Author: Sébastien GAGGINI AKA Sarbian, France
* License: Attribution 4.0 International (CC BY 4.0): http://creativecommons.org/licenses/by/4.0/
*
* Thanks to Nothke for all the feature ideas, testing and feedback
*
*/

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


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

public static PersistentEmitterManager Instance { get; private set; }

private static List<PersistentKSPParticleEmitter> persistentEmitters;


private void Awake()
{
PersistentEmitterManager.Instance = this;

persistentEmitters = new List<PersistentKSPParticleEmitter>();

GameEvents.onGameSceneLoadRequested.Add(new EventData<GameScenes>.OnEvent(this.OnSceneChange));
}

private void OnDestroy()
{
GameEvents.onGameSceneLoadRequested.Remove(new EventData<GameScenes>.OnEvent(this.OnSceneChange));
}

static public void Add(PersistentKSPParticleEmitter pkpe)
{
persistentEmitters.Add(pkpe);
EffectBehaviour.AddParticleEmitter(pkpe.pe);
}

private void OnSceneChange(GameScenes scene)
{
for (int i = 0; i < persistentEmitters.Count; i++)
{
EffectBehaviour.RemoveParticleEmitter(persistentEmitters[i].pe);
if (persistentEmitters[i].go.transform.parent == null)
Destroy(persistentEmitters[i].go);
}
persistentEmitters = new List<PersistentKSPParticleEmitter>();
}


void FixedUpdate()
{
List<PersistentKSPParticleEmitter> persistentEmittersCopy = new List<PersistentKSPParticleEmitter>(persistentEmitters);
for (int i = 0; i < persistentEmittersCopy.Count; i++)
{
if (persistentEmittersCopy[i].go.transform.parent == null && persistentEmittersCopy[i].pe.pe.particles.Count() == 0)
{
EffectBehaviour.RemoveParticleEmitter(persistentEmittersCopy[i].pe);
persistentEmitters.Remove(persistentEmittersCopy[i]);
Destroy(persistentEmittersCopy[i].go);
}
}

}

private void print(String s)
{
MonoBehaviour.print(this.GetType().Name + " : " + s);
}


}


78 changes: 39 additions & 39 deletions PersistantKSPParticleEmitter.cs → PersistentKSPParticleEmitter.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
/*
* Author: Sébastien GAGGINI AKA Sarbian, France
* License: Attribution 4.0 International (CC BY 4.0): http://creativecommons.org/licenses/by/4.0/
*
* Thanks to Nothke for all the feature ideas, testing and feedback
*
*/


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


// TODO : handle the relation with PersistentEmitterManager inside the class
public class PersistentKSPParticleEmitter
{
public GameObject go;
public KSPParticleEmitter pe;
public bool fixedEmit = false;
public float baseMaxSize;

public PersistentKSPParticleEmitter(GameObject go, KSPParticleEmitter pe, float ms)
{
this.go = go;
this.pe = pe;
baseMaxSize = ms;
}

public PersistentKSPParticleEmitter(GameObject go, KSPParticleEmitter pe)
{
this.go = go;
this.pe = pe;
this.baseMaxSize = 1;
}

}
/*
* Author: Sébastien GAGGINI AKA Sarbian, France
* License: Attribution 4.0 International (CC BY 4.0): http://creativecommons.org/licenses/by/4.0/
*
* Thanks to Nothke for all the feature ideas, testing and feedback
*
*/


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


// TODO : handle the relation with PersistentEmitterManager inside the class
public class PersistentKSPParticleEmitter
{
public GameObject go;
public KSPParticleEmitter pe;
public bool fixedEmit = false;
public float baseMaxSize;

public PersistentKSPParticleEmitter(GameObject go, KSPParticleEmitter pe, float ms)
{
this.go = go;
this.pe = pe;
baseMaxSize = ms;
}

public PersistentKSPParticleEmitter(GameObject go, KSPParticleEmitter pe)
{
this.go = go;
this.pe = pe;
this.baseMaxSize = 1;
}

}

0 comments on commit 60962d0

Please sign in to comment.