10 class ImpactEffectsData
31 static int m_LastRegisteredMaterial = 0;
35 static int m_LastRegisteredIgnoredAmmo = 0;
42 static int PLASTIC = RegisterSurface(
"Hit_Plastic");
43 static int SAND = RegisterSurface(
"Hit_Sand");
44 static int TEXTILE = RegisterSurface(
"Hit_Textile");
45 static int CONCRETE = RegisterSurface(
"Hit_Concrete");
46 static int GRAVEL = RegisterSurface(
"Hit_Gravel");
47 static int DIRT = RegisterSurface(
"Hit_Dirt");
48 static int FOLIAGE = RegisterSurface(
"Hit_Foliage");
49 static int GRASS = RegisterSurface(
"Hit_Grass");
50 static int WOOD = RegisterSurface(
"Hit_Wood");
51 static int METAL = RegisterSurface(
"Hit_Metal");
52 static int GLASS = RegisterSurface(
"Hit_Glass");
53 static int GLASS_THIN = RegisterSurface(
"Hit_Glass_Thin");
54 static int WATER = RegisterSurface(
"Hit_Water");
55 static int RUBBER = RegisterSurface(
"Hit_Rubber");
56 static int PLASTER = RegisterSurface(
"Hit_Plaster");
57 static int MEATBONES = RegisterSurface(
"Hit_MeatBones");
58 static int MEATBONES_SHOVEL = RegisterSurface(
"Hit_MeatBones_MeleeShovel");
59 static int MEATBONES_PIPEWRENCH = RegisterSurface(
"Hit_MeatBones_MeleePipeWrench");
60 static int MEATBONES_WRENCH = RegisterSurface(
"Hit_MeatBones_MeleeWrench");
61 static int MEATBONES_FIST = RegisterSurface(
"Hit_MeatBones_MeleeFist");
62 static int UNDEFINED = RegisterSurface(
"Hit_Undefined");
63 static int ERROR_NO_MATERIAL = RegisterSurface(
"Hit_ErrorNoMaterial");
71 static int FIST = RegisterIgnoredAmmo(
"MeleeFist");
72 static int FIST_HEAVY = RegisterIgnoredAmmo(
"MeleeFist_Heavy");
73 static int SOFT = RegisterIgnoredAmmo(
"MeleeSoft");
74 static int SOFT_HEAVY = RegisterIgnoredAmmo(
"MeleeSoft_Heavy");
75 static int DUMMY = RegisterIgnoredAmmo(
"Dummy_Light");
76 static int DUMMY_HEAVY = RegisterIgnoredAmmo(
"Dummy_Heavy");
79 static int RegisterSurface(
string surface)
84 m_ImpactEffect.Insert(surface, surface.ToType());
86 return ++m_LastRegisteredMaterial;
89 static bool UnregisterSurface(
string surface)
93 m_ImpactEffect.Remove(surface);
94 return !m_ImpactEffect.Contains(surface);
100 static int RegisterIgnoredAmmo(
string ammo)
105 ++m_LastRegisteredIgnoredAmmo;
107 m_IgnoredAmmo.Insert(ammo, m_LastRegisteredIgnoredAmmo);
109 return m_LastRegisteredIgnoredAmmo;
112 static bool UnregisterIgnoredAmmo(
string ammo)
116 m_IgnoredAmmo.Remove(ammo);
117 return !m_IgnoredAmmo.Contains(ammo);
123 static typename GetImpactEffect(
string surface,
string ammoType)
125 string key =
string.Format(
"%1_%2", surface, ammoType);
127 typename eff_type = m_ImpactEffect[key];
132 return m_ImpactEffect[surface];
135 static void EvaluateImpactEffectEx(ImpactEffectsData pData)
137 EvaluateImpactEffect(pData.m_DirectHit, pData.m_ComponentIndex, pData.m_Surface, pData.m_Position, pData.m_ImpactType, pData.m_SurfaceNormal, pData.m_ExitPosition, pData.m_InSpeed, pData.m_OutSpeed, pData.m_IsDeflected, pData.m_AmmoType, pData.m_IsWater);
140 static void EvaluateImpactEffect(
Object directHit,
int componentIndex,
string surface,
vector pos,
int impact_type,
vector surfNormal,
vector exitPos,
vector inSpeed,
vector outSpeed,
bool deflected,
string ammoType,
bool isWater)
143 if (m_IgnoredAmmo.Contains(ammoType))
155 surface =
"Hit_Water";
159 if ( !eff && surface ==
"" )
165 RegisterSurface(surface);
166 ErrorEx(
string.Format(
"Unregistered surface for bullet impact effect (%1). Register this surface in ImpactMaterials (Script) for better performance.", surface),
ErrorExSeverity.WARNING);
172 string object_type = directHit.GetType();
174 if ( object_type ==
"" )
175 object_type =
"OBJECT_WITHOUT_CONFIG_CLASS";
177 ErrorEx(
string.Format(
"Object '%1' with model file: %2 has undefined 'Hit_...' material! Cannot play impact effect.", object_type, directHit.GetShapeName()));
183 if ( !eff && surface !=
"" )
185 ErrorEx(
string.Format(
"Unregistered surface impact material <%1>! Register this surface in ImpactMaterials (Script).", surface));
191 eff.EvaluateEffect(directHit, componentIndex, pos, impact_type, surfNormal, exitPos, inSpeed, outSpeed, ammoType);
192 eff.SetAutodestroy(
true);