v0.12.0.2

This commit is contained in:
Joonas Rikkonen
2021-02-10 17:08:21 +02:00
parent 5c80a59bdd
commit 694cdfee7b
353 changed files with 12897 additions and 5028 deletions
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Linq;
using System;
using Barotrauma.Extensions;
namespace Barotrauma
{
@@ -73,7 +74,10 @@ namespace Barotrauma
else if (Strength < ActiveThreshold)
{
DeactivateHusk();
character.SpeechImpediment = 100;
if (Prefab is AfflictionPrefabHusk { CauseSpeechImpediment: false })
{
character.SpeechImpediment = 100;
}
State = InfectionState.Transition;
}
else if (Strength < Prefab.MaxStrength)
@@ -118,13 +122,25 @@ namespace Barotrauma
{
huskAppendage = AttachHuskAppendage(character, Prefab.Identifier);
}
character.NeedsAir = false;
character.SpeechImpediment = 100;
if (Prefab is AfflictionPrefabHusk { NeedsAir: false })
{
character.NeedsAir = false;
}
if (Prefab is AfflictionPrefabHusk { CauseSpeechImpediment: false })
{
character.SpeechImpediment = 100;
}
}
private void DeactivateHusk()
{
character.NeedsAir = character.Params.MainElement.GetAttributeBool("needsair", false);
if (Prefab is AfflictionPrefabHusk { NeedsAir: false })
{
character.NeedsAir = character.Params.MainElement.GetAttributeBool("needsair", false);
}
if (huskAppendage != null)
{
huskAppendage.ForEach(l => character.AnimController.RemoveLimb(l));
@@ -154,6 +170,10 @@ namespace Barotrauma
}
}
//character already in remove queue (being removed by something else, for example a modded affliction that uses AfflictionHusk as the base)
// -> don't spawn the AI husk
if (Entity.Spawner.IsInRemoveQueue(character)) { return; }
//create the AI husk in a coroutine to ensure that we don't modify the character list while enumerating it
CoroutineManager.StartCoroutine(CreateAIHusk());
}
@@ -179,7 +199,7 @@ namespace Barotrauma
if (husk.Info != null)
{
husk.Info.Character = husk;
husk.Info.TeamID = Character.TeamType.None;
husk.Info.TeamID = CharacterTeamType.None;
}
foreach (Limb limb in husk.AnimController.Limbs)
@@ -201,17 +221,16 @@ namespace Barotrauma
if (character.Inventory != null && husk.Inventory != null)
{
if (character.Inventory.Items.Length != husk.Inventory.Items.Length)
if (character.Inventory.Capacity != husk.Inventory.Capacity)
{
string errorMsg = "Failed to move items from the source character's inventory into a husk's inventory (inventory sizes don't match)";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("AfflictionHusk.CreateAIHusk:InventoryMismatch", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
yield return CoroutineStatus.Success;
}
for (int i = 0; i < character.Inventory.Items.Length && i < husk.Inventory.Items.Length; i++)
for (int i = 0; i < character.Inventory.Capacity && i < husk.Inventory.Capacity; i++)
{
if (character.Inventory.Items[i] == null) continue;
husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true, false, null);
character.Inventory.GetItemsAt(i).ForEachMod(item => husk.Inventory.TryPutItem(item, i, true, false, null));
}
}
@@ -90,6 +90,10 @@ namespace Barotrauma
AttachLimbName = null;
AttachLimbType = LimbType.None;
}
SendMessages = element.GetAttributeBool("sendmessages", true);
CauseSpeechImpediment = element.GetAttributeBool("causespeechimpediment", true);
NeedsAir = element.GetAttributeBool("needsair", false);
}
// Use any of these to define which limb the appendage is attached to.
@@ -101,6 +105,10 @@ namespace Barotrauma
public readonly string HuskedSpeciesName;
public readonly string[] TargetSpecies;
public const string Tag = "[speciesname]";
public readonly bool SendMessages;
public readonly bool CauseSpeechImpediment;
public readonly bool NeedsAir;
}
class AfflictionPrefab : IPrefab, IDisposable
@@ -572,7 +580,7 @@ namespace Barotrauma
IconColors = element.GetAttributeColorArray("iconcolors", null);
AchievementOnRemoved = element.GetAttributeString("achievementonremoved", "");
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -214,7 +214,7 @@ namespace Barotrauma
InitProjSpecific(null, character);
}
public CharacterHealth(XElement element, Character character)
public CharacterHealth(XElement element, Character character, XElement limbHealthElement = null)
{
this.Character = character;
InitIrremovableAfflictions();
@@ -224,7 +224,8 @@ namespace Barotrauma
minVitality = character.IsHuman ? -100.0f : 0.0f;
limbHealths.Clear();
foreach (XElement subElement in element.Elements())
limbHealthElement ??= element;
foreach (XElement subElement in limbHealthElement.Elements())
{
if (!subElement.Name.ToString().Equals("limb", StringComparison.OrdinalIgnoreCase)) { continue; }
limbHealths.Add(new LimbHealth(subElement, this));
@@ -86,6 +86,11 @@ namespace Barotrauma
private void ParseAfflictionTypes()
{
if (string.IsNullOrWhiteSpace(rawAfflictionTypeString))
{
parsedAfflictionTypes = new string[0];
return;
}
string[] splitValue = rawAfflictionTypeString.Split(',', '');
for (int i = 0; i < splitValue.Length; i++)
{
@@ -96,6 +101,11 @@ namespace Barotrauma
private void ParseAfflictionIdentifiers()
{
if (string.IsNullOrWhiteSpace(rawAfflictionIdentifierString))
{
parsedAfflictionIdentifiers = new string[0];
return;
}
string[] splitValue = rawAfflictionIdentifierString.Split(',', '');
for (int i = 0; i < splitValue.Length; i++)
{