1 class IntroSceneCharacter
extends Managed
3 protected int m_CharacterId;
4 protected string m_CharacterType;
7 protected vector m_CharacterPos;
8 protected vector m_CharacterRot;
19 void IntroSceneCharacter()
24 void ~IntroSceneCharacter()
29 bool IsDefaultCharacter()
31 return m_CharacterId ==
GameConstants.DEFAULT_CHARACTER_MENU_ID;
34 void SetToDefaultCharacter()
41 void SetCharacterID(
int char_id)
43 m_CharacterId = char_id;
59 return m_CharacterObj;
67 return m_CharGenderList;
75 return m_Characters[gender];
83 return m_CharShirtList;
91 return m_CharPantsList;
99 return m_CharShoesList;
107 m_CharGender = gender;
113 bool IsCharacterFemale()
131 return m_CharacterObj.GetPosition();
137 int GetNextCharacterID()
139 int count = m_CharacterDta.GetCharactersCount();
146 if ( m_CharacterId + 1 < count )
148 return m_CharacterId + 1;
159 int GetPrevCharacterID()
161 int count = m_CharacterDta.GetCharactersCount();
168 if ( m_CharacterId > -1 )
170 return m_CharacterId - 1;
179 void CreateNewCharacterRandom()
182 SetCharacterGender(
Math.RandomInt(0, 2) );
185 string char_name_random = m_Characters[GetCharacterGender()].GetRandomElement();
188 CreateNewCharacterByName( char_name_random );
194 void CreateNewCharacterById(
int character_id )
196 if ( character_id ==
GameConstants.DEFAULT_CHARACTER_MENU_ID )
198 CreateDefaultCharacter();
202 CharacterLoad( character_id, m_CharacterPos, m_CharacterRot );
209 void CreateNewCharacterByName(
string character_name,
bool randomize_equip =
true )
211 m_CharacterType = character_name;
212 GetGame().GetMenuDefaultCharacterData().SetCharacterType(m_CharacterType);
214 GetGame().GetMenuDefaultCharacterData().GenerateRandomEquip();
216 CreateNewCharacter();
219 void CreateDefaultCharacter()
223 m_CharacterType =
GetGame().GetMenuDefaultCharacterData().GetCharacterType();
224 if (m_CharacterType !=
"")
226 CreateNewCharacter();
231 m_CharacterObj.PlaceOnSurface();
232 m_CharacterObj.SetPosition(m_CharacterPos);
233 m_CharacterObj.SetOrientation(m_CharacterRot);
238 CreateNewCharacterRandom();
244 void GetLastPlayedServer(
int characterID, out
string address, out
string name, out
int port)
246 m_CharacterDta.GetLastServerAddress(characterID,address);
247 port = m_CharacterDta.GetLastServerPort(characterID);
248 m_CharacterDta.GetLastServerName(characterID,
name);
253 void CreateNewCharacter()
263 m_CharacterObj.PlaceOnSurface();
264 m_CharacterObj.SetOrientation(m_CharacterRot);
265 GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_CharacterObj);
269 SetupPlayerName(
true );
292 void LoadCharacterData(
vector char_pos,
vector char_rot,
bool default_char =
false)
294 m_CharacterDta =
g_Game.GetMenuData();
295 m_CharacterPos = char_pos;
296 m_CharacterRot = char_rot;
298 if (!default_char && m_CharacterDta.GetLastPlayedCharacter() > -1 )
300 m_CharacterId = m_CharacterDta.GetLastPlayedCharacter();
301 m_CharacterDta.GetCharacterName(m_CharacterId,
g_Game.GetPlayerGameName());
305 g_Game.ConfigGetTextArray(
"cfgCharacterCreation" +
" gender", m_CharGenderList);
306 g_Game.ConfigGetTextArray(
"cfgCharacterCreation" +
" top", m_CharShirtList);
307 g_Game.ConfigGetTextArray(
"cfgCharacterCreation" +
" bottom", m_CharPantsList);
308 g_Game.ConfigGetTextArray(
"cfgCharacterCreation" +
" shoe", m_CharShoesList);
311 m_Characters.Clear();
317 for (
int i = 0; i < characters.Count(); i++)
319 string char_cfg_name = characters.Get(i);
320 if (
GetGame().IsKindOf(char_cfg_name,
"SurvivorMale_Base") )
322 m_Characters[
ECharGender.Male].Insert( char_cfg_name );
326 m_Characters[
ECharGender.Female].Insert( char_cfg_name );
330 CreateNewCharacterById(m_CharacterId);
332 if (GetCharacterObj() )
334 if ( GetCharacterObj().IsMale() )
344 protected void CharacterUnload()
346 if ( m_CharacterObj )
348 g_Game.ObjectDelete(m_CharacterObj);
349 m_CharacterObj = NULL;
356 protected void CharacterLoad(
int character_id,
vector char_pos,
vector char_rot )
358 if ( character_id == -1 )
360 Error(
"IntroSceneCharacter->CharacterLoad: character_id = "+ character_id +
" Cant Load Character!!!");
366 SetCharacterID( character_id );
368 m_CharacterObj =
PlayerBase.Cast( m_CharacterDta.CreateCharacterPerson( character_id ) );
370 if ( m_CharacterObj )
373 m_CharacterObj.PlaceOnSurface();
374 m_CharacterObj.SetPosition(char_pos);
375 m_CharacterObj.SetOrientation(char_rot);
382 protected void SetupPlayerName(
bool new_name )
386 #ifdef PLATFORM_CONSOLE
390 BiosUser user = user_manager.GetSelectedUser();
393 name = user.GetName();
399 m_CharacterDta.GetCharacterName(m_CharacterId,
name);
409 void SetAttachment(
string type,
int slot)
411 if ( !m_CharacterObj )
416 g_Game.ObjectDelete(m_CharacterObj.GetInventory().FindAttachment(slot));
422 m_CharacterObj.LocalTakeEntityAsAttachmentEx(entity, slot);
426 string GetCharacterNameById(
int char_id )
428 string character_name;
431 character_name =
GetGame().GetMenuDefaultCharacterData().GetCharacterName();
435 m_CharacterDta.GetCharacterName(char_id, character_name);
437 return character_name;
440 string GetCharacterName()
442 string character_name;
443 if (IsDefaultCharacter())
445 character_name =
GetGame().GetMenuDefaultCharacterData().GetCharacterName();
449 m_CharacterDta.GetCharacterName(m_CharacterId, character_name);
451 return character_name;
457 void SaveCharName(
string name )
459 if (IsDefaultCharacter())
461 GetGame().GetMenuDefaultCharacterData().SetCharacterName(
name);
465 m_CharacterDta.SetCharacterName(m_CharacterId,
name);
467 m_CharacterDta.SaveCharactersLocal();
473 void SaveDefaultCharacter()
477 m_CharacterDta.RequestSetDefaultCharacterData();