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; }
54 var idCard = item.GetComponent<Items.
Components.IdCard>();
60 idCard.SubmarineSpecificID = 0;
70 info.StartItemsGiven =
true;
71 crewManager.AddCharacter(npc);
75 DebugConsole.AddWarning($
"Attempted to change the team of a character ({npc.Name}) that doesn't have Character Info. Can't add to the crew.");
87 info.StartItemsGiven =
true;
88 crewManager.RemoveCharacter(npc, removeInfo:
true);
92 DebugConsole.AddWarning($
"Attempted to change the team of a character ({npc.Name}) that doesn't have Character Info. Can't remove from the crew.");
95 ChangeItemTeam(sub,
false);
103 void ChangeItemTeam(
Submarine sub,
bool allowStealing)
108 if (item.GetComponent<Items.
Components.WifiComponent>() is { } wifiComponent)
110 wifiComponent.TeamID =
TeamID;
112 if (item.GetComponent<Items.
Components.IdCard>() is { } idCard)
114 idCard.SubmarineSpecificID = 0;
120 if (subWaypoint !=
null)
141 return $
"{ToolBox.GetDebugSymbol(isFinished)} {nameof(NPCChangeTeamAction)} -> (NPCTag: {NPCTag.ColorizeObject()})";
void GiveIdCardTags(WayPoint spawnPoint, bool createNetworkEvent=false)
CharacterInventory Inventory
void SetOriginalTeamAndChangeTeam(CharacterTeamType newTeam, bool processImmediately=false)
Saves the character's original team (which affects e.g. whether the character considers the sub/outpo...
Stores information about the Character that is needed between rounds in the menu etc....
ContentPackage? ContentPackage
Responsible for keeping track of the characters in the player crew, saving and loading their orders,...
readonly ScriptedEvent ParentEvent
static GameSession?? GameSession
static NetworkMember NetworkMember
virtual IEnumerable< Item > AllItems
All items contained in the inventory. Stacked items are returned as individual instances....
List< Item > FindAllItems(Func< Item, bool > predicate=null, bool recursive=false, List< Item > list=null)
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 Submarine MainSub
Note that this can be null in some situations, e.g. editors and missions that don't load a submarine.
static List< Submarine > Loaded
static List< WayPoint > WayPointList