4 using System.Collections.Generic;
36 private readonly HashSet<Identifier> tags =
new HashSet<Identifier>();
41 get =>
string.Join(
",", tags);
45 if (!
string.IsNullOrWhiteSpace(value))
47 string[] splitTags = value.Split(
',');
48 foreach (var tag
in splitTags)
50 tags.Add(tag.ToIdentifier());
56 private readonly HashSet<Identifier> moduleFlags =
new HashSet<Identifier>();
61 get =>
string.Join(
",", moduleFlags);
65 if (!
string.IsNullOrWhiteSpace(value))
67 string[] splitFlags = value.Split(
',');
68 foreach (var f
in splitFlags)
70 moduleFlags.Add(f.ToIdentifier());
77 private readonly HashSet<Identifier> spawnPointTags =
new HashSet<Identifier>();
82 get =>
string.Join(
",", spawnPointTags);
85 spawnPointTags.Clear();
86 if (!
string.IsNullOrWhiteSpace(value))
88 string[] splitTags = value.Split(
',');
89 foreach (var tag
in splitTags)
91 spawnPointTags.Add(tag.ToIdentifier());
97 [
Serialize(
false,
IsPropertySaveable.No, description:
"If enabled, the NPC will not spawn if the specified spawn point tags can't be found.")]
107 "Affects how far the character can hear sounds created by AI targets with the tag ProvocativeToHumanAI. "+
108 "Used as a multiplier on the sound range of the target, e.g. a value of 0.5 would mean a target with a sound range of 1000 would need to be within 500 units for this character to hear it. "+
109 "Only affects the \"fight intruders\" objective, which makes the character go and inspect noises.")]
129 public XElement
Element {
get;
protected set; }
144 this.NpcSetIdentifier = npcSetIdentifier;
159 return spawnPointTags;
162 public JobPrefab GetJobPrefab(Rand.RandSync randSync = Rand.RandSync.Unsynced, Func<JobPrefab, bool> predicate =
null)
195 if (positionToStayIn !=
null && humanAI !=
null)
197 humanAI.ObjectiveManager.SetForcedOrder(
new AIObjectiveGoTo(positionToStayIn, npc, humanAI.ObjectiveManager, repeat:
true, getDivingGearIfNeeded:
false, closeEnough: 200)
199 FaceTargetOnCompleted =
false,
200 DebugLogWhenFails =
false,
211 var spawnItems = ToolBox.SelectWeightedRandom(
ItemSets, it => it.commonness, randSync).element;
212 if (spawnItems !=
null)
217 for (
int i = 0; i < amount; i++)
219 InitializeItem(character, itemElement, submarine,
this, spawnPoint, createNetworkEvents: createNetworkEvents);
233 var characterElement = ToolBox.SelectWeightedRandom(
CustomCharacterInfos, info => info.commonness, randSync).element;
235 if (characterElement ==
null)
248 skill.IncreaseSkill(newSkill - skill.Level, increasePastMax:
false);
254 return characterInfo;
262 if (itemPrefab ==
null)
264 DebugConsole.ThrowError(
"Tried to spawn \"" + humanPrefab?.
Identifier +
"\" with the item \"" + itemIdentifier +
"\". Matching item prefab not found.",
272 if (
GameMain.Server.EntityEventManager.UniqueEvents.Any(ev => ev.Entity == item))
274 string errorMsg = $
"Error while spawning job items. Item {item.Name} created network events before the spawn event had been created.";
275 DebugConsole.ThrowError(errorMsg);
276 GameAnalyticsManager.AddErrorEventOnce(
"Job.InitializeJobItem:EventsBeforeSpawning", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
277 GameMain.Server.EntityEventManager.UniqueEvents.RemoveAll(ev => ev.Entity == item);
278 GameMain.Server.EntityEventManager.Events.RemoveAll(ev => ev.Entity == item);
287 List<InvSlotType> allowedSlots =
288 item.GetComponents<
Pickable>().Count() > 1 ?
300 if (idCardComponent !=
null)
302 idCardComponent.
Initialize(spawnPoint, character);
309 foreach (
string tag
in idCardTags)
317 wifiComponent.
TeamID = character.TeamID;
319 parentItem?.Combine(item, user:
null);
323 for (
int i = 0; i < amount; i++)
325 InitializeItem(character, childItemElement, submarine, humanPrefab, spawnPoint, item, createNetworkEvents);
readonly HashSet< Identifier > PreferredOutpostModuleTypes
virtual AIController AIController
CharacterInventory Inventory
override Vector2 Position
Stores information about the Character that is needed between rounds in the menu etc....
void GiveExperience(int amount)
override bool TryPutItem(Item item, Character user, IEnumerable< InvSlotType > allowedSlots=null, bool createNetworkEvent=true, bool ignoreCondition=false)
If there is room, puts the item in the inventory and returns true, otherwise returns false
static readonly Identifier HumanSpeciesName
Base class for content file types, which are loaded from filelist.xml via reflection....
string? GetAttributeString(string key, string? def)
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
IEnumerable< ContentXElement > GetChildElements(string name)
IEnumerable< ContentXElement > Elements()
bool GetAttributeBool(string key, bool def)
int GetAttributeInt(string key, int def)
string?[] GetAttributeStringArray(string key, string[]? def, bool convertToLowerInvariant=false)
static EntitySpawner Spawner
static GameSession?? GameSession
AIObjectiveManager ObjectiveManager
IEnumerable< Identifier > GetSpawnPointTags()
CharacterInfo CreateCharacterInfo(Rand.RandSync randSync=Rand.RandSync.Unsynced)
Creates a character info from the human prefab. If there are custom character infos defined,...
readonly List<(ContentXElement element, float commonness)> CustomCharacterInfos
HumanPrefab(ContentXElement element, ContentFile file, Identifier npcSetIdentifier)
readonly List<(ContentXElement element, float commonness)> ItemSets
bool RequireSpawnPointTag
IEnumerable< Identifier > GetTags()
float HealthMultiplierInMultiplayer
bool AllowDraggingIndefinitely
void InitializeCharacter(Character npc, ISpatialEntity positionToStayIn=null)
JobPrefab GetJobPrefab(Rand.RandSync randSync=Rand.RandSync.Unsynced, Func< JobPrefab, bool > predicate=null)
IEnumerable< Identifier > GetModuleFlags()
bool GiveItems(Character character, Submarine submarine, WayPoint spawnPoint, Rand.RandSync randSync=Rand.RandSync.Unsynced, bool createNetworkEvents=true)
static void InitializeItem(Character character, ContentXElement itemElement, Submarine submarine, HumanPrefab humanPrefab, WayPoint spawnPoint=null, Item parentItem=null, bool createNetworkEvents=true)
readonly Identifier NpcSetIdentifier
AIObjectiveIdle.BehaviorType Behavior
Identifier[] PreferredOutpostModuleTypes
CampaignMode.InteractionType CampaignInteractionType
IEnumerable< InvSlotType > AllowedSlots
void Initialize(WayPoint spawnPoint, Character character)
List< InvSlotType > AllowedSlots
IEnumerable< Skill > GetSkills()
static JobPrefab Random(Rand.RandSync sync, Func< JobPrefab, bool > predicate=null)
static JobPrefab Get(Identifier identifier)
static MapEntityPrefab FindByIdentifier(Identifier identifier)
readonly Identifier Identifier
Prefab that has a property serves as a deterministic hash of a prefab's identifier....
static Dictionary< Identifier, SerializableProperty > DeserializeProperties(object obj, XElement element=null)
int??? SubmarineSpecificIDTag