Client LuaCsForBarotrauma
CheckTraitorVoteAction.cs
1 #nullable enable
3 using System.Linq;
4 
5 namespace Barotrauma
6 {
11  {
12  [Serialize("", IsPropertySaveable.Yes, description: "Tag of the character to check.")]
13  public Identifier Target { get; set; }
14 
15  public CheckTraitorVoteAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
16  {
17  if (parentEvent is not TraitorEvent)
18  {
19  DebugConsole.ThrowError($"Error in event \"{parentEvent.Prefab.Identifier}\" - {nameof(CheckTraitorVoteAction)} can only be used in traitor events.",
20  contentPackage: element.ContentPackage);
21  }
22  }
23 
24  protected override bool? DetermineSuccess()
25  {
26  var targetEntities = ParentEvent.GetTargets(Target);
27 #if SERVER
28  if (GameMain.Server?.TraitorManager?.GetClientAccusedAsTraitor() is Client traitorClient)
29  {
30  return targetEntities.Any(e => e is Character character && traitorClient?.Character == character);
31  }
32 #endif
33  return false;
34  }
35 
36  public override string ToDebugString()
37  {
38  return $"{ToolBox.GetDebugSymbol(succeeded.HasValue)} {nameof(CheckTraitorVoteAction)} -> (TargetTag: {Target.ColorizeObject()}";
39  }
40  }
41 }
Checks whether the specific target was voted as the traitor.
CheckTraitorVoteAction(ScriptedEvent parentEvent, ContentXElement element)
override string ToDebugString()
Rich test to display in debugdraw
ContentPackage? ContentPackage
readonly ScriptedEvent ParentEvent
Definition: EventAction.cs:106
IEnumerable< Entity > GetTargets(Identifier tag)