3 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
11 private Identifier[] targetItemIdentifiers;
13 private List<Item> targetItems;
15 private int minItemAmount, maxItemAmount;
17 private float decreaseConditionAmount;
19 private float duration;
25 return "MalfunctionEvent (" +
string.Join(
", ", targetItemIdentifiers) +
")";
31 targetItems =
new List<Item>();
44 var matchingItems =
Item.
ItemList.FindAll(i => i.Condition > 0.0f && targetItemIdentifiers.Contains(i.Prefab.Identifier));
45 int itemAmount = Rand.Range(minItemAmount, maxItemAmount, Rand.RandSync.ServerAndClient);
46 for (
int i = 0; i < itemAmount; i++)
48 if (matchingItems.Count == 0)
break;
49 targetItems.Add(matchingItems[Rand.Int(matchingItems.Count, Rand.RandSync.ServerAndClient)]);
53 public override void Update(
float deltaTime)
56 if (targetItems.Count == 0 || timer >= duration)
62 targetItems.RemoveAll(i => i.Removed || i.Condition <= 0.0f);
63 foreach (
Item item
in targetItems)
71 item.
Condition -= decreaseConditionAmount / duration * deltaTime;
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
float GetAttributeFloat(string key, float def)
int GetAttributeInt(string key, int def)
readonly EventPrefab prefab
readonly ContentXElement ConfigElement
Event sets are sets of random events that occur within a level (most commonly, monster spawns and scr...
static readonly List< Item > ItemList
override void Update(float deltaTime)
MalfunctionEvent(EventPrefab prefab, int seed)
override string ToString()
override void InitEventSpecific(EventSet parentSet)