dayzintroscenexbox.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. class DayZIntroSceneXbox: Managed
  2. {
  3. protected bool m_IsCharFemale;
  4. protected int m_LastPlayedCharacterID;
  5. protected ref TStringArray m_genderList;
  6. protected ref TStringArray m_CharPersonalityMaleList;
  7. protected ref TStringArray m_CharPersonalityFemaleList;
  8. protected ref TStringArray m_CharShirtList;
  9. protected ref TStringArray m_CharPantsList;
  10. protected ref TStringArray m_CharShoesList;
  11. protected ref TStringArray m_AllCharacters;
  12. protected ref IntroSceneCharacter m_Character;
  13. protected Camera m_SceneCamera;
  14. protected Weather m_Weather;
  15. protected Object m_Clutter;
  16. protected vector m_CharacterPos;
  17. protected vector m_CharacterDir;
  18. protected ref TIntArray m_Date = new TIntArray;
  19. protected MenuData m_MenuData;
  20. protected ref MenuCarEngineSmoke m_FXParticleCarSmoke;
  21. protected ref MenuEvaporation m_FXParticleStreamLeft;
  22. protected ref MenuEvaporation m_FXParticleStreamRight;
  23. ref Timer m_TimerUpdate = new Timer( CALL_CATEGORY_GAMEPLAY );
  24. ref Timer m_TimerParticle = new Timer( CALL_CATEGORY_GAMEPLAY );
  25. ref Timer m_TimerDate = new Timer( CALL_CATEGORY_GAMEPLAY );
  26. ref Timer m_TimerClientUpdate = new Timer( CALL_CATEGORY_GAMEPLAY );
  27. //==================================
  28. // DayZIntroSceneXbox
  29. //==================================
  30. void DayZIntroSceneXbox()
  31. {
  32. m_MenuData = g_Game.GetMenuData();
  33. m_LastPlayedCharacterID = m_MenuData.GetLastPlayedCharacter();
  34. m_CharacterPos = "0 0 0";
  35. m_CharacterDir = "0 0 0";
  36. //g_Game.m_PlayerName = "Survivor"; //default
  37. if ( m_MenuData.GetCharactersCount() == 0 )
  38. {
  39. m_LastPlayedCharacterID = -1;
  40. }
  41. if ( m_LastPlayedCharacterID > -1 )
  42. {
  43. m_MenuData.GetCharacterName(m_LastPlayedCharacterID, g_Game.GetPlayerGameName());
  44. }
  45. // Camera Setup
  46. vector camera_position;
  47. camera_position[0] = 1323.0; // X
  48. camera_position[1] = 1.0; // Y
  49. camera_position[2] = 1590.37; // Z
  50. float camera_rotation_h = 100;
  51. float camera_rotation_v = -3;
  52. float camera_fov = 0.85;
  53. float camera_focus_distance = 0.0;
  54. float camera_focus_streght = 0.0;
  55. // Character
  56. float character_distance = 2.25;
  57. // Camera Setup
  58. m_SceneCamera = CameraCreate(camera_position, camera_rotation_h, camera_rotation_v, camera_fov, camera_focus_distance, camera_focus_streght);
  59. m_SceneCamera.SetActive(true);
  60. PPEffects.Init(); //Deprecated, left in for legacy purposes only
  61. // Character Setup
  62. vector cam_dir = m_SceneCamera.GetDirection();
  63. m_CharacterPos = camera_position + ( cam_dir * character_distance );
  64. m_CharacterPos[1] = GetGame().SurfaceY(m_CharacterPos[0], m_CharacterPos[2]);
  65. m_CharacterDir = (camera_position - m_CharacterPos);
  66. float overcast = 0.42;
  67. float rain = 0.0;
  68. float snowfall = 0.0;
  69. float fog = 0.0;
  70. m_Weather = g_Game.GetWeather();
  71. m_Weather.GetOvercast().SetLimits(overcast, overcast);
  72. m_Weather.GetRain().SetLimits(rain, rain);
  73. m_Weather.GetSnowfall().SetLimits(snowfall, snowfall);
  74. m_Weather.GetFog().SetLimits(fog, fog);
  75. m_Weather.GetOvercast().Set(overcast, 0, 0);
  76. m_Weather.GetRain().Set(rain, 0, 0);
  77. m_Weather.GetSnowfall().Set(snowfall, 0, 0);
  78. m_Weather.GetFog().Set(fog, 0, 0);
  79. m_Character = new IntroSceneCharacter();
  80. m_Character.LoadCharacterData(m_CharacterPos, m_CharacterDir);
  81. m_TimerParticle.Run(0.1, this, "SetupParticles", null, false);
  82. //m_TimerDate.Run(2.0, this, "SetupDate", null, false);
  83. m_TimerUpdate.Run(0.5, this, "SetupCharacter", null, true);
  84. vector clut_pos = SnapToGround( m_CharacterPos + "-1 0 0" );
  85. m_Clutter = GetGame().CreateObject( "ClutterCutter2x2", clut_pos, true );
  86. // Xbox check update
  87. CheckXboxClientUpdateLoopStart();
  88. g_Game.SetHudBrightness(g_Game.GetHUDBrightnessSetting());
  89. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetInitPostprocesses);
  90. }
  91. void ~DayZIntroSceneXbox()
  92. {
  93. if ( m_TimerUpdate )
  94. {
  95. m_TimerUpdate.Stop();
  96. delete m_TimerUpdate;
  97. m_TimerUpdate = null;
  98. }
  99. if ( m_TimerParticle )
  100. {
  101. m_TimerParticle.Stop();
  102. delete m_TimerParticle;
  103. m_TimerParticle = null;
  104. }
  105. if ( m_TimerDate )
  106. {
  107. m_TimerDate.Stop();
  108. delete m_TimerDate;
  109. m_TimerDate = null;
  110. }
  111. CheckXboxClientUpdateLoopStop();
  112. GetGame().ObjectDelete( m_SceneCamera );
  113. if ( m_MenuData )
  114. {
  115. m_MenuData.ClearCharacters();
  116. }
  117. SEffectManager.DestroyEffect(m_FXParticleCarSmoke);
  118. SEffectManager.DestroyEffect(m_FXParticleStreamLeft);
  119. SEffectManager.DestroyEffect(m_FXParticleStreamRight);
  120. PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
  121. }
  122. protected void SetInitPostprocesses()
  123. {
  124. PPERequester_MenuEffects requester;
  125. Class.CastTo(requester,PPERequesterBank.GetRequester(PPERequester_MenuEffects));
  126. requester.SetVignetteIntensity(0.3);
  127. PPERequesterBank.GetRequester(PPERequester_IntroChromAbb).Start();
  128. }
  129. //==============================================
  130. // GetIntroSceneCharacter
  131. //==============================================
  132. IntroSceneCharacter GetIntroCharacter()
  133. {
  134. return m_Character;
  135. }
  136. //==================================
  137. // SetupCharacter
  138. //==================================
  139. void SetupCharacter()
  140. {
  141. if ( m_Character.GetCharacterObj() )
  142. {
  143. vector v = m_Character.GetCharacterObj().GetOrientation();
  144. v[0] = -75;
  145. m_Character.GetCharacterObj().SetOrientation(v);
  146. }
  147. }
  148. //==================================
  149. // SetupParticles
  150. //==================================
  151. void SetupParticles()
  152. {
  153. m_FXParticleCarSmoke = new MenuCarEngineSmoke();
  154. //SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1330.36 2.11628 1594.31");
  155. //SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1333.88 1.51392 1594.88");
  156. SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1331.52 2.34052 1593.55");
  157. vector pos = m_SceneCamera.GetPosition() + m_SceneCamera.GetDirection() * 1.5;
  158. vector dir = m_SceneCamera.GetDirection();
  159. float temp = dir[0];
  160. dir[0] = dir[2];
  161. dir[2] = -temp;
  162. vector pos_right = pos + (dir * 1.5);
  163. vector pos_left = pos + (-dir * 1.5);
  164. m_FXParticleStreamLeft = new MenuEvaporation();
  165. SEffectManager.PlayInWorld(m_FXParticleStreamLeft, pos_right);
  166. m_FXParticleStreamRight = new MenuEvaporation();
  167. SEffectManager.PlayInWorld(m_FXParticleStreamRight, pos_left);
  168. }
  169. //==================================
  170. // SetupDate
  171. //==================================
  172. void SetupDate()
  173. {
  174. //g_Game.GetWorld().SetDate(m_Date.Get(0), m_Date.Get(1), m_Date.Get(2), m_Date.Get(3), m_Date.Get(4));
  175. //g_Game.GetWorld().SetDate(2020, 10, 15, 18, 20);
  176. }
  177. //==================================
  178. // CheckXboxClientUpdateLoopStart
  179. //==================================
  180. void CheckXboxClientUpdateLoopStart()
  181. {
  182. if ( CheckXboxClientUpdate() )
  183. {
  184. m_TimerClientUpdate.Run(30, this, "CheckXboxClientUpdate", null, true);
  185. }
  186. }
  187. //==================================
  188. // CheckXboxClientUpdateLoopStop
  189. //==================================
  190. void CheckXboxClientUpdateLoopStop()
  191. {
  192. if ( m_TimerClientUpdate )
  193. {
  194. m_TimerClientUpdate.Stop();
  195. delete m_TimerClientUpdate;
  196. m_TimerClientUpdate = null;
  197. }
  198. }
  199. //==================================
  200. // CheckXboxClientUpdate
  201. //==================================
  202. bool CheckXboxClientUpdate()
  203. {
  204. return OnlineServices.CheckUpdate();
  205. }
  206. //==================================
  207. // CameraCreate
  208. //==================================
  209. protected Camera CameraCreate(vector cam_pos, float cam_rot_h, float cam_rot_v, float cam_fov, float cam_focus_dist, float cam_focus_strg)
  210. {
  211. Camera cam = Camera.Cast( g_Game.CreateObject("staticcamera", SnapToGround(cam_pos), true));
  212. cam.SetOrientation( Vector( cam_rot_h, cam_rot_v, 0) );
  213. cam.SetFOV( cam_fov );
  214. cam.SetFocus(cam_focus_dist, cam_focus_strg);
  215. return cam;
  216. }
  217. //==================================
  218. // GetCamera
  219. //==================================
  220. Camera GetCamera()
  221. {
  222. return m_SceneCamera;
  223. }
  224. //==================================
  225. // ResetIntroCamera
  226. //==================================
  227. void ResetIntroCamera()
  228. {
  229. }
  230. //==================================
  231. // SetCharacterFemale
  232. //==================================
  233. void SetCharacterFemale(bool fem)
  234. {
  235. m_IsCharFemale = fem;
  236. }
  237. //==================================
  238. // IsCharacterFemale
  239. //==================================
  240. bool IsCharacterFemale()
  241. {
  242. return m_IsCharFemale;
  243. }
  244. //==================================
  245. // CreateRandomCharacter
  246. //==================================
  247. void CreateRandomCharacter()
  248. {
  249. string character_name;
  250. string params[2];
  251. m_IsCharFemale = Math.RandomInt(0, 2);
  252. if (m_IsCharFemale)
  253. {
  254. character_name = m_CharPersonalityFemaleList.GetRandomElement();
  255. }
  256. else
  257. {
  258. character_name = m_CharPersonalityMaleList.GetRandomElement();
  259. }
  260. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(UpdateCharacterPos, 250);
  261. }
  262. void UpdateSelectedUserName()
  263. {
  264. string name;
  265. BiosUserManager user_manager = GetGame().GetUserManager();
  266. if( user_manager )
  267. {
  268. BiosUser user = user_manager.GetSelectedUser();
  269. if( user )
  270. {
  271. g_Game.SetPlayerGameName( user.GetName() );
  272. return;
  273. }
  274. }
  275. g_Game.SetPlayerGameName(GameConstants.DEFAULT_CHARACTER_NAME);
  276. }
  277. void UpdateCharacterPos()
  278. {
  279. if (m_Character.GetCharacterObj())
  280. {
  281. m_Character.GetCharacterObj().SetPosition(m_CharacterPos);
  282. m_Character.GetCharacterObj().SetDirection(m_CharacterDir.Normalized() );
  283. }
  284. }
  285. void SaveCharName( string name )
  286. {
  287. GetDayZGame().InitCharacterMenuDataInfo(m_MenuData.GetCharactersCount());
  288. //if (!GetDayZGame().IsNewCharacter() && m_LastPlayedCharacterID > -1)
  289. //{
  290. m_MenuData.SetCharacterName(m_LastPlayedCharacterID, name);
  291. //}
  292. if (m_Character.IsDefaultCharacter())
  293. {
  294. GetGame().GetMenuDefaultCharacterData().SetCharacterName(name);
  295. }
  296. m_MenuData.SaveCharactersLocal();
  297. }
  298. // ------------------------------------------------------------
  299. vector SnapToGround(vector pos)
  300. {
  301. float pos_x = pos[0];
  302. float pos_z = pos[2];
  303. float pos_y = GetGame().SurfaceY(pos_x, pos_z);
  304. vector tmp_pos = Vector(pos_x, pos_y, pos_z);
  305. tmp_pos[1] = tmp_pos[1] + pos[1];
  306. return tmp_pos;
  307. }
  308. };