Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Events/Missions/AbandonedOutpostMission.cs
3 
4 namespace Barotrauma
5 {
6  partial class AbandonedOutpostMission : Mission
7  {
8  public override int State
9  {
10  get { return base.State; }
11  set
12  {
13  if (state != value)
14  {
15  base.State = value;
16  if (state == HostagesKilledState && !hostagesKilledMessage.IsNullOrEmpty())
17  {
18  CreateMessageBox(string.Empty, hostagesKilledMessage);
19  }
20  }
21  }
22  }
23 
24  public override bool DisplayAsCompleted => State > 0 && requireRescue.None();
25  public override bool DisplayAsFailed => State == HostagesKilledState;
26 
27  public override void ClientReadInitial(IReadMessage msg)
28  {
29  base.ClientReadInitial(msg);
30  ushort targetItemCount = msg.ReadUInt16();
31  for (int i = 0; i < targetItemCount; i++)
32  {
33  var item = Item.ReadSpawnData(msg);
34  items.Add(item);
35  }
36 
37  byte characterCount = msg.ReadByte();
38 
39  for (int i = 0; i < characterCount; i++)
40  {
41  Character character = Character.ReadSpawnData(msg);
42  characters.Add(character);
43  if (msg.ReadBoolean()) { requireKill.Add(character); }
44  if (msg.ReadBoolean())
45  {
46  requireRescue.Add(character);
47 #if CLIENT
48  if (allowOrderingRescuees)
49  {
51  }
52 #endif
53  }
54  ushort itemCount = msg.ReadUInt16();
55  for (int j = 0; j < itemCount; j++)
56  {
57  Item.ReadSpawnData(msg);
58  }
59  if (character.Submarine != null && character.AIController is EnemyAIController enemyAi)
60  {
61  enemyAi.UnattackableSubmarines.Add(character.Submarine);
62  enemyAi.UnattackableSubmarines.Add(Submarine.MainSub);
63  foreach (Submarine sub in Submarine.MainSub.DockedTo)
64  {
65  enemyAi.UnattackableSubmarines.Add(sub);
66  }
67  }
68  }
69  if (characters.Contains(null))
70  {
71  throw new System.Exception("Error in AbandonedOutpostMission.ClientReadInitial: character list contains null (mission: " + Prefab.Identifier + ")");
72  }
73  if (characters.Count != characterCount)
74  {
75  throw new System.Exception("Error in AbandonedOutpostMission.ClientReadInitial: character count does not match the server count (" + characters + " != " + characters.Count + "mission: " + Prefab.Identifier + ")");
76  }
77  }
78  }
79 }
GUIComponent AddCharacterToCrewList(Character character)
Add character to the list without actually adding it to the crew
Submarine Submarine
Definition: Entity.cs:53
static GameSession?? GameSession
Definition: GameMain.cs:88
static Item ReadSpawnData(IReadMessage msg, bool spawn=true)
void CreateMessageBox(LocalizedString header, LocalizedString message)
readonly Identifier Identifier
Definition: Prefab.cs:34