Merge branch 'dev' of https://github.com/Regalis11/Barotrauma.git into unstable-tests
This commit is contained in:
+10
-9
@@ -12,7 +12,7 @@ namespace Barotrauma
|
||||
|
||||
public string Name => ToString();
|
||||
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties { get; set; }
|
||||
public Dictionary<Identifier, SerializableProperty> SerializableProperties { get; set; }
|
||||
|
||||
public float PendingAdditionStrength { get; set; }
|
||||
public float AdditionStrength { get; set; }
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
|
||||
protected float _strength;
|
||||
|
||||
[Serialize(0f, true), Editable]
|
||||
[Serialize(0f, IsPropertySaveable.Yes), Editable]
|
||||
public virtual float Strength
|
||||
{
|
||||
get { return _strength; }
|
||||
@@ -43,10 +43,10 @@ namespace Barotrauma
|
||||
private float _nonClampedStrength = -1;
|
||||
public float NonClampedStrength => _nonClampedStrength > 0 ? _nonClampedStrength : _strength;
|
||||
|
||||
[Serialize("", true), Editable]
|
||||
public string Identifier { get; private set; }
|
||||
[Serialize("", IsPropertySaveable.Yes), Editable]
|
||||
public Identifier Identifier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true, description: "The probability for the affliction to be applied."), Editable(minValue: 0f, maxValue: 1f)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes, description: "The probability for the affliction to be applied."), Editable(minValue: 0f, maxValue: 1f)]
|
||||
public float Probability { get; set; } = 1.0f;
|
||||
|
||||
public float DamagePerSecond;
|
||||
@@ -73,7 +73,7 @@ namespace Barotrauma
|
||||
Prefab = prefab;
|
||||
PendingAdditionStrength = Prefab.GrainBurst;
|
||||
_strength = strength;
|
||||
Identifier = prefab?.Identifier;
|
||||
Identifier = prefab.Identifier;
|
||||
|
||||
foreach (var periodicEffect in prefab.PeriodicEffects)
|
||||
{
|
||||
@@ -269,14 +269,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public float GetResistance(AfflictionPrefab affliction)
|
||||
public float GetResistance(Identifier afflictionId)
|
||||
{
|
||||
if (Strength < Prefab.ActivationThreshold) { return 0.0f; }
|
||||
var affliction = AfflictionPrefab.Prefabs[afflictionId];
|
||||
AfflictionPrefab.Effect currentEffect = GetActiveEffect();
|
||||
if (currentEffect == null) { return 0.0f; }
|
||||
if (!currentEffect.ResistanceFor.Any(r =>
|
||||
r.Equals(affliction.Identifier, StringComparison.OrdinalIgnoreCase) ||
|
||||
r.Equals(affliction.AfflictionType, StringComparison.OrdinalIgnoreCase)))
|
||||
r == affliction.Identifier ||
|
||||
r == affliction.AfflictionType))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
+83
-23
@@ -26,7 +26,7 @@ namespace Barotrauma
|
||||
|
||||
private readonly List<Affliction> huskInfection = new List<Affliction>();
|
||||
|
||||
[Serialize(0f, true), Editable]
|
||||
[Serialize(0f, IsPropertySaveable.Yes), Editable]
|
||||
public override float Strength
|
||||
{
|
||||
get { return _strength; }
|
||||
@@ -41,9 +41,11 @@ namespace Barotrauma
|
||||
if (previousValue > 0.0f && value <= 0.0f)
|
||||
{
|
||||
DeactivateHusk();
|
||||
highestStrength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
private float highestStrength;
|
||||
|
||||
public InfectionState State
|
||||
{
|
||||
@@ -75,6 +77,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (HuskPrefab == null) { return; }
|
||||
base.Update(characterHealth, targetLimb, deltaTime);
|
||||
highestStrength = Math.Max(_strength, highestStrength);
|
||||
character = characterHealth.Character;
|
||||
if (character == null) { return; }
|
||||
|
||||
@@ -98,7 +101,7 @@ namespace Barotrauma
|
||||
DeactivateHusk();
|
||||
if (Prefab is AfflictionPrefabHusk { CauseSpeechImpediment: true })
|
||||
{
|
||||
character.SpeechImpediment = 100;
|
||||
character.SpeechImpediment = 30;
|
||||
}
|
||||
State = InfectionState.Transition;
|
||||
}
|
||||
@@ -108,6 +111,10 @@ namespace Barotrauma
|
||||
{
|
||||
character.SetStun(Rand.Range(2f, 3f));
|
||||
}
|
||||
if (Prefab is AfflictionPrefabHusk { CauseSpeechImpediment: true })
|
||||
{
|
||||
character.SpeechImpediment = 100;
|
||||
}
|
||||
State = InfectionState.Active;
|
||||
ActivateHusk();
|
||||
}
|
||||
@@ -120,7 +127,57 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
partial void UpdateMessages();
|
||||
private InfectionState? prevDisplayedMessage;
|
||||
private void UpdateMessages()
|
||||
{
|
||||
if (Prefab is AfflictionPrefabHusk { SendMessages: false }) { return; }
|
||||
if (prevDisplayedMessage.HasValue && prevDisplayedMessage.Value == State) { return; }
|
||||
if (highestStrength > Strength) { return; }
|
||||
|
||||
switch (State)
|
||||
{
|
||||
case InfectionState.Dormant:
|
||||
if (Strength < DormantThreshold * 0.5f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (character == Character.Controlled)
|
||||
{
|
||||
#if CLIENT
|
||||
GUI.AddMessage(TextManager.Get("HuskDormant"), GUIStyle.Red);
|
||||
#endif
|
||||
}
|
||||
else if (character.IsBot)
|
||||
{
|
||||
character.Speak(TextManager.Get("dialoghuskdormant").Value, delay: Rand.Range(0.5f, 5.0f), identifier: "huskdormant".ToIdentifier());
|
||||
}
|
||||
break;
|
||||
case InfectionState.Transition:
|
||||
if (character == Character.Controlled)
|
||||
{
|
||||
#if CLIENT
|
||||
GUI.AddMessage(TextManager.Get("HuskCantSpeak"), GUIStyle.Red);
|
||||
#endif
|
||||
}
|
||||
else if (character.IsBot)
|
||||
{
|
||||
character.Speak(TextManager.Get("dialoghuskcantspeak").Value, delay: Rand.Range(0.5f, 5.0f), identifier: "huskcantspeak".ToIdentifier());
|
||||
}
|
||||
break;
|
||||
case InfectionState.Active:
|
||||
#if CLIENT
|
||||
if (character == Character.Controlled && character.Params.UseHuskAppendage)
|
||||
{
|
||||
GUI.AddMessage(TextManager.GetWithVariable("HuskActivate", "[Attack]", GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.Attack)), GUIStyle.Red);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case InfectionState.Final:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prevDisplayedMessage = State;
|
||||
}
|
||||
|
||||
private void ApplyDamage(float deltaTime, bool applyForce)
|
||||
{
|
||||
@@ -209,12 +266,14 @@ namespace Barotrauma
|
||||
{
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
#if SERVER
|
||||
var client = GameMain.Server?.ConnectedClients.FirstOrDefault(c => c.Character == character);
|
||||
#endif
|
||||
character.Enabled = false;
|
||||
Entity.Spawner.AddToRemoveQueue(character);
|
||||
Entity.Spawner.AddEntityToRemoveQueue(character);
|
||||
UnsubscribeFromDeathEvent();
|
||||
|
||||
string huskedSpeciesName = GetHuskedSpeciesName(character.SpeciesName, Prefab as AfflictionPrefabHusk);
|
||||
Identifier huskedSpeciesName = GetHuskedSpeciesName(character.SpeciesName, Prefab as AfflictionPrefabHusk);
|
||||
CharacterPrefab prefab = CharacterPrefab.FindBySpeciesName(huskedSpeciesName);
|
||||
|
||||
if (prefab == null)
|
||||
@@ -230,8 +289,8 @@ namespace Barotrauma
|
||||
if (huskCharacterInfo != null)
|
||||
{
|
||||
var bodyTint = GetBodyTint();
|
||||
huskCharacterInfo.SkinColor =
|
||||
Color.Lerp(huskCharacterInfo.SkinColor, bodyTint.Opaque(), bodyTint.A / 255.0f);
|
||||
huskCharacterInfo.Head.SkinColor =
|
||||
Color.Lerp(huskCharacterInfo.Head.SkinColor, bodyTint.Opaque(), bodyTint.A / 255.0f);
|
||||
}
|
||||
|
||||
var husk = Character.Create(huskedSpeciesName, character.WorldPosition, ToolBox.RandomSeed(8), huskCharacterInfo, isRemotePlayer: false, hasAi: true);
|
||||
@@ -246,7 +305,6 @@ namespace Barotrauma
|
||||
if (huskPrefab.ControlHusk || GameMain.Lua.game.enableControlHusk)
|
||||
{
|
||||
#if SERVER
|
||||
var client = GameMain.Server?.ConnectedClients.FirstOrDefault(c => c.Character == character);
|
||||
if (client != null)
|
||||
{
|
||||
GameMain.Server.SetClientCharacter(client, husk);
|
||||
@@ -307,7 +365,7 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public static List<Limb> AttachHuskAppendage(Character character, string afflictionIdentifier, XElement appendageDefinition = null, Ragdoll ragdoll = null)
|
||||
public static List<Limb> AttachHuskAppendage(Character character, Identifier afflictionIdentifier, ContentXElement appendageDefinition = null, Ragdoll ragdoll = null)
|
||||
{
|
||||
var appendage = new List<Limb>();
|
||||
if (!(AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier == afflictionIdentifier) is AfflictionPrefabHusk matchingAffliction))
|
||||
@@ -315,26 +373,26 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError($"Could not find an affliction of type 'huskinfection' that matches the affliction '{afflictionIdentifier}'!");
|
||||
return appendage;
|
||||
}
|
||||
string nonhuskedSpeciesName = GetNonHuskedSpeciesName(character.SpeciesName, matchingAffliction);
|
||||
string huskedSpeciesName = GetHuskedSpeciesName(nonhuskedSpeciesName, matchingAffliction);
|
||||
Identifier nonhuskedSpeciesName = GetNonHuskedSpeciesName(character.SpeciesName, matchingAffliction);
|
||||
Identifier huskedSpeciesName = GetHuskedSpeciesName(nonhuskedSpeciesName, matchingAffliction);
|
||||
CharacterPrefab huskPrefab = CharacterPrefab.FindBySpeciesName(huskedSpeciesName);
|
||||
if (huskPrefab?.XDocument == null)
|
||||
if (huskPrefab?.ConfigElement == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to find the config file for the husk infected species with the species name '{huskedSpeciesName}'!");
|
||||
return appendage;
|
||||
}
|
||||
var mainElement = huskPrefab.XDocument.Root.IsOverride() ? huskPrefab.XDocument.Root.FirstElement() : huskPrefab.XDocument.Root;
|
||||
var mainElement = huskPrefab.ConfigElement;
|
||||
var element = appendageDefinition;
|
||||
if (element == null)
|
||||
{
|
||||
element = mainElement.GetChildElements("huskappendage").FirstOrDefault(e => e.GetAttributeString("affliction", string.Empty).Equals(afflictionIdentifier));
|
||||
element = mainElement.GetChildElements("huskappendage").FirstOrDefault(e => e.GetAttributeIdentifier("affliction", Identifier.Empty) == afflictionIdentifier);
|
||||
}
|
||||
if (element == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in '{huskPrefab.FilePath}': Failed to find a huskappendage that matches the affliction with an identifier '{afflictionIdentifier}'!");
|
||||
return appendage;
|
||||
}
|
||||
string pathToAppendage = element.GetAttributeString("path", string.Empty);
|
||||
ContentPath pathToAppendage = element.GetAttributeContentPath("path") ?? ContentPath.Empty;
|
||||
XDocument doc = XMLExtensions.TryLoadXml(pathToAppendage);
|
||||
if (doc == null) { return appendage; }
|
||||
if (ragdoll == null)
|
||||
@@ -345,10 +403,12 @@ namespace Barotrauma
|
||||
{
|
||||
ragdoll.Flip();
|
||||
}
|
||||
var limbElements = doc.Root.Elements("limb").ToDictionary(e => e.GetAttributeString("id", null), e => e);
|
||||
foreach (var jointElement in doc.Root.Elements("joint"))
|
||||
|
||||
var root = doc.Root.FromPackage(pathToAppendage.ContentPackage);
|
||||
var limbElements = root.GetChildElements("limb").ToDictionary(e => e.GetAttributeString("id", null), e => e);
|
||||
foreach (var jointElement in root.GetChildElements("joint"))
|
||||
{
|
||||
if (limbElements.TryGetValue(jointElement.GetAttributeString("limb2", null), out XElement limbElement))
|
||||
if (limbElements.TryGetValue(jointElement.GetAttributeString("limb2", null), out ContentXElement limbElement))
|
||||
{
|
||||
var jointParams = new RagdollParams.JointParams(jointElement, ragdoll.RagdollParams);
|
||||
Limb attachLimb = null;
|
||||
@@ -389,15 +449,15 @@ namespace Barotrauma
|
||||
return appendage;
|
||||
}
|
||||
|
||||
public static string GetHuskedSpeciesName(string speciesName, AfflictionPrefabHusk prefab)
|
||||
public static Identifier GetHuskedSpeciesName(Identifier speciesName, AfflictionPrefabHusk prefab)
|
||||
{
|
||||
return prefab.HuskedSpeciesName.Replace(AfflictionPrefabHusk.Tag, speciesName);
|
||||
}
|
||||
|
||||
public static string GetNonHuskedSpeciesName(string huskedSpeciesName, AfflictionPrefabHusk prefab)
|
||||
public static Identifier GetNonHuskedSpeciesName(Identifier huskedSpeciesName, AfflictionPrefabHusk prefab)
|
||||
{
|
||||
string nonTag = prefab.HuskedSpeciesName.Remove(AfflictionPrefabHusk.Tag);
|
||||
return huskedSpeciesName.ToLowerInvariant().Remove(nonTag);
|
||||
Identifier nonTag = prefab.HuskedSpeciesName.Remove(AfflictionPrefabHusk.Tag);
|
||||
return huskedSpeciesName.Remove(nonTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+139
-396
@@ -2,28 +2,29 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
static class CPRSettings
|
||||
class CPRSettings : Prefab
|
||||
{
|
||||
public static string FilePath { get; private set; }
|
||||
public static bool IsLoaded { get; private set; }
|
||||
public static float ReviveChancePerSkill { get; private set; }
|
||||
public static float ReviveChanceExponent { get; private set; }
|
||||
public static float ReviveChanceMin { get; private set; }
|
||||
public static float ReviveChanceMax { get; private set; }
|
||||
public static float StabilizationPerSkill { get; private set; }
|
||||
public static float StabilizationMin { get; private set; }
|
||||
public static float StabilizationMax { get; private set; }
|
||||
public static float DamageSkillThreshold { get; private set; }
|
||||
public static float DamageSkillMultiplier { get; private set; }
|
||||
public readonly static PrefabSelector<CPRSettings> Prefabs = new PrefabSelector<CPRSettings>();
|
||||
public static CPRSettings Active => Prefabs.ActivePrefab;
|
||||
|
||||
private static string insufficientSkillAfflictionIdentifier { get; set; }
|
||||
public static AfflictionPrefab InsufficientSkillAffliction
|
||||
public readonly float ReviveChancePerSkill;
|
||||
public readonly float ReviveChanceExponent;
|
||||
public readonly float ReviveChanceMin;
|
||||
public readonly float ReviveChanceMax;
|
||||
public readonly float StabilizationPerSkill;
|
||||
public readonly float StabilizationMin;
|
||||
public readonly float StabilizationMax;
|
||||
public readonly float DamageSkillThreshold;
|
||||
public readonly float DamageSkillMultiplier;
|
||||
|
||||
private readonly string insufficientSkillAfflictionIdentifier;
|
||||
public AfflictionPrefab InsufficientSkillAffliction
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void Load(XElement element, string filePath)
|
||||
public CPRSettings(XElement element, AfflictionsFile file) : base(file, file.Path.Value.ToIdentifier())
|
||||
{
|
||||
ReviveChancePerSkill = Math.Max(element.GetAttributeFloat("revivechanceperskill", 0.01f), 0.0f);
|
||||
ReviveChanceExponent = Math.Max(element.GetAttributeFloat("revivechanceexponent", 2.0f), 0.0f);
|
||||
@@ -49,33 +50,26 @@ namespace Barotrauma
|
||||
DamageSkillMultiplier = MathHelper.Clamp(element.GetAttributeFloat("damageskillmultiplier", 0.1f), 0.0f, 100.0f);
|
||||
|
||||
insufficientSkillAfflictionIdentifier = element.GetAttributeString("insufficientskillaffliction", "");
|
||||
|
||||
IsLoaded = true;
|
||||
FilePath = filePath;
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
IsLoaded = false;
|
||||
FilePath = null;
|
||||
}
|
||||
public override void Dispose() { }
|
||||
}
|
||||
|
||||
class AfflictionPrefabHusk : AfflictionPrefab
|
||||
{
|
||||
public AfflictionPrefabHusk(XElement element, string filePath, Type type = null) : base(element, filePath, type)
|
||||
public AfflictionPrefabHusk(ContentXElement element, AfflictionsFile file, Type type = null) : base(element, file, type)
|
||||
{
|
||||
HuskedSpeciesName = element.GetAttributeString("huskedspeciesname", null).ToLowerInvariant();
|
||||
if (HuskedSpeciesName == null)
|
||||
HuskedSpeciesName = element.GetAttributeIdentifier("huskedspeciesname", Identifier.Empty);
|
||||
if (HuskedSpeciesName.IsEmpty)
|
||||
{
|
||||
DebugConsole.NewMessage($"No 'huskedspeciesname' defined for the husk affliction ({Identifier}) in {element}", Color.Orange);
|
||||
HuskedSpeciesName = "[speciesname]husk";
|
||||
HuskedSpeciesName = "[speciesname]husk".ToIdentifier();
|
||||
}
|
||||
TargetSpecies = element.GetAttributeStringArray("targets", new string[0] { }, trim: true, convertToLowerInvariant: true);
|
||||
TargetSpecies = element.GetAttributeIdentifierArray("targets", Array.Empty<Identifier>(), trim: true);
|
||||
if (TargetSpecies.Length == 0)
|
||||
{
|
||||
DebugConsole.NewMessage($"No 'targets' defined for the husk affliction ({Identifier}) in {element}", Color.Orange);
|
||||
TargetSpecies = new string[] { "human" };
|
||||
TargetSpecies = new Identifier[] { CharacterPrefab.HumanSpeciesName };
|
||||
}
|
||||
var attachElement = element.GetChildElement("attachlimb");
|
||||
if (attachElement != null)
|
||||
@@ -112,9 +106,9 @@ namespace Barotrauma
|
||||
public float ActiveThreshold, DormantThreshold, TransitionThreshold;
|
||||
public float TransformThresholdOnDeath;
|
||||
|
||||
public readonly string HuskedSpeciesName;
|
||||
public readonly string[] TargetSpecies;
|
||||
public const string Tag = "[speciesname]";
|
||||
public readonly Identifier HuskedSpeciesName;
|
||||
public readonly Identifier[] TargetSpecies;
|
||||
public static readonly Identifier Tag = "[speciesname]".ToIdentifier();
|
||||
|
||||
public readonly bool TransferBuffs;
|
||||
public readonly bool SendMessages;
|
||||
@@ -123,124 +117,122 @@ namespace Barotrauma
|
||||
public readonly bool ControlHusk;
|
||||
}
|
||||
|
||||
partial class AfflictionPrefab : IPrefab, IDisposable, IHasUintIdentifier
|
||||
class AfflictionPrefab : PrefabWithUintIdentifier
|
||||
{
|
||||
public class Effect
|
||||
{
|
||||
//this effect is applied when the strength is within this range
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinStrength { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxStrength { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinVitalityDecrease { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxVitalityDecrease { get; private set; }
|
||||
|
||||
//how much the strength of the affliction changes per second
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float StrengthChange { get; private set; }
|
||||
|
||||
[Serialize(false, false)]
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool MultiplyByMaxVitality { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinScreenBlur { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxScreenBlur { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinScreenDistort { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxScreenDistort { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinRadialDistort { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxRadialDistort { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinChromaticAberration { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxChromaticAberration { get; private set; }
|
||||
|
||||
[Serialize("255,255,255,255", false)]
|
||||
[Serialize("255,255,255,255", IsPropertySaveable.No)]
|
||||
public Color GrainColor { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinGrainStrength { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxGrainStrength { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float ScreenEffectFluctuationFrequency { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MinAfflictionOverlayAlphaMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MaxAfflictionOverlayAlphaMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MinBuffMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MaxBuffMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MinSpeedMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MaxSpeedMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MinSkillMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1.0f, false)]
|
||||
[Serialize(1.0f, IsPropertySaveable.No)]
|
||||
public float MaxSkillMultiplier { get; private set; }
|
||||
|
||||
private readonly Identifier[] resistanceFor;
|
||||
public IReadOnlyList<Identifier> ResistanceFor => resistanceFor;
|
||||
|
||||
private readonly string[] resistanceFor;
|
||||
public IEnumerable<string> ResistanceFor
|
||||
{
|
||||
get { return resistanceFor; }
|
||||
}
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MinResistance { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float MaxResistance { get; private set; }
|
||||
|
||||
[Serialize("", false)]
|
||||
public string DialogFlag { get; private set; }
|
||||
[Serialize("", IsPropertySaveable.No)]
|
||||
public Identifier DialogFlag { get; private set; }
|
||||
|
||||
[Serialize("", false)]
|
||||
public string Tag { get; private set; }
|
||||
|
||||
[Serialize("0,0,0,0", false)]
|
||||
[Serialize("", IsPropertySaveable.No)]
|
||||
public Identifier Tag { get; private set; }
|
||||
|
||||
[Serialize("0,0,0,0", IsPropertySaveable.No)]
|
||||
public Color MinFaceTint { get; private set; }
|
||||
|
||||
[Serialize("0,0,0,0", false)]
|
||||
[Serialize("0,0,0,0", IsPropertySaveable.No)]
|
||||
public Color MaxFaceTint { get; private set; }
|
||||
|
||||
[Serialize("0,0,0,0", false)]
|
||||
[Serialize("0,0,0,0", IsPropertySaveable.No)]
|
||||
public Color MinBodyTint { get; private set; }
|
||||
|
||||
[Serialize("0,0,0,0", false)]
|
||||
[Serialize("0,0,0,0", IsPropertySaveable.No)]
|
||||
public Color MaxBodyTint { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prevents AfflictionHusks with the specified identifier(s) from transforming the character into an AI-controlled character
|
||||
/// </summary>
|
||||
public string[] BlockTransformation { get; private set; }
|
||||
public Identifier[] BlockTransformation { get; private set; }
|
||||
|
||||
public readonly Dictionary<StatTypes, (float minValue, float maxValue)> AfflictionStatValues = new Dictionary<StatTypes, (float minValue, float maxValue)>();
|
||||
public readonly HashSet<AbilityFlags> AfflictionAbilityFlags = new HashSet<AbilityFlags>();
|
||||
@@ -248,14 +240,14 @@ namespace Barotrauma
|
||||
//statuseffects applied on the character when the affliction is active
|
||||
public readonly List<StatusEffect> StatusEffects = new List<StatusEffect>();
|
||||
|
||||
public Effect(XElement element, string parentDebugName)
|
||||
public Effect(ContentXElement element, string parentDebugName)
|
||||
{
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
resistanceFor = element.GetAttributeStringArray("resistancefor", new string[0], convertToLowerInvariant: true);
|
||||
BlockTransformation = element.GetAttributeStringArray("blocktransformation", new string[0], convertToLowerInvariant: true);
|
||||
resistanceFor = element.GetAttributeIdentifierArray("resistancefor", Array.Empty<Identifier>());
|
||||
BlockTransformation = element.GetAttributeIdentifierArray("blocktransformation", Array.Empty<Identifier>());
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -288,14 +280,14 @@ namespace Barotrauma
|
||||
public readonly List<StatusEffect> StatusEffects = new List<StatusEffect>();
|
||||
public readonly float MinInterval, MaxInterval;
|
||||
|
||||
public PeriodicEffect(XElement element, string parentDebugName)
|
||||
public PeriodicEffect(ContentXElement element, string parentDebugName)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
StatusEffects.Add(StatusEffect.Load(subElement, parentDebugName));
|
||||
}
|
||||
|
||||
if (element.Attribute("interval") != null)
|
||||
if (element.GetAttribute("interval") != null)
|
||||
{
|
||||
MinInterval = MaxInterval = Math.Max(element.GetAttributeFloat("interval", 1.0f), 1.0f);
|
||||
}
|
||||
@@ -307,48 +299,28 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static AfflictionPrefab InternalDamage;
|
||||
public static AfflictionPrefab ImpactDamage;
|
||||
public static AfflictionPrefab Bleeding;
|
||||
public static AfflictionPrefab Burn;
|
||||
public static AfflictionPrefab OxygenLow;
|
||||
public static AfflictionPrefab Bloodloss;
|
||||
public static AfflictionPrefab Pressure;
|
||||
public static AfflictionPrefab Stun;
|
||||
public static AfflictionPrefab RadiationSickness;
|
||||
public static AfflictionPrefab InternalDamage => Prefabs["internaldamage"];
|
||||
public static AfflictionPrefab ImpactDamage => Prefabs["blunttrauma"];
|
||||
public static AfflictionPrefab Bleeding => Prefabs["bleeding"];
|
||||
public static AfflictionPrefab Burn => Prefabs["burn"];
|
||||
public static AfflictionPrefab OxygenLow => Prefabs["oxygenlow"];
|
||||
public static AfflictionPrefab Bloodloss => Prefabs["bloodloss"];
|
||||
public static AfflictionPrefab Pressure => Prefabs["pressure"];
|
||||
public static AfflictionPrefab Stun => Prefabs["stun"];
|
||||
public static AfflictionPrefab RadiationSickness => Prefabs["radiationsickness"];
|
||||
|
||||
public static readonly PrefabCollection<AfflictionPrefab> Prefabs = new PrefabCollection<AfflictionPrefab>();
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) { return; }
|
||||
disposed = true;
|
||||
Prefabs.Remove(this);
|
||||
}
|
||||
public override void Dispose() { }
|
||||
|
||||
public static IEnumerable<AfflictionPrefab> List
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var prefab in Prefabs)
|
||||
{
|
||||
yield return prefab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FilePath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique identifier that's generated by hashing the prefab's string identifier.
|
||||
/// Used to reduce the amount of bytes needed to write affliction data into network messages in multiplayer.
|
||||
/// </summary>
|
||||
public uint UIntIdentifier { get; set; }
|
||||
public static IEnumerable<AfflictionPrefab> List => Prefabs;
|
||||
|
||||
// Arbitrary string that is used to identify the type of the affliction.
|
||||
public readonly string AfflictionType;
|
||||
public readonly Identifier AfflictionType;
|
||||
|
||||
private readonly ContentXElement configElement;
|
||||
|
||||
//Does the affliction affect a specific limb or the whole character
|
||||
public readonly bool LimbSpecific;
|
||||
|
||||
@@ -356,18 +328,14 @@ namespace Barotrauma
|
||||
//(e.g. mental health problems on head, lack of oxygen on torso...)
|
||||
public readonly LimbType IndicatorLimb;
|
||||
|
||||
public string Identifier { get; private set; }
|
||||
public string OriginalName { get { return Identifier; } }
|
||||
public ContentPackage ContentPackage { get; private set; }
|
||||
|
||||
public readonly string Name, Description;
|
||||
public readonly string TranslationOverride;
|
||||
public readonly LocalizedString Name, Description;
|
||||
public readonly Identifier TranslationIdentifier;
|
||||
public readonly bool IsBuff;
|
||||
public readonly bool HealableInMedicalClinic;
|
||||
public readonly float HealCostMultiplier;
|
||||
public readonly int BaseHealCost;
|
||||
|
||||
public readonly string CauseOfDeathDescription, SelfCauseOfDeathDescription;
|
||||
public readonly LocalizedString CauseOfDeathDescription, SelfCauseOfDeathDescription;
|
||||
|
||||
//how high the strength has to be for the affliction to take affect
|
||||
public readonly float ActivationThreshold = 0.0f;
|
||||
@@ -392,7 +360,7 @@ namespace Barotrauma
|
||||
public float DamageOverlayAlpha;
|
||||
|
||||
//steam achievement given when the affliction is removed from the controlled character
|
||||
public readonly string AchievementOnRemoved;
|
||||
public readonly Identifier AchievementOnRemoved;
|
||||
|
||||
public readonly Sprite Icon;
|
||||
public readonly Color[] IconColors;
|
||||
@@ -407,11 +375,9 @@ namespace Barotrauma
|
||||
|
||||
public IList<PeriodicEffect> PeriodicEffects => periodicEffects;
|
||||
|
||||
private readonly string typeName;
|
||||
|
||||
private readonly ConstructorInfo constructor;
|
||||
|
||||
public IEnumerable<KeyValuePair<string, float>> TreatmentSuitability
|
||||
public IEnumerable<KeyValuePair<Identifier, float>> TreatmentSuitability
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -420,255 +386,32 @@ namespace Barotrauma
|
||||
float suitability = Math.Max(itemPrefab.GetTreatmentSuitability(Identifier), itemPrefab.GetTreatmentSuitability(AfflictionType));
|
||||
if (suitability > 0.0f)
|
||||
{
|
||||
yield return new KeyValuePair<string, float>(itemPrefab.Identifier, suitability);
|
||||
yield return new KeyValuePair<Identifier, float>(itemPrefab.Identifier, suitability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadAll(IEnumerable<ContentFile> files)
|
||||
public AfflictionPrefab(ContentXElement element, AfflictionsFile file, Type type) : base(file, element.GetAttributeIdentifier("identifier", ""))
|
||||
{
|
||||
CPRSettings.Unload();
|
||||
InternalDamage = null;
|
||||
ImpactDamage = null;
|
||||
Bleeding = null;
|
||||
Burn = null;
|
||||
OxygenLow = null;
|
||||
Bloodloss = null;
|
||||
Pressure = null;
|
||||
Stun = null;
|
||||
RadiationSickness = null;
|
||||
#if CLIENT
|
||||
CharacterHealth.DamageOverlay?.Remove();
|
||||
CharacterHealth.DamageOverlay = null;
|
||||
CharacterHealth.DamageOverlayFile = string.Empty;
|
||||
#endif
|
||||
var prevPrefabs = Prefabs.AllPrefabs.SelectMany(kvp => kvp.Value).ToList();
|
||||
foreach (var prefab in prevPrefabs)
|
||||
{
|
||||
prefab?.Dispose();
|
||||
}
|
||||
System.Diagnostics.Debug.Assert(Prefabs.Count() == 0, "All previous AfflictionPrefabs were not removed in AfflictionPrefab.LoadAll");
|
||||
|
||||
foreach (ContentFile file in files)
|
||||
{
|
||||
LoadFromFile(file);
|
||||
}
|
||||
|
||||
if (InternalDamage == null) { DebugConsole.ThrowError("Affliction \"Internal Damage\" not defined in the affliction prefabs."); }
|
||||
if (Bleeding == null) { DebugConsole.ThrowError("Affliction \"Bleeding\" not defined in the affliction prefabs."); }
|
||||
if (Burn == null) { DebugConsole.ThrowError("Affliction \"Burn\" not defined in the affliction prefabs."); }
|
||||
if (OxygenLow == null) { DebugConsole.ThrowError("Affliction \"OxygenLow\" not defined in the affliction prefabs."); }
|
||||
if (Bloodloss == null) { DebugConsole.ThrowError("Affliction \"Bloodloss\" not defined in the affliction prefabs."); }
|
||||
if (Pressure == null) { DebugConsole.ThrowError("Affliction \"Pressure\" not defined in the affliction prefabs."); }
|
||||
if (Stun == null) { DebugConsole.ThrowError("Affliction \"Stun\" not defined in the affliction prefabs."); }
|
||||
if (RadiationSickness == null) { DebugConsole.ThrowError("Affliction \"RadiationSickness\" not defined in the affliction prefabs."); }
|
||||
}
|
||||
|
||||
public static void LoadFromFile(ContentFile file)
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file.Path);
|
||||
if (doc == null) { return; }
|
||||
var mainElement = doc.Root.IsOverride() ? doc.Root.FirstElement() : doc.Root;
|
||||
if (doc.Root.IsOverride())
|
||||
{
|
||||
DebugConsole.ThrowError("Cannot override all afflictions, because many of them are required by the main game! Please try overriding them one by one.");
|
||||
}
|
||||
|
||||
List<(AfflictionPrefab prefab, XElement element)> loadedAfflictions = new List<(AfflictionPrefab prefab, XElement element)>();
|
||||
|
||||
foreach (XElement element in mainElement.Elements())
|
||||
{
|
||||
bool isOverride = element.IsOverride();
|
||||
XElement sourceElement = isOverride ? element.FirstElement() : element;
|
||||
string elementName = sourceElement.Name.ToString().ToLowerInvariant();
|
||||
string identifier = sourceElement.GetAttributeString("identifier", null);
|
||||
if (!elementName.Equals("cprsettings", StringComparison.OrdinalIgnoreCase) &&
|
||||
!elementName.Equals("damageoverlay", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(identifier))
|
||||
{
|
||||
DebugConsole.ThrowError($"No identifier defined for the affliction '{elementName}' in file '{file.Path}'");
|
||||
continue;
|
||||
}
|
||||
if (Prefabs.ContainsKey(identifier))
|
||||
{
|
||||
if (isOverride)
|
||||
{
|
||||
DebugConsole.NewMessage($"Overriding an affliction or a buff with the identifier '{identifier}' using the file '{file.Path}'", Color.Yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Duplicate affliction: '{identifier}' defined in {elementName} of '{file.Path}'");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
string type = sourceElement.GetAttributeString("type", "");
|
||||
switch (sourceElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "cprsettings":
|
||||
type = "cprsettings";
|
||||
break;
|
||||
case "damageoverlay":
|
||||
type = "damageoverlay";
|
||||
break;
|
||||
}
|
||||
|
||||
AfflictionPrefab prefab = null;
|
||||
switch (type)
|
||||
{
|
||||
case "damageoverlay":
|
||||
#if CLIENT
|
||||
if (CharacterHealth.DamageOverlay != null)
|
||||
{
|
||||
if (isOverride)
|
||||
{
|
||||
DebugConsole.NewMessage($"Overriding damage overlay with '{file.Path}'", Color.Yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in '{file.Path}': damage overlay already loaded. Add <override></override> tags as the parent of the custom damage overlay sprite to allow overriding the vanilla one.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
CharacterHealth.DamageOverlay?.Remove();
|
||||
CharacterHealth.DamageOverlay = new Sprite(element);
|
||||
CharacterHealth.DamageOverlayFile = file.Path;
|
||||
#endif
|
||||
break;
|
||||
case "bleeding":
|
||||
prefab = new AfflictionPrefab(sourceElement, file.Path, typeof(AfflictionBleeding));
|
||||
break;
|
||||
case "huskinfection":
|
||||
case "alieninfection":
|
||||
prefab = new AfflictionPrefabHusk(sourceElement, file.Path, typeof(AfflictionHusk));
|
||||
break;
|
||||
case "cprsettings":
|
||||
if (CPRSettings.IsLoaded)
|
||||
{
|
||||
if (isOverride)
|
||||
{
|
||||
DebugConsole.NewMessage($"Overriding the CPR settings with '{file.Path}'", Color.Yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in '{file.Path}': CPR settings already loaded. Add <override></override> tags as the parent of the custom CPRSettings to allow overriding the vanilla values.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
CPRSettings.Load(sourceElement, file.Path);
|
||||
break;
|
||||
case "damage":
|
||||
case "burn":
|
||||
case "oxygenlow":
|
||||
case "bloodloss":
|
||||
case "stun":
|
||||
case "pressure":
|
||||
case "internaldamage":
|
||||
prefab = new AfflictionPrefab(sourceElement, file.Path, typeof(Affliction))
|
||||
{
|
||||
ContentPackage = file.ContentPackage
|
||||
};
|
||||
break;
|
||||
default:
|
||||
prefab = new AfflictionPrefab(sourceElement, file.Path)
|
||||
{
|
||||
ContentPackage = file.ContentPackage
|
||||
};
|
||||
break;
|
||||
}
|
||||
switch (identifier)
|
||||
{
|
||||
case "internaldamage":
|
||||
InternalDamage = prefab;
|
||||
break;
|
||||
case "blunttrauma":
|
||||
ImpactDamage = prefab;
|
||||
break;
|
||||
case "bleeding":
|
||||
Bleeding = prefab;
|
||||
break;
|
||||
case "burn":
|
||||
Burn = prefab;
|
||||
break;
|
||||
case "oxygenlow":
|
||||
OxygenLow = prefab;
|
||||
break;
|
||||
case "bloodloss":
|
||||
Bloodloss = prefab;
|
||||
break;
|
||||
case "pressure":
|
||||
Pressure = prefab;
|
||||
break;
|
||||
case "stun":
|
||||
Stun = prefab;
|
||||
break;
|
||||
case "radiationsickness":
|
||||
RadiationSickness = prefab;
|
||||
break;
|
||||
}
|
||||
if (ImpactDamage == null) { ImpactDamage = InternalDamage; }
|
||||
|
||||
if (prefab != null)
|
||||
{
|
||||
loadedAfflictions.Add((prefab, sourceElement));
|
||||
Prefabs.Add(prefab, isOverride);
|
||||
prefab.CalculatePrefabUIntIdentifier(Prefabs);
|
||||
}
|
||||
}
|
||||
|
||||
//load the effects after all the afflictions in the file have been instantiated
|
||||
//otherwise afflictions can't inflict other afflictions that are defined at a later point in the file
|
||||
foreach ((AfflictionPrefab prefab, XElement element) in loadedAfflictions)
|
||||
{
|
||||
prefab.LoadEffects(element);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveByFile(string filePath)
|
||||
{
|
||||
if (CPRSettings.FilePath == filePath) { CPRSettings.Unload(); }
|
||||
#if CLIENT
|
||||
if (CharacterHealth.DamageOverlayFile == filePath)
|
||||
{
|
||||
CharacterHealth.DamageOverlay?.Remove();
|
||||
CharacterHealth.DamageOverlay = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
Prefabs.RemoveByFile(filePath);
|
||||
}
|
||||
|
||||
public AfflictionPrefab(XElement element, string filePath, Type type = null)
|
||||
{
|
||||
FilePath = filePath;
|
||||
|
||||
typeName = type == null ? element.Name.ToString() : type.Name;
|
||||
if (typeName == "InternalDamage" && type == null)
|
||||
{
|
||||
type = typeof(Affliction);
|
||||
}
|
||||
|
||||
Identifier = element.GetAttributeString("identifier", "");
|
||||
|
||||
AfflictionType = element.GetAttributeString("type", "");
|
||||
TranslationOverride = element.GetAttributeString("translationoverride", null);
|
||||
string translationId = TranslationOverride ?? Identifier;
|
||||
Name = TextManager.Get("AfflictionName." + translationId, true) ?? element.GetAttributeString("name", "");
|
||||
Description = TextManager.Get("AfflictionDescription." + translationId, true) ?? element.GetAttributeString("description", "");
|
||||
configElement = element;
|
||||
|
||||
AfflictionType = element.GetAttributeIdentifier("type", "");
|
||||
TranslationIdentifier = element.GetAttributeIdentifier("translationoverride", Identifier);
|
||||
Name = TextManager.Get($"AfflictionName.{TranslationIdentifier}").Fallback(element.GetAttributeString("name", ""));
|
||||
Description = TextManager.Get($"AfflictionDescription.{TranslationIdentifier}").Fallback(element.GetAttributeString("description", ""));
|
||||
IsBuff = element.GetAttributeBool("isbuff", false);
|
||||
|
||||
HealableInMedicalClinic = element.GetAttributeBool("healableinmedicalclinic",
|
||||
!IsBuff &&
|
||||
!AfflictionType.Equals("geneticmaterialbuff", StringComparison.OrdinalIgnoreCase) &&
|
||||
!AfflictionType.Equals("geneticmaterialdebuff", StringComparison.OrdinalIgnoreCase));
|
||||
AfflictionType != "geneticmaterialbuff" &&
|
||||
AfflictionType != "geneticmaterialdebuff");
|
||||
HealCostMultiplier = element.GetAttributeFloat(nameof(HealCostMultiplier).ToLowerInvariant(), 1f);
|
||||
BaseHealCost = element.GetAttributeInt(nameof(BaseHealCost).ToLowerInvariant(), 0);
|
||||
|
||||
if (element.Attribute("nameidentifier") != null)
|
||||
if (element.GetAttribute("nameidentifier") != null)
|
||||
{
|
||||
Name = TextManager.Get(element.GetAttributeString("nameidentifier", string.Empty), returnNull: true) ?? Name;
|
||||
Name = TextManager.Get(element.GetAttributeString("nameidentifier", string.Empty)).Fallback(Name);
|
||||
}
|
||||
|
||||
LimbSpecific = element.GetAttributeBool("limbspecific", false);
|
||||
@@ -687,7 +430,8 @@ namespace Barotrauma
|
||||
MaxStrength = element.GetAttributeFloat("maxstrength", 100.0f);
|
||||
GrainBurst = element.GetAttributeFloat(nameof(GrainBurst).ToLowerInvariant(), 0.0f);
|
||||
|
||||
ShowInHealthScannerThreshold = element.GetAttributeFloat("showinhealthscannerthreshold", Math.Max(ActivationThreshold, AfflictionType == "talentbuff" ? float.MaxValue : 0.05f));
|
||||
ShowInHealthScannerThreshold = element.GetAttributeFloat("showinhealthscannerthreshold",
|
||||
Math.Max(ActivationThreshold, AfflictionType == "talentbuff" ? float.MaxValue : ShowIconToOthersThreshold));
|
||||
TreatmentThreshold = element.GetAttributeFloat("treatmentthreshold", Math.Max(ActivationThreshold, 5.0f));
|
||||
|
||||
DamageOverlayAlpha = element.GetAttributeFloat("damageoverlayalpha", 0.0f);
|
||||
@@ -695,14 +439,14 @@ namespace Barotrauma
|
||||
|
||||
KarmaChangeOnApplied = element.GetAttributeFloat("karmachangeonapplied", 0.0f);
|
||||
|
||||
CauseOfDeathDescription = TextManager.Get("AfflictionCauseOfDeath." + translationId, true) ?? element.GetAttributeString("causeofdeathdescription", "");
|
||||
SelfCauseOfDeathDescription = TextManager.Get("AfflictionCauseOfDeathSelf." + translationId, true) ?? element.GetAttributeString("selfcauseofdeathdescription", "");
|
||||
CauseOfDeathDescription = TextManager.Get($"AfflictionCauseOfDeath.{TranslationIdentifier}").Fallback(element.GetAttributeString("causeofdeathdescription", ""));
|
||||
SelfCauseOfDeathDescription = TextManager.Get($"AfflictionCauseOfDeathSelf.{TranslationIdentifier}").Fallback(element.GetAttributeString("selfcauseofdeathdescription", ""));
|
||||
|
||||
IconColors = element.GetAttributeColorArray("iconcolors", null);
|
||||
AfflictionOverlayAlphaIsLinear = element.GetAttributeBool("afflictionoverlayalphaislinear", false);
|
||||
AchievementOnRemoved = element.GetAttributeString("achievementonremoved", "");
|
||||
AchievementOnRemoved = element.GetAttributeIdentifier("achievementonremoved", "");
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -724,43 +468,42 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (type == null)
|
||||
{
|
||||
type = Type.GetType("Barotrauma." + typeName, true, true);
|
||||
if (type == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not find an affliction class of the type \"" + typeName + "\".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugConsole.ThrowError("Could not find an affliction class of the type \"" + typeName + "\".");
|
||||
type = typeof(Affliction);
|
||||
}
|
||||
|
||||
constructor = type.GetConstructor(new[] { typeof(AfflictionPrefab), typeof(float) });
|
||||
}
|
||||
|
||||
private void LoadEffects(XElement element)
|
||||
public static void LoadAllEffects()
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
Prefabs.ForEach(p => p.LoadEffects());
|
||||
}
|
||||
|
||||
public static void ClearAllEffects()
|
||||
{
|
||||
Prefabs.ForEach(p => p.ClearEffects());
|
||||
}
|
||||
|
||||
public void LoadEffects()
|
||||
{
|
||||
ClearEffects();
|
||||
foreach (var subElement in configElement.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "effect":
|
||||
effects.Add(new Effect(subElement, Name));
|
||||
effects.Add(new Effect(subElement, Name.Value));
|
||||
break;
|
||||
case "periodiceffect":
|
||||
periodicEffects.Add(new PeriodicEffect(subElement, Name));
|
||||
periodicEffects.Add(new PeriodicEffect(subElement, Name.Value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEffects()
|
||||
{
|
||||
effects.Clear();
|
||||
periodicEffects.Clear();
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
public void ReloadSoundsIfNeeded()
|
||||
{
|
||||
@@ -770,7 +513,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (var sound in statusEffect.Sounds)
|
||||
{
|
||||
if (sound.Sound == null) { Submarine.ReloadRoundSound(sound); }
|
||||
if (sound.Sound == null) { RoundSound.Reload(sound); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -780,7 +523,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (var sound in statusEffect.Sounds)
|
||||
{
|
||||
if (sound.Sound == null) { Submarine.ReloadRoundSound(sound); }
|
||||
if (sound.Sound == null) { RoundSound.Reload(sound); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -789,7 +532,7 @@ namespace Barotrauma
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "AfflictionPrefab (" + Name + ")";
|
||||
return $"AfflictionPrefab ({Name})";
|
||||
}
|
||||
|
||||
public Affliction Instantiate(float strength, Character source = null)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ namespace Barotrauma
|
||||
invertControlsToggleTimer = 5.0f;
|
||||
if (Rand.Range(0.0f, 1.0f) < 0.5f)
|
||||
{
|
||||
characterHealth.ReduceAffliction(null, "invertcontrols", 100);
|
||||
characterHealth.ReduceAfflictionOnAllLimbs("invertcontrols".ToIdentifier(), 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user