Client LuaCsForBarotrauma
UnlockPathAction.cs
2 using Microsoft.Xna.Framework;
3 using System;
4 
5 namespace Barotrauma
6 {
11  {
12  public UnlockPathAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element) { }
13 
14  private bool isFinished = false;
15 
16  public override bool IsFinished(ref string goTo)
17  {
18  return isFinished;
19  }
20 
21  public override void Reset()
22  {
23  isFinished = false;
24  }
25 
26  public override void Update(float deltaTime)
27  {
28  if (isFinished) { return; }
30  {
32  {
33  if (!connection.Locked) { continue; }
34  connection.Locked = false;
35 #if SERVER
36  NotifyUnlock(connection);
37 #else
38  new GUIMessageBox(string.Empty, TextManager.Get("pathunlockedgeneric"),
39  Array.Empty<LocalizedString>(), type: GUIMessageBox.Type.InGame, iconStyle: "UnlockPathIcon", relativeSize: new Vector2(0.3f, 0.15f), minSize: new Point(512, 128));
40 #endif
41  }
42  }
43 
44  isFinished = true;
45  }
46 
47  public override string ToDebugString()
48  {
49  return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(UnlockPathAction)}";
50  }
51 
52 #if SERVER
53  private void NotifyUnlock(LocationConnection connection)
54  {
55  foreach (Client client in GameMain.Server.ConnectedClients)
56  {
57  IWriteMessage outmsg = new WriteOnlyMessage();
58  outmsg.WriteByte((byte)ServerPacketHeader.EVENTACTION);
59  outmsg.WriteByte((byte)EventManager.NetworkEventType.UNLOCKPATH);
60  outmsg.WriteUInt16((UInt16)GameMain.GameSession.Map.Connections.IndexOf(connection));
61  GameMain.Server.ServerPeer.Send(outmsg, client.Connection, DeliveryMethod.Reliable);
62  }
63  }
64 #endif
65  }
66 }
static GameSession?? GameSession
Definition: GameMain.cs:88
readonly List< LocationConnection > Connections
Definition: Location.cs:57
List< LocationConnection > Connections
Unlocks a "locked" pathways between locations, if there are any such paths adjacent to the current lo...
override bool IsFinished(ref string goTo)
Has the action finished.
UnlockPathAction(ScriptedEvent parentEvent, ContentXElement element)
override void Update(float deltaTime)
override string ToDebugString()
Rich test to display in debugdraw