4 using System.Collections.Generic;
26 private State currentState;
29 get {
return currentState; }
32 if (currentState == value) {
return; }
42 private readonly HashSet<Client> secondaryTraitors =
new HashSet<Client>();
48 return $
"{nameof(TraitorEvent)} ({prefab.Identifier})";
51 private readonly
static HashSet<Identifier> nonActionChildElementNames =
new HashSet<Identifier>()
53 "icon".ToIdentifier(),
54 "reputationrequirement".ToIdentifier(),
55 "missionrequirement".ToIdentifier(),
56 "levelrequirement".ToIdentifier()
63 codeWord =
string.Empty;
70 DebugConsole.ThrowError($
"Error when initializing event \"{prefab.Identifier}\": traitor not set.\n" + Environment.StackTrace);
76 if (codeWord.IsNullOrEmpty())
79 codeWord = TextManager.Get(
"traitor.codeword");
83 .
Replace(
"[traitor]", traitor?.Name ??
"none")
92 throw new InvalidOperationException($
"Tried to set a client who's not controlling a character (\"{traitor.Name}\") as the traitor.");
94 this.traitor = traitor;
105 foreach (var traitor
in traitors)
107 if (traitor.Character ==
null)
109 throw new InvalidOperationException($
"Tried to set a client who's not controlling a character (\"{traitor.Name}\") as a secondary traitor.");
111 if (this.traitor == traitor)
113 DebugConsole.ThrowError($
"Tried to assign the main traitor {traitor.Name} as a secondary traitor.");
116 secondaryTraitors.Add(traitor);
117 traitor.Character.IsTraitor =
true;
118 AddTarget(Tags.SecondaryTraitor, traitor.Character);
119 AddTarget((Tags.SecondaryTraitor.ToString() + index).ToIdentifier(), traitor.Character);
120 AddTarget(Tags.AnyTraitor, traitor.Character);
Event sets are sets of random events that occur within a level (most commonly, monster spawns and scr...
LocalizedString Replace(Identifier find, LocalizedString replace, StringComparison stringComparison=StringComparison.Ordinal)
sealed record TargetPredicate(TargetPredicate.EntityType Type, Predicate< Entity > Predicate)
void AddTargetPredicate(Identifier tag, TargetPredicate.EntityType entityType, Predicate< Entity > predicate)
void AddTarget(Identifier tag, Entity target)
IEnumerable< Entity > GetTargets(Identifier tag)
IEnumerable< Client > SecondaryTraitors
TraitorEvent(TraitorEventPrefab prefab, int seed)
override void InitEventSpecific(EventSet? parentSet=null)
override IEnumerable< Identifier > NonActionChildElementNames
void SetSecondaryTraitors(IEnumerable< Client > traitors)
override string ToString()
void SetTraitor(Client traitor)
override LocalizedString ReplaceVariablesInEventText(LocalizedString str)