3 protected string FILE_ROOT =
"$saves:";
4 protected const string FILE_ROOT_SCENES =
"scenes";
6 protected const string PARAM_MISSION =
"Mission";
7 protected const string PARAM_TIME =
"InitTime";
8 protected const string PARAM_YEAR =
"InitYear";
9 protected const string PARAM_MONTH =
"InitMonth";
10 protected const string PARAM_DAY =
"InitDay";
11 protected const string PARAM_HOUR =
"InitHour";
12 protected const string PARAM_MINUTE =
"InitMinute";
13 protected const string PARAM_OVERCAST =
"WeatherInitOvercast";
14 protected const string PARAM_RAIN =
"WeatherInitRain";
15 protected const string PARAM_FOG =
"WeatherInitFog";
16 protected const string PARAM_WIND_F =
"WeatherInitWindForce";
17 protected const string PARAM_PLAYER =
"Player";
18 protected const string PARAM_OBJ_COUNT =
"SceneObjectsCount";
19 protected const string PARAM_OBJ_NAME =
"SceneObject";
20 protected const string PARAM_OBJ_ATT =
"Att";
21 protected const string PARAM_OBJ_LNK =
"Lnk";
22 protected const string PARAM_OBJ_TYPE =
"type";
23 protected const string PARAM_OBJ_POS =
"position";
24 protected const string PARAM_OBJ_ROT =
"rotation";
25 protected const string PARAM_OBJ_DMG =
"damage";
26 protected const string PARAM_OBJ_HLT =
"health";
27 protected const string PARAM_OBJ_ISCR =
"init_script";
31 protected string m_FileSceneName;
40 FILE_ROOT =
g_Game.GetMissionFolderPath();
46 string GetPathScenes()
48 return FILE_ROOT+
"\\"+FILE_ROOT_SCENES;
56 return GetPathScenes()+
"\\"+m_FileSceneName;
62 void SceneRename(
string scene_name,
string scene_name_new)
64 string file_path = GetPathScenes()+
"\\"+scene_name+
"."+PluginSceneManager.SCENE_SUFIX;
65 string file_path_new = GetPathScenes()+
"\\"+scene_name_new+
"."+PluginSceneManager.SCENE_SUFIX;
72 void SceneDelete(
string scene_name)
74 string file_path = GetPathScenes()+
"\\"+scene_name+
"."+PluginSceneManager.SCENE_SUFIX;
81 void SceneDuplicate(
string scene_name)
83 string file_path = GetPathScenes()+
"\\"+scene_name+
"."+PluginSceneManager.SCENE_SUFIX;
84 string file_path_new = file_path;
89 file_path_new = GetPathScenes()+
"\\"+scene_name+
"_copy"+i.ToString()+
"."+PluginSceneManager.SCENE_SUFIX;
111 string path_find_pattern = GetPathScenes()+
"/*."+PluginSceneManager.SCENE_SUFIX;
117 int pos = file_name.IndexOf(
".");
121 list.Insert( file_name.Substring(0, pos) );
124 found =
FindNextFile(file_handler, file_name, file_attr);
133 string EncodeInitScript(
string script )
135 script.Replace(
"\"",
"^" );
136 script.Replace(
"\n",
"$" );
143 string DecodeInitScript(
string script )
145 script.Replace(
"^",
"\"" );
146 script.Replace(
"$",
"\n" );
161 PluginSceneManager module_scene_editor = PluginSceneManager.Cast(
GetPlugin(PluginSceneManager) );
163 EntityAI player = PluginSceneManager.PLAYER;
166 m_FileSceneName = scene.GetNameScene()+
"."+PluginSceneManager.SCENE_SUFIX;
169 SaveSceneSettings(scene);
172 SaveSceneWeather(scene);
175 SaveScenePlayer(scene);
178 SaveSceneObjects(scene);
191 CfgParamString cfg_mission = CfgParamString.Cast( GetParamByName(PARAM_MISSION,
CFG_TYPE_STRING) );
192 cfg_mission.SetValue(scene.GetNameMission());
195 CfgParamFloat cfg_time = CfgParamFloat.Cast( GetParamByName(PARAM_TIME,
CFG_TYPE_FLOAT) );
196 cfg_time.SetValue(scene.GetInitTime());
199 CfgParamInt cfg_year = CfgParamInt.Cast( GetParamByName(PARAM_YEAR,
CFG_TYPE_INT) );
200 cfg_year.SetValue(scene.GetInitYear());
203 CfgParamInt cfg_month = CfgParamInt.Cast( GetParamByName(PARAM_MONTH,
CFG_TYPE_INT) );
204 cfg_month.SetValue(scene.GetInitMonth());
207 CfgParamInt cfg_day = CfgParamInt.Cast( GetParamByName(PARAM_DAY,
CFG_TYPE_INT) );
208 cfg_day.SetValue(scene.GetInitDay());
211 CfgParamInt cfg_hour = CfgParamInt.Cast( GetParamByName(PARAM_HOUR,
CFG_TYPE_INT) );
212 cfg_hour.SetValue(scene.GetInitHour());
215 CfgParamInt cfg_minute = CfgParamInt.Cast( GetParamByName(PARAM_MINUTE,
CFG_TYPE_INT) );
216 cfg_minute.SetValue(scene.GetInitMinute());
225 CfgParamFloat cfg_overcast = CfgParamFloat.Cast( GetParamByName(PARAM_OVERCAST,
CFG_TYPE_FLOAT) );
226 cfg_overcast.SetValue(scene.GetInitOvercast());
229 CfgParamFloat cfg_rain = CfgParamFloat.Cast( GetParamByName(PARAM_RAIN,
CFG_TYPE_FLOAT) );
230 cfg_rain.SetValue(scene.GetInitRain());
233 CfgParamFloat cfg_fog = CfgParamFloat.Cast( GetParamByName(PARAM_FOG,
CFG_TYPE_FLOAT) );
234 cfg_fog.SetValue(scene.GetInitFog());
237 CfgParamFloat cfg_wind_force = CfgParamFloat.Cast( GetParamByName(PARAM_WIND_F,
CFG_TYPE_FLOAT) );
238 cfg_wind_force.SetValue(scene.GetInitWindForce());
248 if ( players.Count() > 0 )
250 ScenePlayer plyr = players.Get(0);
253 CfgParamArray cfg_param_player = CfgParamArray.Cast( GetParamByName(PARAM_PLAYER,
CFG_TYPE_ARRAY) );
256 CfgParamString cfg_param_player_pos = CfgParamString.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_POS,
CFG_TYPE_STRING) );
257 cfg_param_player_pos.SetValue(plyr.GetPositionAsString());
260 CfgParamFloat cfg_param_player_rot = CfgParamFloat.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_ROT,
CFG_TYPE_FLOAT) );
261 cfg_param_player_rot.SetValue(plyr.GetRotation());
264 CfgParamFloat cfg_param_player_hlt = CfgParamFloat.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_HLT,
CFG_TYPE_FLOAT) );
265 cfg_param_player_hlt.SetValue(plyr.GetHealth());
268 CfgParamString cfg_param_player_iscr = CfgParamString.Cast( cfg_param_player.GetValueByName(PARAM_OBJ_ISCR,
CFG_TYPE_STRING) );
269 cfg_param_player_iscr.SetValue( EncodeInitScript(plyr.GetInitScript()) );
281 for (
int i = 0; i < objects.Count(); ++i )
287 param_name = PARAM_OBJ_NAME+
"_"+i.ToString();
290 CfgParamArray cfg_param_obj = CfgParamArray.Cast( GetParamByName(param_name,
CFG_TYPE_ARRAY) );
293 CfgParamString cfg_param_obj_type = CfgParamString.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_TYPE,
CFG_TYPE_STRING) );
294 cfg_param_obj_type.SetValue(obj.GetTypeName());
297 CfgParamString cfg_param_obj_pos = CfgParamString.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_POS,
CFG_TYPE_STRING) );
298 cfg_param_obj_pos.SetValue(obj.GetPositionAsString());
301 CfgParamFloat cfg_param_obj_rot = CfgParamFloat.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_ROT,
CFG_TYPE_FLOAT) );
302 cfg_param_obj_rot.SetValue(obj.GetRotation());
305 CfgParamFloat cfg_param_obj_hlt = CfgParamFloat.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_HLT,
CFG_TYPE_FLOAT) );
306 cfg_param_obj_hlt.SetValue(obj.GetHealth());
309 CfgParamString cfg_param_obj_iscr = CfgParamString.Cast( cfg_param_obj.GetValueByName(PARAM_OBJ_ISCR,
CFG_TYPE_STRING) );
310 cfg_param_obj_iscr.SetValue( EncodeInitScript(obj.GetInitScript()) );
314 int attcount = e_obj.GetInventory().AttachmentCount();
318 string param_name_att = param_name+
"_"+PARAM_OBJ_ATT;
319 CfgParamArray cfg_param_att = CfgParamArray.Cast( GetParamByName(param_name_att,
CFG_TYPE_ARRAY) );
320 cfg_param_att.Clear();
322 for (
int att = 0; att < attcount; att++)
324 EntityAI attachment = e_obj.GetInventory().GetAttachmentFromIndex(att);
326 CfgParamString cfg_param_att_str =
new CfgParamString(
"");
327 cfg_param_att_str.SetValue( attachment.GetType() );
328 cfg_param_att.InsertValue( cfg_param_att_str );
333 if ( linked_scene_objects.Count() > 0 )
335 string param_name_lnk = param_name +
"_" + PARAM_OBJ_LNK;
336 CfgParamArray cfg_param_lnk = CfgParamArray.Cast( GetParamByName( param_name_lnk,
CFG_TYPE_ARRAY ) );
337 cfg_param_lnk.Clear();
339 for (
int lnk = 0; lnk < linked_scene_objects.Count(); lnk++ )
341 CfgParamInt cfg_param_lnk_int =
new CfgParamInt(
"");
343 int index = objects.Find( linked_scene_objects.Get(lnk) );
347 cfg_param_lnk_int.SetValue( index );
348 cfg_param_lnk.InsertValue( cfg_param_lnk_int );
355 CfgParamInt cfg_obj_count = CfgParamInt.Cast( GetParamByName(PARAM_OBJ_COUNT,
CFG_TYPE_INT) );
356 cfg_obj_count.SetValue(objects.Count());
368 SceneData SceneDataLoad(
string scene_name)
370 m_FileSceneName = scene_name+
"."+PluginSceneManager.SCENE_SUFIX;
378 scene.SetNameScene(scene_name);
381 LoadSceneSettings(scene);
384 LoadSceneWeather(scene);
387 LoadScenePlayer(scene);
390 LoadSceneObjects(scene);
394 SceneDataSave(scene);
406 CfgParamString cfg_mission = CfgParamString.Cast( GetParamByName(PARAM_MISSION,
CFG_TYPE_STRING) );
407 scene.SetNameMission(cfg_mission.GetValue());
410 CfgParamFloat cfg_time = CfgParamFloat.Cast( GetParamByName(PARAM_TIME,
CFG_TYPE_FLOAT) );
411 scene.SetInitTime(cfg_time.GetValue());
413 int year, month, day, hour, minute;
414 GetGame().GetWorld().GetDate( year, month, day, hour, minute );
417 if ( ParamExist(PARAM_YEAR) )
419 CfgParamInt cfg_year = CfgParamInt.Cast( GetParamByName( PARAM_YEAR,
CFG_TYPE_INT ) );
420 scene.SetInitYear( cfg_year.GetValue() );
424 scene.SetInitYear( year );
428 if ( ParamExist(PARAM_MONTH) )
430 CfgParamInt cfg_month = CfgParamInt.Cast( GetParamByName( PARAM_MONTH,
CFG_TYPE_INT ) );
431 scene.SetInitMonth( cfg_month.GetValue() );
435 scene.SetInitMonth( month );
439 if ( ParamExist(PARAM_DAY) )
441 CfgParamInt cfg_day = CfgParamInt.Cast( GetParamByName( PARAM_DAY,
CFG_TYPE_INT ) );
442 scene.SetInitDay( cfg_day.GetValue() );
446 scene.SetInitDay( day );
450 if ( ParamExist(PARAM_HOUR) )
452 CfgParamInt cfg_hour = CfgParamInt.Cast( GetParamByName( PARAM_HOUR,
CFG_TYPE_INT ) );
453 scene.SetInitHour( cfg_hour.GetValue() );
457 scene.SetInitHour( hour );
461 if ( ParamExist(PARAM_MINUTE) )
463 CfgParamInt cfg_minute = CfgParamInt.Cast( GetParamByName( PARAM_MINUTE,
CFG_TYPE_INT ) );
464 scene.SetInitMinute( cfg_minute.GetValue() );
468 scene.SetInitMinute( minute );
478 if ( ParamExist(PARAM_OVERCAST) )
480 CfgParamFloat cfg_overcast = CfgParamFloat.Cast( GetParamByName(PARAM_OVERCAST,
CFG_TYPE_FLOAT) );
481 scene.SetInitOvercast(cfg_overcast.GetValue());
485 if ( ParamExist(PARAM_RAIN) )
487 CfgParamFloat cfg_rain = CfgParamFloat.Cast( GetParamByName(PARAM_RAIN,
CFG_TYPE_FLOAT) );
488 scene.SetInitRain(cfg_rain.GetValue());
492 if ( ParamExist(PARAM_FOG) )
494 CfgParamFloat cfg_fog = CfgParamFloat.Cast( GetParamByName(PARAM_FOG,
CFG_TYPE_FLOAT) );
495 scene.SetInitFog(cfg_fog.GetValue());
499 if ( ParamExist(PARAM_WIND_F) )
501 CfgParamFloat cfg_wind_force = CfgParamFloat.Cast( GetParamByName(PARAM_WIND_F,
CFG_TYPE_FLOAT) );
502 scene.SetInitWindForce(cfg_wind_force.GetValue());
514 CfgParamArray cfg_player = CfgParamArray.Cast( GetParamByName(PARAM_PLAYER,
CFG_TYPE_ARRAY) );
515 CfgParamString cfg_ply_pos = CfgParamString.Cast( cfg_player.GetValueByName(PARAM_OBJ_POS,
CFG_TYPE_STRING) );
516 CfgParamFloat cfg_ply_rot = CfgParamFloat.Cast( cfg_player.GetValueByName(PARAM_OBJ_ROT,
CFG_TYPE_FLOAT) );
517 CfgParamFloat cfg_ply_hlt = CfgParamFloat.Cast( cfg_player.GetValueByName(PARAM_OBJ_HLT,
CFG_TYPE_FLOAT) );
518 CfgParamString cfg_ply_iscr = CfgParamString.Cast( cfg_player.GetValueByName(PARAM_OBJ_ISCR,
CFG_TYPE_STRING) );
520 ScenePlayer scn_player = scene.CreateScenePlayer();
523 if ( PluginSceneManager.GetInstance().GetLoadPlayerPos() )
526 vector start_pos = cfg_ply_pos.GetValue().ToVector();
528 if ( start_pos !=
vector.Zero )
531 scn_player.SetPosition(cfg_ply_pos.GetValue().ToVector());
534 scn_player.SetRotation(cfg_ply_rot.GetValue());
540 float health2 = cfg_ply_hlt.GetValue();
542 health2 = scn_player.GetMaxHealth();
544 scn_player.SetHealth(health2);
547 scn_player.SetInitScript( DecodeInitScript(cfg_ply_iscr.GetValue()) );
557 CfgParamInt cfg_obj_count = CfgParamInt.Cast( GetParamByName(PARAM_OBJ_COUNT,
CFG_TYPE_INT) );
558 int obj_count = cfg_obj_count.GetValue();
560 for (
int i = 0; i < obj_count; ++i )
562 string param_name = PARAM_OBJ_NAME+
"_"+i.ToString();
565 CfgParamArray cfg_obj = CfgParamArray.Cast( GetParamByName(param_name,
CFG_TYPE_ARRAY) );
567 CfgParamString cfg_obj_type = CfgParamString.Cast( cfg_obj.GetValueByName(PARAM_OBJ_TYPE,
CFG_TYPE_STRING) );
568 CfgParamString cfg_obj_pos = CfgParamString.Cast( cfg_obj.GetValueByName(PARAM_OBJ_POS,
CFG_TYPE_STRING) );
569 CfgParamFloat cfg_obj_rot = CfgParamFloat.Cast( cfg_obj.GetValueByName(PARAM_OBJ_ROT,
CFG_TYPE_FLOAT) );
570 CfgParamFloat cfg_obj_hlt = CfgParamFloat.Cast( cfg_obj.GetValueByName(PARAM_OBJ_HLT,
CFG_TYPE_FLOAT) );
571 CfgParamString cfg_obj_iscr = CfgParamString.Cast( cfg_obj.GetValueByName(PARAM_OBJ_ISCR,
CFG_TYPE_STRING) );
576 SceneObject scn_obj = scene.CreateSceneObject(cfg_obj_type.GetValue(), cfg_obj_pos.GetValue().ToVector());
579 scn_obj.SetRotation(cfg_obj_rot.GetValue());
581 scn_obj.SetHealth(cfg_obj_hlt.GetValue());
583 scn_obj.SetInitScript( DecodeInitScript(cfg_obj_iscr.GetValue()) );
586 CfgParamArray cfg_obj_param_links = CfgParamArray.Cast( GetParamByName(param_name +
"_" + PARAM_OBJ_LNK,
CFG_TYPE_ARRAY) );
589 for (
int lnko = 0; lnko < cfg_obj_links.Count(); lnko++ )
591 CfgParamInt cfg_obj_param_lnk_int = CfgParamInt.Cast( cfg_obj_links.Get(lnko) );
592 scn_obj.m_LinkedSceneObjectsIndices.Insert( cfg_obj_param_lnk_int.GetValue() );
595 string param_name_att = param_name +
"_"+ PARAM_OBJ_ATT;
597 if ( ParamExist(param_name_att) )
599 CfgParamArray cfg_param_att = CfgParamArray.Cast( GetParamByName(param_name_att,
CFG_TYPE_ARRAY) );
603 for (
int j = 0; j < cfg_param_attachments.Count(); ++j )
605 CfgParamString cfg_param_att_str = CfgParamString.Cast( cfg_param_attachments.Get(j) );
606 scn_obj.GetObject().GetInventory().CreateAttachment( cfg_param_att_str.GetValue() );