Client LuaCsForBarotrauma
Event.cs
1 using Microsoft.Xna.Framework;
2 using System;
3 using System.Collections.Generic;
4 
5 namespace Barotrauma
6 {
7  class Event
8  {
9  public event Action Finished;
10  protected bool isFinished;
11 
12  public readonly int RandomSeed;
13 
14  protected readonly EventPrefab prefab;
15 
17 
18  public EventSet ParentSet { get; private set; }
19 
20  public bool Initialized { get; private set; }
21 
23 
24  public bool IsFinished
25  {
26  get { return isFinished; }
27  }
28 
29  public override string ToString()
30  {
31  return "Event (" + prefab.EventType.ToString() +")";
32  }
33 
34  public virtual Vector2 DebugDrawPos
35  {
36  get
37  {
38  return Vector2.Zero;
39  }
40  }
41 
42  public Event(EventPrefab prefab, int seed)
43  {
44  RandomSeed = seed;
45  this.prefab = prefab ?? throw new ArgumentNullException(nameof(prefab));
46  }
47 
48  public virtual IEnumerable<ContentFile> GetFilesToPreload()
49  {
50  yield break;
51  }
52 
53  public void Init(EventSet parentSet = null)
54  {
55  Initialized = true;
56  ParentSet = parentSet;
57  InitEventSpecific(parentSet);
58  }
59 
60  protected virtual void InitEventSpecific(EventSet parentSet = null)
61  {
62  }
63 
64  public virtual string GetDebugInfo()
65  {
66  return $"Finished: {IsFinished.ColorizeObject()}";
67  }
68 
69  public virtual void Update(float deltaTime)
70  {
71  }
72 
73  public virtual void Finish()
74  {
75  isFinished = true;
76  Finished?.Invoke();
77  }
78 
79  public virtual bool LevelMeetsRequirements()
80  {
81  return true;
82  }
83  }
84 }
override string ToString()
Definition: Event.cs:29
bool Initialized
Definition: Event.cs:20
virtual string GetDebugInfo()
Definition: Event.cs:64
Action Finished
Definition: Event.cs:9
virtual void Update(float deltaTime)
Definition: Event.cs:69
bool IsFinished
Definition: Event.cs:25
virtual bool LevelMeetsRequirements()
Definition: Event.cs:79
Func< Level.InterestingPosition, bool > SpawnPosFilter
Definition: Event.cs:22
Event(EventPrefab prefab, int seed)
Definition: Event.cs:42
EventSet ParentSet
Definition: Event.cs:18
virtual Vector2 DebugDrawPos
Definition: Event.cs:35
virtual void Finish()
Definition: Event.cs:73
virtual IEnumerable< ContentFile > GetFilesToPreload()
Definition: Event.cs:48
readonly EventPrefab prefab
Definition: Event.cs:14
virtual void InitEventSpecific(EventSet parentSet=null)
Definition: Event.cs:60
void Init(EventSet parentSet=null)
Definition: Event.cs:53
bool isFinished
Definition: Event.cs:10
readonly int RandomSeed
Definition: Event.cs:12
readonly Type EventType
Definition: EventPrefab.cs:12
Event sets are sets of random events that occur within a level (most commonly, monster spawns and scr...
Definition: EventSet.cs:31