| |
| |
| |
| |
| class AmmoEffects |
| { |
| |
| static ref map<string, int> m_AmmoParticles; |
| |
| |
| static ref map<string, typename> m_AmmoEffects; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static int GetAmmoParticleID(string ammoType) |
| { |
| int particleID; |
| |
| |
| if ( !m_AmmoParticles.Find(ammoType, particleID) ) |
| { |
| |
| string particleFileName; |
| GetGame().ConfigGetText(string.Format("cfgAmmo %1 particle", ammoType), particleFileName); |
| |
| |
| if ( particleFileName != "" ) |
| { |
| particleID = ParticleList.GetParticleIDByName(particleFileName); |
| } |
| |
| |
| m_AmmoParticles.Insert(ammoType, particleID); |
| } |
| |
| return particleID; |
| } |
| |
| |
| static bool PlayAmmoParticle(string ammoType, vector pos) |
| { |
| int particleID = GetAmmoParticleID(ammoType); |
| |
| if (ParticleList.IsValidId(particleID)) |
| { |
| return ParticleManager.GetInstance().PlayInWorld(particleID, pos) != null; |
| } |
| |
| return false; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static typename GetAmmoEffectTypename(string ammoType) |
| { |
| typename typeName; |
| |
| |
| if ( !m_AmmoEffects.Find(ammoType, typeName) ) |
| { |
| |
| string effectName; |
| GetGame().ConfigGetText(string.Format("cfgAmmo %1 effect", ammoType), effectName); |
| |
| |
| if ( effectName != "" ) |
| { |
| typeName = effectName.ToType(); |
| } |
| |
| |
| m_AmmoEffects.Insert(ammoType, typeName); |
| } |
| |
| return typeName; |
| } |
| |
| |
| static bool PlayAmmoEffect(string ammoType, vector pos) |
| { |
| typename typeName = GetAmmoEffectTypename(ammoType); |
| |
| if ( typeName ) |
| { |
| Effect eff = Effect.Cast(typeName.Spawn()); |
| |
| if ( eff ) |
| { |
| eff.SetAutodestroy(true); |
| return SEffectManager.PlayInWorld( eff, pos ); |
| } |
| } |
| |
| return false; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static void Init() |
| { |
| m_AmmoParticles = new map<string, int>(); |
| m_AmmoEffects = new map<string, typename>(); |
| } |
| |
| |
| static void Cleanup() |
| { |
| |
| |
| |
| |
| } |
| |
| |
| } |