Unstable v0.15.17.0 (Hex is out of town edition)

This commit is contained in:
Juan Pablo Arce
2021-12-03 13:31:10 -03:00
parent cd5c8f3e13
commit 617d9ede88
245 changed files with 8088 additions and 5842 deletions
@@ -1,4 +1,5 @@
using Barotrauma.Items.Components;
using System;
using System.Linq;
using System.Xml.Linq;
@@ -10,26 +11,25 @@ namespace Barotrauma.Abilities
{
Any = 0,
Melee = 1,
Ranged = 2
Ranged = 2,
HandheldRanged = 3,
Turret = 4
};
private readonly string itemIdentifier;
private readonly string[] tags;
private readonly WeaponType weapontype;
private bool ignoreNonHarmfulAttacks;
private readonly bool ignoreNonHarmfulAttacks;
public AbilityConditionAttackData(CharacterTalent characterTalent, XElement conditionElement) : base(characterTalent, conditionElement)
{
itemIdentifier = conditionElement.GetAttributeString("itemidentifier", "");
tags = conditionElement.GetAttributeStringArray("tags", new string[0], convertToLowerInvariant: true);
ignoreNonHarmfulAttacks = conditionElement.GetAttributeBool("ignorenonharmfulattacks", false);
switch (conditionElement.GetAttributeString("weapontype", ""))
string weaponTypeStr = conditionElement.GetAttributeString("weapontype", "Any");
if (!Enum.TryParse(weaponTypeStr, ignoreCase: true, out weapontype))
{
case "melee":
weapontype = WeaponType.Melee;
break;
case "ranged":
weapontype = WeaponType.Ranged;
break;
DebugConsole.ThrowError($"Error in talent \"{characterTalent.DebugIdentifier}\": \"{weaponTypeStr}\" is not a valid weapon type.");
}
}
@@ -77,6 +77,16 @@ namespace Barotrauma.Abilities
return item.GetComponent<MeleeWeapon>() != null;
case WeaponType.Ranged:
return item.GetComponent<Projectile>() != null;
case WeaponType.HandheldRanged:
{
var projectile = item.GetComponent<Projectile>();
return projectile?.Launcher?.GetComponent<Holdable>() != null;
}
case WeaponType.Turret:
{
var projectile = item.GetComponent<Projectile>();
return projectile?.Launcher?.GetComponent<Turret>() != null;
}
}
return true;
@@ -0,0 +1,28 @@
using System.Xml.Linq;
using static Barotrauma.StatusEffect;
namespace Barotrauma.Abilities
{
class AbilityConditionStatusEffectIdentifier : AbilityConditionData
{
private string effectIdentifier;
public AbilityConditionStatusEffectIdentifier(CharacterTalent characterTalent, XElement conditionElement) : base(characterTalent, conditionElement)
{
effectIdentifier = conditionElement.GetAttributeString("effectidentifier", "").ToLowerInvariant();
}
protected override bool MatchesConditionSpecific(AbilityObject abilityObject)
{
if (abilityObject is AbilityStatusEffectIdentifier abilityStatusEffectIdentifier)
{
return abilityStatusEffectIdentifier.EffectIdentifier == effectIdentifier;
}
else
{
LogAbilityConditionError(abilityObject, typeof(AbilityStatusEffectIdentifier));
return false;
}
}
}
}
@@ -26,7 +26,7 @@ namespace Barotrauma.Abilities
value = abilityElement.GetAttributeFloat("value", 0f);
maxValue = abilityElement.GetAttributeFloat("maxvalue", float.MaxValue);
targetAllies = abilityElement.GetAttributeBool("targetallies", false);
removeOnDeath = abilityElement.GetAttributeBool("removeondeath", true);
removeOnDeath = abilityElement.GetAttributeBool("removeondeath", false);
giveOnAddingFirstTime = abilityElement.GetAttributeBool("giveonaddingfirsttime", characterAbilityGroup.AbilityEffectType == AbilityEffectType.None);
setValue = abilityElement.GetAttributeBool("setvalue", false);
}
@@ -1,6 +1,4 @@
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Xml.Linq;
namespace Barotrauma.Abilities
{
@@ -13,6 +11,10 @@ namespace Barotrauma.Abilities
{
itemIdentifier = abilityElement.GetAttributeString("itemidentifier", "");
amount = abilityElement.GetAttributeInt("amount", 1);
if (string.IsNullOrEmpty(itemIdentifier))
{
DebugConsole.ThrowError($"Error in talent \"{characterAbilityGroup.CharacterTalent.DebugIdentifier}\" - itemIdentifier not defined.");
}
}
protected override void ApplyEffect()
@@ -34,7 +36,13 @@ namespace Barotrauma.Abilities
if (GameMain.GameSession?.RoundEnding ?? true)
{
Item item = new Item(itemPrefab, Character.WorldPosition, Character.Submarine);
Character.Inventory.TryPutItem(item, Character, new List<InvSlotType>() { InvSlotType.Any });
if (!Character.Inventory.TryPutItem(item, Character))
{
foreach (Item containedItem in Character.Inventory.AllItemsMod)
{
if (containedItem.OwnInventory?.TryPutItem(item, Character) ?? false) { break; }
}
}
}
else
{
@@ -31,7 +31,7 @@ namespace Barotrauma.Abilities
}
}
if (closestCharacter.SelectedConstruction == null || !closestCharacter.SelectedConstruction.HasTag(tag)) { return; }
if (closestCharacter?.SelectedConstruction == null || !closestCharacter.SelectedConstruction.HasTag(tag)) { return; }
if (closestDistance < squaredMaxDistance)
{
@@ -31,7 +31,6 @@ namespace Barotrauma
ConfigElement = element;
Identifier = element.GetAttributeString("identifier", "noidentifier");
DisplayName = TextManager.Get("talentname." + Identifier, returnNull: true) ?? Identifier;
this.CalculatePrefabUIntIdentifier(TalentPrefabs);
foreach (XElement subElement in element.Elements())
{
@@ -103,7 +102,9 @@ namespace Barotrauma
void loadSinglePrefab(XElement element, bool isOverride)
{
TalentPrefabs.Add(new TalentPrefab(element, file.Path) { ContentPackage = file.ContentPackage }, isOverride);
var newPrefab = new TalentPrefab(element, file.Path) { ContentPackage = file.ContentPackage };
TalentPrefabs.Add(newPrefab, isOverride);
newPrefab.CalculatePrefabUIntIdentifier(TalentPrefabs);
}
void loadMultiplePrefabs(XElement element, bool isOverride)