Client LuaCsForBarotrauma
EventManagerSettings.cs
1 using System.Collections.Generic;
2 using System.Xml.Linq;
3 using System.Linq;
4 using System;
5 using Microsoft.Xna.Framework;
6 
7 namespace Barotrauma
8 {
10  {
12  public static IOrderedEnumerable<EventManagerSettings> OrderedByDifficulty
13  {
14  get
15  {
16  return Prefabs.OrderBy(p => (p.MinLevelDifficulty + p.MaxLevelDifficulty) * 0.5f)
17  .ThenBy(p => p.UintIdentifier);
18  }
19  }
20 
22  {
23  EventManagerSettings[] settings = OrderedByDifficulty.ToArray();
24  return settings[Math.Clamp((int)(settings.Length * p), 0, settings.Length - 1)];
25  }
26 
27  public readonly LocalizedString Name;
28 
29  //How much the event threshold increases per second. 0.0005f = 0.03f per minute
30  public readonly float EventThresholdIncrease = 0.0005f;
31 
32  //The threshold is reset to this value after an event has been triggered.
33  public readonly float DefaultEventThreshold = 0.2f;
34 
35  public readonly float EventCooldown = 360.0f;
36 
37  public readonly float MinLevelDifficulty = 0.0f;
38  public readonly float MaxLevelDifficulty = 100.0f;
39 
40  public readonly float FreezeDurationWhenCrewAway = 60.0f * 10.0f;
41 
42  public override void Dispose() { }
43 
44  public EventManagerSettings(XElement element, EventManagerSettingsFile file) : base(file, element.NameAsIdentifier())
45  {
46  Name = TextManager.Get("difficulty." + Identifier).Fallback(Identifier.Value);
47  EventThresholdIncrease = element.GetAttributeFloat("EventThresholdIncrease", EventThresholdIncrease);
48  DefaultEventThreshold = element.GetAttributeFloat("DefaultEventThreshold", DefaultEventThreshold);
49  EventCooldown = element.GetAttributeFloat("EventCooldown", EventCooldown);
50 
51  MinLevelDifficulty = element.GetAttributeFloat("MinLevelDifficulty", MinLevelDifficulty);
52  MaxLevelDifficulty = element.GetAttributeFloat("MaxLevelDifficulty", MaxLevelDifficulty);
53 
54  FreezeDurationWhenCrewAway = element.GetAttributeFloat("FreezeDurationWhenCrewAway", FreezeDurationWhenCrewAway);
55  }
56  }
57 }
EventManagerSettings(XElement element, EventManagerSettingsFile file)
static EventManagerSettings GetByDifficultyPercentile(float p)
static readonly PrefabCollection< EventManagerSettings > Prefabs
static IOrderedEnumerable< EventManagerSettings > OrderedByDifficulty
LocalizedString Fallback(LocalizedString fallback, bool useDefaultLanguageIfFound=true)
Use this text instead if the original text cannot be found.
readonly Identifier Identifier
Definition: Prefab.cs:34
Prefab that has a property serves as a deterministic hash of a prefab's identifier....