2 using System.Collections.Generic;
12 public static readonly
string ConfigFile =
"Data" + Path.DirectorySeparatorChar +
"karmasettings.xml";
14 public string Name =>
"KarmaManager";
76 private int allowedWireDisconnectionsPerMinute;
80 get {
return allowedWireDisconnectionsPerMinute; }
81 set { allowedWireDisconnectionsPerMinute = Math.Max(0, value); }
119 public Dictionary<string, XElement>
Presets =
new Dictionary<string, XElement>();
123 XDocument doc =
null;
124 int maxLoadRetries = 4;
125 for (
int i = 0; i <= maxLoadRetries; i++)
132 catch (System.IO.IOException)
134 if (i == maxLoadRetries) {
break; }
135 DebugConsole.NewMessage(
"Opening karma settings file \"" +
ConfigFile +
"\" failed, retrying in 250 ms...");
136 System.Threading.Thread.Sleep(250);
141 if (doc?.Root !=
null)
144 foreach (var subElement
in doc.Root.Elements())
146 string presetName = subElement.GetAttributeString(
"name",
"");
147 Presets[presetName.ToLowerInvariant()] = subElement;
156 if (
string.IsNullOrEmpty(presetName)) {
return; }
157 presetName = presetName.ToLowerInvariant();
159 if (
Presets.ContainsKey(presetName))
163 else if (
Presets.ContainsKey(
"custom"))
172 if (
Presets.ContainsKey(
"custom"))
180 XDocument doc =
new XDocument(
new XElement(
Name));
182 foreach (KeyValuePair<string, XElement> preset
in Presets)
184 doc.Root.Add(preset.Value);
187 System.Xml.XmlWriterSettings settings =
new System.Xml.XmlWriterSettings
190 NewLineOnAttributes =
true
193 int maxLoadRetries = 4;
194 for (
int i = 0; i <= maxLoadRetries; i++)
200 doc.SaveSafe(writer);
204 catch (System.IO.IOException)
206 if (i == maxLoadRetries) {
throw; }
208 DebugConsole.NewMessage(
"Saving karma settings file file \"" +
ConfigFile +
"\" failed, retrying in 250 ms...");
209 System.Threading.Thread.Sleep(250);
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
static IEnumerable< AfflictionPrefab > List
static NetworkMember NetworkMember
static XmlWriter Create(string path, System.Xml.XmlWriterSettings settings)
float BallastFloraKarmaIncrease
Dictionary< string, XElement > Presets
float SteerSubKarmaIncrease
float StructureRepairKarmaIncrease
float KarmaDecayThreshold
float WireDisconnectionKarmaDecrease
bool ResetKarmaBetweenRounds
float KarmaIncreaseThreshold
float DamageEnemyKarmaIncrease
float HealFriendlyKarmaIncrease
float DangerousItemStealKarmaDecrease
float KarmaNotificationInterval
static readonly string ConfigFile
float MaxDangerousItemContainKarmaDecrease
float ReactorOverheatKarmaDecrease
bool IsDangerousItemContainKarmaDecreaseIncremental
float StunFriendlyKarmaDecrease
float ExtinguishFireKarmaIncrease
float StunFriendlyKarmaDecreaseThreshold
Dictionary< Identifier, SerializableProperty > SerializableProperties
float MaxStructureDamageKarmaDecreasePerSecond
bool DangerousItemStealBots
float StructureDamageKarmaDecrease
void SelectPreset(string presetName)
float DangerousItemContainKarmaDecrease
float ReactorMeltdownKarmaDecrease
float ItemRepairKarmaIncrease
float AllowedRetaliationTime
float DamageFriendlyKarmaDecrease
float SpamFilterKarmaDecrease
int AllowedWireDisconnectionsPerMinute
static Dictionary< Identifier, SerializableProperty > DeserializeProperties(object obj, XElement element=null)
static void SerializeProperties(ISerializableEntity obj, XElement element, bool saveIfDefault=false, bool ignoreEditable=false)