1 using Microsoft.Xna.Framework;
13 private Vector2 spawnPos;
15 private bool spawnPending;
24 get {
return spawnPos; }
29 return $
"ArtifactEvent ({(itemPrefab == null ? "null" : itemPrefab.Name)})";
37 DebugConsole.ThrowError(
"Error in ArtifactEvent - use item identifier instead of the name of the item.",
41 if (itemPrefab ==
null)
43 DebugConsole.ThrowError(
"Error in SalvageMission: couldn't find an item prefab with the name " + itemName);
50 if (itemPrefab ==
null)
52 DebugConsole.ThrowError(
"Error in ArtifactEvent - couldn't find an item prefab with the identifier " + itemIdentifier,
61 (Rand.Value(Rand.RandSync.ServerAndClient) < 0.5f) ?
72 $
"Finished: {IsFinished.ColorizeObject()}\n" +
73 $
"Item: {Item.ColorizeObject()}\n" +
74 $
"Spawn pending: {SpawnPending.ColorizeObject()}\n" +
75 $
"Spawn position: {SpawnPos.ColorizeObject()}";
78 private void SpawnItem()
80 item =
new Item(itemPrefab, spawnPos,
null);
86 if (it.
Submarine !=
null || !it.
HasTag(Tags.ArtifactHolder)) {
continue; }
88 var itemContainer = it.GetComponent<Items.
Components.ItemContainer>();
89 if (itemContainer ==
null)
continue;
90 if (itemContainer.Combine(item, user:
null))
break;
93 if (GameSettings.CurrentConfig.VerboseLogging)
95 DebugConsole.NewMessage(
"Initialized ArtifactEvent (" + item.
Name +
")", Color.White);
99 if (GameMain.Server !=
null)
101 Entity.Spawner.CreateNetworkEvent(
new EntitySpawner.SpawnEntity(item));
106 public override void Update(
float deltaTime)
110 if (itemPrefab ==
null)
116 spawnPending =
false;
ArtifactEvent(EventPrefab prefab, int seed)
override Vector2 DebugDrawPos
override void InitEventSpecific(EventSet parentSet)
override string GetDebugInfo()
override string ToString()
override void Update(float deltaTime)
string? GetAttributeString(string key, string? def)
XAttribute? GetAttribute(string name)
Identifier GetAttributeIdentifier(string key, string def)
Func< Level.InterestingPosition, bool > SpawnPosFilter
readonly EventPrefab prefab
readonly ContentXElement ConfigElement
Event sets are sets of random events that occur within a level (most commonly, monster spawns and scr...
Inventory ParentInventory
bool HasTag(Identifier tag)
override string Name
Note that this is not a LocalizedString instance, just the current name of the item as a string....
static readonly List< Item > ItemList
List< ItemComponent > Components
Vector2 GetRandomItemPos(PositionType spawnPosType, float randomSpread, float minDistFromSubs, float offsetFromWall=10.0f, Func< InterestingPosition, bool > filter=null)
static MapEntityPrefab FindByIdentifier(Identifier identifier)
static MapEntityPrefab Find(string name, string identifier=null, bool showErrorMessages=true)
Find a matching map entity prefab
static Submarine MainSub
Note that this can be null in some situations, e.g. editors and missions that don't load a submarine.