2 using System.Collections.Generic;
13 public Identifier
NPCTag {
get;
set; }
15 [
Serialize(
CharacterTeamType.None,
IsPropertySaveable.Yes, description:
"The team to move the NPC to. None = unspecified, Team1 = player crew, Team2 = the team opposing Team1 (= hostile to player crew), FriendlyNPC = friendly to all other teams.")]
24 private bool isFinished =
false;
32 if (!enums.Contains(
TeamID))
34 DebugConsole.ThrowError($
"Error in {nameof(NPCChangeTeamAction)} in the event {ParentEvent.Prefab.Identifier}. \"{TeamID}\" is not a valid Team ID. Valid values are {string.Join(',', Enum.GetNames(typeof(CharacterTeamType)))}.",
39 private List<Character> affectedNpcs =
null;
41 public override void Update(
float deltaTime)
43 if (isFinished) {
return; }
48 foreach (var npc
in affectedNpcs)
51 npc.SetOriginalTeam(
TeamID);
52 foreach (
Item item
in npc.Inventory.AllItems)
54 var idCard = item.GetComponent<Items.
Components.IdCard>();
60 idCard.SubmarineSpecificID = 0;
66 npc.Info.StartItemsGiven =
true;
76 npc.Info.StartItemsGiven =
true;
79 ChangeItemTeam(sub,
false);
86 void ChangeItemTeam(
Submarine sub,
bool allowStealing)
88 foreach (
Item item
in npc.Inventory.FindAllItems(recursive:
true))
91 if (item.GetComponent<Items.
Components.WifiComponent>() is { } wifiComponent)
93 wifiComponent.TeamID =
TeamID;
95 if (item.GetComponent<Items.
Components.IdCard>() is { } idCard)
97 idCard.SubmarineSpecificID = 0;
103 if (subWaypoint !=
null)
105 npc.GiveIdCardTags(subWaypoint, createNetworkEvent:
true);
124 return $
"{ToolBox.GetDebugSymbol(isFinished)} {nameof(NPCChangeTeamAction)} -> (NPCTag: {NPCTag.ColorizeObject()})";
ContentPackage? ContentPackage
void RemoveCharacter(Character character, bool removeInfo=false, bool resetCrewListIndex=true)
Remove the character from the crew (and crew menus).
void AddCharacter(Character character, bool sortCrewList=true)
readonly ScriptedEvent ParentEvent
static GameSession?? GameSession
static NetworkMember NetworkMember
List< ItemComponent > Components
Changes the team of an NPC. Most common use cases are adding a character to the crew,...
override void Update(float deltaTime)
override string ToDebugString()
Rich test to display in debugdraw
NPCChangeTeamAction(ScriptedEvent parentEvent, ContentXElement element)
override bool IsFinished(ref string goTo)
Has the action finished.
IEnumerable< Entity > GetTargets(Identifier tag)
static List< Submarine > Loaded
static List< WayPoint > WayPointList