21 string m_ParamName =
"Default setup";
22 string m_ParamTriggerType =
"ContaminatedTrigger";
23 float m_ParamRadius = 100;
24 float m_ParamPosHeight = 25;
25 float m_ParamNegHeight = 10;
26 int m_ParamInnerRings = 1;
27 int m_ParamInnerSpace = 35;
28 bool m_ParamOuterToggle =
true;
29 int m_ParamOuterSpace = 20;
30 int m_ParamOuterOffset = -5;
31 int m_ParamVertLayers = 0;
32 int m_ParamVerticalOffset = 10;
33 int m_ParamEffectInterval = 0;
34 int m_ParamEffectDuration = 0;
35 int m_ParamEffectModifier = 0;
41 int m_ParamPartId = 0;
42 int m_ParamAroundPartId = 0;
43 int m_ParamTinyPartId = 0;
45 string m_ParamPpeRequesterType =
"PPERequester_ContaminatedAreaTint";
49class EffectArea :
House
52 string m_Name =
"Default setup";
55 vector m_PositionTrigger;
58 bool m_EffectModifier;
62 float m_PositiveHeight = 25;
63 float m_NegativeHeight = 10;
68 int m_InnerSpacing = 35;
70 bool m_OuterRingToggle =
true;
71 int m_OuterRingOffset = -5;
72 int m_OuterSpacing = 20;
74 int m_VerticalLayers = 0;
75 int m_VerticalOffset = 10;
78 int m_ParticleID = ParticleList.CONTAMINATED_AREA_GAS_BIGASS;
79 int m_AroundParticleID = ParticleList.CONTAMINATED_AREA_GAS_AROUND;
80 int m_TinyParticleID = ParticleList.CONTAMINATED_AREA_GAS_TINY;
81 string m_PPERequesterType;
82 int m_PPERequesterIdx = -1;
83 int m_EffectsPriority;
85 const int PARTICLES_MAX = 1000;
88 string m_TriggerType =
"ContaminatedTrigger";
89 EffectTrigger m_Trigger;
91 ref array<Particle> m_ToxicClouds;
99 RegisterNetSyncVariableFloat(
"m_Radius", 0, 0, 2);
100 RegisterNetSyncVariableFloat(
"m_PositiveHeight", 0, 0, 2);
101 RegisterNetSyncVariableFloat(
"m_NegativeHeight", 0, 0, 2);
103 RegisterNetSyncVariableInt(
"m_InnerRings");
104 RegisterNetSyncVariableInt(
"m_InnerSpacing");
105 RegisterNetSyncVariableInt(
"m_OuterRingOffset");
106 RegisterNetSyncVariableInt(
"m_OuterSpacing");
107 RegisterNetSyncVariableInt(
"m_VerticalLayers");
108 RegisterNetSyncVariableInt(
"m_VerticalOffset");
110 RegisterNetSyncVariableInt(
"m_ParticleID");
116 RegisterNetSyncVariableBool(
"m_OuterRingToggle");
127 if ( params.m_ParamName !=
"" )
128 m_Name = params.m_ParamName;
129 if ( params.m_ParamTriggerType !=
"" )
130 m_TriggerType = params.m_ParamTriggerType;
132 if ( params.m_ParamRadius > 0 )
134 if ( params.m_ParamPosHeight > -1 )
135 m_PositiveHeight = params.m_ParamPosHeight;
136 if ( params.m_ParamNegHeight > -1 )
137 m_NegativeHeight = params.m_ParamNegHeight;
139 m_InnerRings = params.m_ParamInnerRings;
140 if ( params.m_ParamInnerSpace > -1 )
141 m_InnerSpacing = params.m_ParamInnerSpace;
143 m_OuterRingToggle = params.m_ParamOuterToggle;
144 if ( params.m_ParamOuterSpace > -1 )
145 m_OuterSpacing = params.m_ParamOuterSpace;
146 m_OuterRingOffset = params.m_ParamOuterOffset;
148 if ( params.m_ParamVertLayers > 0 )
149 m_VerticalLayers = params.m_ParamVertLayers;
150 if ( params.m_ParamVerticalOffset > 0 )
151 m_VerticalOffset = params.m_ParamVerticalOffset;
153 m_EffectInterval = params.m_ParamEffectInterval;
154 m_EffectDuration = params.m_ParamEffectDuration;
155 m_EffectModifier = params.m_ParamEffectModifier;
157 m_ParticleID = params.m_ParamPartId;
158 m_AroundParticleID = params.m_ParamAroundPartId;
159 m_TinyParticleID = params.m_ParamTinyPartId;
161 if ( params.m_ParamPpeRequesterType !=
"" )
163 m_PPERequesterType = params.m_ParamPpeRequesterType;
164 m_PPERequesterIdx = GetRequesterIndex(m_PPERequesterType);
172 #ifdef ENABLE_LOGGING
173 Debug.Log(
">>>> SetupZoneData: Finished: " +
m_Name);
182 #ifdef DIAG_DEVELOPER
183 #ifdef EFFECT_AREA_VISUAL_DEBUG
191 override void OnCEIterate(
float currentTime,
float elapsedTime)
193 super.OnCEIterate(currentTime, elapsedTime);
204 m_PositionTrigger[1] =
m_Position[1] + ((m_PositiveHeight - m_NegativeHeight) * 0.5);
206 if (!
g_Game.IsDedicatedServer())
238 override bool CanBeTargetedByAI(
EntityAI ai )
247 void PlaceParticles( vector pos,
float radius,
int nbRings,
int innerSpacing,
bool outerToggle,
int outerSpacing,
int outerOffset,
int partId )
256 Error(
"[WARNING] :: [EffectArea PlaceParticles] :: no particle defined, skipping area particle generation" );
261 Error(
"[WARNING] :: [EffectArea PlaceParticles] :: Radius of contaminated zone is set to 0, this should not happen");
264 if ( outerToggle && radius == outerOffset )
266 Error(
"[WARNING] :: [EffectArea PlaceParticles] :: Your outerOffset is EQUAL to your Radius, this will result in division by 0");
272 ParticlePropertiesArray props =
new ParticlePropertiesArray();
275 if (innerSpacing == 0)
279 for (
int i = 0; i <= nbRings + outerToggle; ++i )
283 SpawnParticles(props, pos, pos, partCount);
288 float angleIncrement;
290 vector temp = vector.Zero;
296 ab = radius - outerOffset;
299 angleIncrement = Math.Acos( 1 - ( ( outerSpacing * outerSpacing ) / ( 2 * Math.SqrInt(ab) ) ) );
300 temp[2] = temp[2] + ab;
306 ab = ( radius / ( nbRings + 1 ) ) * i;
309 angleIncrement = Math.Acos( 1 - ( ( innerSpacing * innerSpacing ) / ( 2 * Math.SqrInt(ab) ) ) );
310 temp[2] = temp[2] + ab;
315 for (
int j = 0; j <= ( Math.PI2 / angleIncrement ); j++ )
320 float sinAngle = Math.Sin(angleIncrement * j);
321 float cosAngle = Math.Cos(angleIncrement * j);
323 vector partPos = vector.RotateAroundZero( temp, vector.Up, cosAngle, sinAngle );
326 SpawnParticles(props, pos, partPos, partCount);
331 InsertParticles(props, partCount, partId);
335 void FillWithParticles(vector pos,
float areaRadius,
float outwardsBleed,
float partSize,
int partId)
352 float radiusMax = areaRadius + outwardsBleed;
353 float radiusPart = partSize / 2;
355 bool centerPart =
true;
357 ParticlePropertiesArray props =
new ParticlePropertiesArray();
361 if (radiusMax > radiusPart * 1.5)
363 if (radiusMax < radiusPart * 2.5)
365 ringDist = radiusMax - radiusPart;
371 radiusMax -= radiusPart;
372 ringCount = Math.Ceil(radiusMax / partSize);
373 ringDist = radiusMax / ringCount;
381 for (
int ring = 0; ring <= ringCount; ++ring)
383 if (ring == 0 && centerPart)
385 SpawnParticles(props, pos, pos, partCount);
389 float ringRadius = ringDist * ring;
390 float circumference = 2 * Math.PI2 * ringRadius;
392 int count = Math.Floor(circumference / partSize);
393 float angleInc = Math.PI2 / count;
395 for (
int i = 0; i < count; ++i)
397 vector partPos = pos;
398 float x = ringRadius * Math.Sin(angleInc * i);
399 float z = ringRadius * Math.Cos(angleInc * i);
401 partPos[0] = partPos[0] +
x;
402 partPos[2] = partPos[2] + z;
404 SpawnParticles(props, pos, partPos, partCount);
409 InsertParticles(props, partCount, partId);
412 protected void SpawnParticles(ParticlePropertiesArray props, vector centerPos, vector partPos, inout
int count)
414 float roadY =
g_Game.SurfaceRoadY(partPos[0], partPos[2]);
416 if (partPos[1] > roadY)
420 for (
int layer = 0; layer <= m_VerticalLayers; ++layer)
422 partPos[1] = partPos[1] + (m_VerticalOffset * layer);
425 if (count < PARTICLES_MAX && Math.IsInRange(partPos[1], centerPos[1] - m_NegativeHeight, centerPos[1] + m_PositiveHeight))
427 props.Insert(ParticleProperties(partPos, ParticlePropertiesFlags.PLAY_ON_CREATION, null,
g_Game.GetSurfaceOrientation( partPos[0], partPos[2] ),
this));
433 private void InsertParticles(ParticlePropertiesArray props,
int count,
int partId)
435 m_ToxicClouds.Reserve(count);
439 array<ParticleSource> createdParticles = gPM.CreateParticlesByIdArr(partId, props, count);
440 if (createdParticles.Count() != count)
442 if (gPM.IsFinishedAllocating())
444 ErrorEx(
string.Format(
"Not enough particles in pool for EffectArea: %1",
m_Name));
462 foreach (ParticleSource p : particles)
464 if (p.GetOwner() ==
this)
466 m_ToxicClouds.Insert(p);
471 int GetRequesterIndex(
string type)
473 typename t = type.
ToType();
488 #ifdef DIAG_DEVELOPER
489 #ifdef EFFECT_AREA_VISUAL_DEBUG
496 if (Class.CastTo(m_Trigger,
g_Game.CreateObjectEx(m_TriggerType, pos,
ECE_NONE)))
499 float centerHeightCorrection = (m_PositiveHeight - m_NegativeHeight) * 0.5;
501 m_Trigger.
SetCollisionCylinderTwoWay(radius, -(m_NegativeHeight + centerHeightCorrection), (m_PositiveHeight - centerHeightCorrection));
502 m_Trigger.SetPosition(pos);
505 #ifdef DIAG_DEVELOPER
506 #ifdef EFFECT_AREA_VISUAL_DEBUG
515 vector colliderPosDebug = pos;
517 colliderPosDebug[1] = pos[1] + (m_PositiveHeight - centerHeightCorrection);
518 m_DebugTargets.Insert(
Debug.DrawSphere(colliderPosDebug, 0.15, 0x1f0000ff,
ShapeFlags.NOZWRITE));
521 m_DebugTargets.Insert(
Debug.DrawSphere(pos, 0.15, 0x1fff0000,
ShapeFlags.NOZWRITE));
525 colliderPosDebug[1] = pos[1] - (m_NegativeHeight + centerHeightCorrection);
526 m_DebugTargets.Insert(
Debug.DrawSphere(colliderPosDebug, 0.15, 0x1f00ff00,
ShapeFlags.NOZWRITE));
529 float triggerHeight = (m_PositiveHeight + m_NegativeHeight);
530 m_DebugTargets.Insert(
Debug.DrawCylinder(pos, radius, triggerHeight, 0x1f0000ff,
ShapeFlags.TRANSP|
ShapeFlags.NOZWRITE));
535 if ( m_Trigger.IsInherited(EffectTrigger))
538 EffectTrigger.Cast(m_Trigger).SetLocalEffects(m_AroundParticleID, m_TinyParticleID, m_PPERequesterIdx);
540 m_Trigger.
Init(
this, m_EffectsPriority);
553 g_Game.ObjectDelete( m_Trigger );
557 if ( (
g_Game.IsClient() || !
g_Game.IsMultiplayer()) && m_ToxicClouds )
559 foreach ( Particle p : m_ToxicClouds )
565 super.EEDelete( parent );
570 player.IncreaseEffectAreaCount();
574 player.DecreaseEffectAreaCount();
577 #ifdef DIAG_DEVELOPER
578 #ifdef EFFECT_AREA_VISUAL_DEBUG
579 protected ref array<Shape> m_DebugTargets =
new array<Shape>();
583 foreach (
Shape shape : shapes)
584 Debug.RemoveShape(shape);
eBleedingSourceType m_Type
override void OnPlayerExitServer(PlayerBase player, EffectTrigger trigger)
override void OnPlayerEnterServer(PlayerBase player, EffectTrigger trigger)
override void InitZoneServer()
override void InitZoneClient()
override void EEDelete(EntityAI parent)
override void SetupZoneData(EffectAreaParams params)
override void OnParticleAllocation(ParticleManager pm, array< ParticleSource > particles)
override bool DisableVicinityIcon()
class DayZProfilesOptions UNDEFINED
void CleanupDebugShapes(array< Shape > shapesArr)
DEPRECATED.
vector m_Position
Cached world position.
enum eZoneType HOT_SPRING
override void OnCEIterate(float currentTime, float elapsedTime)
override bool CanPutInCargo(EntityAI parent)
override bool CanPutIntoHands(EntityAI parent)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
void Init(EffectArea area, int priority)
int GetRequesterIDX()
Returns requester index.
void SetCollisionCylinderTwoWay(float radius, float negativeHeight, float positiveHeight)
Input value validated version of SetCollisionCylinderTwoWay.
void Error(string err)
Messagebox with error message.
@ STATIC
Static objects are included in the query.
@ DYNAMIC
Dynamic objects are included in the query.
vector GetPosition()
Get the world position of the Effect.
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...