dayzintroscenexbox.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 fog = 0.0;
  69. m_Weather = g_Game.GetWeather();
  70. m_Weather.GetOvercast().SetLimits(overcast, overcast);
  71. m_Weather.GetRain().SetLimits(rain, rain);
  72. m_Weather.GetFog().SetLimits(fog, fog);
  73. m_Weather.GetOvercast().Set(overcast, 0, 0);
  74. m_Weather.GetRain().Set(rain, 0, 0);
  75. m_Weather.GetFog().Set(fog, 0, 0);
  76. m_Character = new IntroSceneCharacter();
  77. m_Character.LoadCharacterData(m_CharacterPos, m_CharacterDir);
  78. m_TimerParticle.Run(0.1, this, "SetupParticles", null, false);
  79. //m_TimerDate.Run(2.0, this, "SetupDate", null, false);
  80. m_TimerUpdate.Run(0.5, this, "SetupCharacter", null, true);
  81. vector clut_pos = SnapToGround( m_CharacterPos + "-1 0 0" );
  82. m_Clutter = GetGame().CreateObject( "ClutterCutter2x2", clut_pos, true );
  83. // Xbox check update
  84. CheckXboxClientUpdateLoopStart();
  85. g_Game.SetHudBrightness(g_Game.GetHUDBrightnessSetting());
  86. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetInitPostprocesses);
  87. }
  88. void ~DayZIntroSceneXbox()
  89. {
  90. if ( m_TimerUpdate )
  91. {
  92. m_TimerUpdate.Stop();
  93. delete m_TimerUpdate;
  94. m_TimerUpdate = null;
  95. }
  96. if ( m_TimerParticle )
  97. {
  98. m_TimerParticle.Stop();
  99. delete m_TimerParticle;
  100. m_TimerParticle = null;
  101. }
  102. if ( m_TimerDate )
  103. {
  104. m_TimerDate.Stop();
  105. delete m_TimerDate;
  106. m_TimerDate = null;
  107. }
  108. CheckXboxClientUpdateLoopStop();
  109. GetGame().ObjectDelete( m_SceneCamera );
  110. if ( m_MenuData )
  111. {
  112. m_MenuData.ClearCharacters();
  113. }
  114. SEffectManager.DestroyEffect(m_FXParticleCarSmoke);
  115. SEffectManager.DestroyEffect(m_FXParticleStreamLeft);
  116. SEffectManager.DestroyEffect(m_FXParticleStreamRight);
  117. PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
  118. }
  119. protected void SetInitPostprocesses()
  120. {
  121. PPERequester_MenuEffects requester;
  122. Class.CastTo(requester,PPERequesterBank.GetRequester(PPERequester_MenuEffects));
  123. requester.SetVignetteIntensity(0.3);
  124. PPERequesterBank.GetRequester(PPERequester_IntroChromAbb).Start();
  125. }
  126. //==============================================
  127. // GetIntroSceneCharacter
  128. //==============================================
  129. IntroSceneCharacter GetIntroCharacter()
  130. {
  131. return m_Character;
  132. }
  133. //==================================
  134. // SetupCharacter
  135. //==================================
  136. void SetupCharacter()
  137. {
  138. if ( m_Character.GetCharacterObj() )
  139. {
  140. vector v = m_Character.GetCharacterObj().GetOrientation();
  141. v[0] = -75;
  142. m_Character.GetCharacterObj().SetOrientation(v);
  143. }
  144. }
  145. //==================================
  146. // SetupParticles
  147. //==================================
  148. void SetupParticles()
  149. {
  150. m_FXParticleCarSmoke = new MenuCarEngineSmoke();
  151. //SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1330.36 2.11628 1594.31");
  152. //SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1333.88 1.51392 1594.88");
  153. SEffectManager.PlayInWorld(m_FXParticleCarSmoke, "1331.52 2.34052 1593.55");
  154. vector pos = m_SceneCamera.GetPosition() + m_SceneCamera.GetDirection() * 1.5;
  155. vector dir = m_SceneCamera.GetDirection();
  156. float temp = dir[0];
  157. dir[0] = dir[2];
  158. dir[2] = -temp;
  159. vector pos_right = pos + (dir * 1.5);
  160. vector pos_left = pos + (-dir * 1.5);
  161. m_FXParticleStreamLeft = new MenuEvaporation();
  162. SEffectManager.PlayInWorld(m_FXParticleStreamLeft, pos_right);
  163. m_FXParticleStreamRight = new MenuEvaporation();
  164. SEffectManager.PlayInWorld(m_FXParticleStreamRight, pos_left);
  165. }
  166. //==================================
  167. // SetupDate
  168. //==================================
  169. void SetupDate()
  170. {
  171. //g_Game.GetWorld().SetDate(m_Date.Get(0), m_Date.Get(1), m_Date.Get(2), m_Date.Get(3), m_Date.Get(4));
  172. //g_Game.GetWorld().SetDate(2020, 10, 15, 18, 20);
  173. }
  174. //==================================
  175. // CheckXboxClientUpdateLoopStart
  176. //==================================
  177. void CheckXboxClientUpdateLoopStart()
  178. {
  179. if ( CheckXboxClientUpdate() )
  180. {
  181. m_TimerClientUpdate.Run(30, this, "CheckXboxClientUpdate", null, true);
  182. }
  183. }
  184. //==================================
  185. // CheckXboxClientUpdateLoopStop
  186. //==================================
  187. void CheckXboxClientUpdateLoopStop()
  188. {
  189. if ( m_TimerClientUpdate )
  190. {
  191. m_TimerClientUpdate.Stop();
  192. delete m_TimerClientUpdate;
  193. m_TimerClientUpdate = null;
  194. }
  195. }
  196. //==================================
  197. // CheckXboxClientUpdate
  198. //==================================
  199. bool CheckXboxClientUpdate()
  200. {
  201. return OnlineServices.CheckUpdate();
  202. }
  203. //==================================
  204. // CameraCreate
  205. //==================================
  206. 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)
  207. {
  208. Camera cam = Camera.Cast( g_Game.CreateObject("staticcamera", SnapToGround(cam_pos), true));
  209. cam.SetOrientation( Vector( cam_rot_h, cam_rot_v, 0) );
  210. cam.SetFOV( cam_fov );
  211. cam.SetFocus(cam_focus_dist, cam_focus_strg);
  212. return cam;
  213. }
  214. //==================================
  215. // GetCamera
  216. //==================================
  217. Camera GetCamera()
  218. {
  219. return m_SceneCamera;
  220. }
  221. //==================================
  222. // ResetIntroCamera
  223. //==================================
  224. void ResetIntroCamera()
  225. {
  226. }
  227. //==================================
  228. // SetCharacterFemale
  229. //==================================
  230. void SetCharacterFemale(bool fem)
  231. {
  232. m_IsCharFemale = fem;
  233. }
  234. //==================================
  235. // IsCharacterFemale
  236. //==================================
  237. bool IsCharacterFemale()
  238. {
  239. return m_IsCharFemale;
  240. }
  241. //==================================
  242. // CreateRandomCharacter
  243. //==================================
  244. void CreateRandomCharacter()
  245. {
  246. string character_name;
  247. string params[2];
  248. m_IsCharFemale = Math.RandomInt(0, 2);
  249. if (m_IsCharFemale)
  250. {
  251. character_name = m_CharPersonalityFemaleList.GetRandomElement();
  252. }
  253. else
  254. {
  255. character_name = m_CharPersonalityMaleList.GetRandomElement();
  256. }
  257. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(UpdateCharacterPos, 250);
  258. }
  259. void UpdateSelectedUserName()
  260. {
  261. string name;
  262. BiosUserManager user_manager = GetGame().GetUserManager();
  263. if( user_manager )
  264. {
  265. BiosUser user = user_manager.GetSelectedUser();
  266. if( user )
  267. {
  268. g_Game.SetPlayerGameName( user.GetName() );
  269. return;
  270. }
  271. }
  272. g_Game.SetPlayerGameName(GameConstants.DEFAULT_CHARACTER_NAME);
  273. }
  274. void UpdateCharacterPos()
  275. {
  276. if (m_Character.GetCharacterObj())
  277. {
  278. m_Character.GetCharacterObj().SetPosition(m_CharacterPos);
  279. m_Character.GetCharacterObj().SetDirection(m_CharacterDir.Normalized() );
  280. }
  281. }
  282. void SaveCharName( string name )
  283. {
  284. GetDayZGame().InitCharacterMenuDataInfo(m_MenuData.GetCharactersCount());
  285. //if (!GetDayZGame().IsNewCharacter() && m_LastPlayedCharacterID > -1)
  286. //{
  287. m_MenuData.SetCharacterName(m_LastPlayedCharacterID, name);
  288. //}
  289. if (m_Character.IsDefaultCharacter())
  290. {
  291. GetGame().GetMenuDefaultCharacterData().SetCharacterName(name);
  292. }
  293. m_MenuData.SaveCharactersLocal();
  294. }
  295. // ------------------------------------------------------------
  296. vector SnapToGround(vector pos)
  297. {
  298. float pos_x = pos[0];
  299. float pos_z = pos[2];
  300. float pos_y = GetGame().SurfaceY(pos_x, pos_z);
  301. vector tmp_pos = Vector(pos_x, pos_y, pos_z);
  302. tmp_pos[1] = tmp_pos[1] + pos[1];
  303. return tmp_pos;
  304. }
  305. };