|
|
|
class EffectAreaLoader |
|
{ |
|
private static string m_Path = "$mission:cfgeffectarea.json"; |
|
|
|
static void CreateZones() |
|
{ |
|
JsonDataContaminatedAreas effectAreaData; |
|
|
|
|
|
if ( !FileExist( m_Path ) ) |
|
{ |
|
|
|
PrintToRPT("[WARNING] :: [EffectAreaLoader CreateZones] :: No contaminated area file found in MISSION folder, your path is " + m_Path + " Attempting DATA folder"); |
|
|
|
m_Path = ""; |
|
GetGame().GetWorldName( m_Path ); |
|
m_Path = string.Format("dz/worlds/%1/ce/cfgeffectarea.json", m_Path ); |
|
|
|
if ( !FileExist( m_Path ) ) |
|
{ |
|
PrintToRPT("[WARNING] :: [EffectAreaLoader CreateZones] :: No contaminated area file found in DATA folder, your path is " + m_Path); |
|
return; |
|
} |
|
} |
|
|
|
|
|
effectAreaData = EffectAreaLoader.GetData(); |
|
if ( effectAreaData ) |
|
{ |
|
|
|
|
|
|
|
for ( int i = 0; i < effectAreaData.Areas.Count(); i++ ) |
|
{ |
|
EffectAreaParams params = new EffectAreaParams(); |
|
|
|
|
|
params.m_ParamName = effectAreaData.Areas.Get( i ).AreaName; |
|
string areaType = effectAreaData.Areas.Get( i ).Type; |
|
params.m_ParamTriggerType = effectAreaData.Areas.Get( i ).TriggerType; |
|
JsonDataAreaData data = effectAreaData.Areas.Get( i ).Data; |
|
|
|
|
|
vector pos = Vector( data.Pos[0], data.Pos[1], data.Pos[2] ); |
|
params.m_ParamRadius = data.Radius; |
|
params.m_ParamPosHeight = data.PosHeight; |
|
params.m_ParamNegHeight = data.NegHeight; |
|
params.m_ParamInnerRings = data.InnerRingCount; |
|
params.m_ParamInnerSpace = data.InnerPartDist; |
|
params.m_ParamOuterToggle = data.OuterRingToggle; |
|
params.m_ParamOuterSpace = data.OuterPartDist; |
|
params.m_ParamOuterOffset = data.OuterOffset; |
|
params.m_ParamVertLayers = data.VerticalLayers; |
|
params.m_ParamVerticalOffset = data.VerticalOffset; |
|
string particleName = data.ParticleName; |
|
|
|
|
|
JsonDataPlayerData playerData = effectAreaData.Areas.Get( i ).PlayerData; |
|
string aroundPartName = playerData.AroundPartName; |
|
string tinyPartName = playerData.TinyPartName; |
|
string ppeRequesterType = playerData.PPERequesterType; |
|
|
|
|
|
if (particleName != "") |
|
params.m_ParamPartId = ParticleList.GetParticleID( particleName ); |
|
|
|
if (aroundPartName != "") |
|
params.m_ParamAroundPartId = ParticleList.GetParticleID( aroundPartName ); |
|
|
|
if (tinyPartName != "") |
|
params.m_ParamTinyPartId = ParticleList.GetParticleID( tinyPartName ); |
|
|
|
params.m_ParamPpeRequesterType = ppeRequesterType; |
|
|
|
EffectArea newZone; |
|
|
|
|
|
if ( pos[1] == 0 ) |
|
{ |
|
pos[1] = GetGame().SurfaceRoadY( pos[0], pos[2] ); |
|
Class.CastTo( newZone, GetGame().CreateObjectEx( areaType, pos, ECE_PLACE_ON_SURFACE ) ); |
|
} |
|
else |
|
Class.CastTo( newZone, GetGame().CreateObjectEx( areaType, pos, ECE_NONE ) ); |
|
|
|
|
|
if ( newZone ) |
|
newZone.SetupZoneData( params ); |
|
else |
|
Error("[WARNING] :: [EffectAreaLoader CreateZones] :: Cast failed, are you sure your class ( 'Type:' ) inherits from EffectArea and that there are no Typos?"); |
|
} |
|
} |
|
else |
|
Error("[WARNING] :: [EffectAreaLoader CreateZones] :: Data could not be read, please check data and syntax"); |
|
} |
|
|
|
static JsonDataContaminatedAreas GetData() |
|
{ |
|
string errorMessage; |
|
JsonDataContaminatedAreas data; |
|
if (!JsonFileLoader<JsonDataContaminatedAreas>.LoadFile(m_Path, data, errorMessage)) |
|
ErrorEx(errorMessage); |
|
|
|
return data; |
|
} |
|
} |