This commit is contained in:
EvilFactory
2022-10-20 12:14:02 -03:00
63 changed files with 579 additions and 339 deletions
@@ -186,8 +186,8 @@ namespace Barotrauma
{
if (character.SelectedItem != Item)
{
if (Item.TryInteract(character, ignoreRequiredItems: true, forceSelectKey: true) ||
Item.TryInteract(character, ignoreRequiredItems: true, forceUseKey: true))
if (Item.TryInteract(character, ignoreRequiredItems: true, forceUseKey: true) ||
Item.TryInteract(character, ignoreRequiredItems: true, forceSelectKey: true))
{
character.SelectedItem = Item;
}
@@ -1345,7 +1345,7 @@ namespace Barotrauma
bool limbsValid = true;
foreach (Limb limb in limbs)
{
if (limb.body == null || !limb.body.Enabled) { continue; }
if (limb?.body == null || !limb.body.Enabled) { continue; }
if (!CheckValidity(limb.body))
{
limbsValid = false;
@@ -1967,7 +1967,7 @@ namespace Barotrauma
{
foreach (Limb l in Limbs)
{
l.Remove();
l?.Remove();
}
limbs = null;
}
@@ -1976,7 +1976,7 @@ namespace Barotrauma
{
foreach (PhysicsBody b in collider)
{
b.Remove();
b?.Remove();
}
collider = null;
}
@@ -1985,7 +1985,7 @@ namespace Barotrauma
{
foreach (var joint in LimbJoints)
{
var j = joint.Joint;
var j = joint?.Joint;
if (GameMain.World.JointList.Contains(j))
{
GameMain.World.Remove(j);
@@ -2728,6 +2728,11 @@ namespace Barotrauma
}
}
bool selectInputSameAsDeselect = false;
#if CLIENT
selectInputSameAsDeselect = GameSettings.CurrentConfig.KeyMap.Bindings[InputType.Select] == GameSettings.CurrentConfig.KeyMap.Bindings[InputType.Deselect];
#endif
if (SelectedCharacter != null && (IsKeyHit(InputType.Grab) || IsKeyHit(InputType.Health))) //Let people use ladders and buttons and stuff when dragging chars
{
DeselectCharacter();
@@ -2767,14 +2772,16 @@ namespace Barotrauma
{
FocusedCharacter.onCustomInteract(FocusedCharacter, this);
}
else if (IsKeyHit(InputType.Deselect) && SelectedItem != null)
else if (IsKeyHit(InputType.Deselect) && SelectedItem != null &&
(focusedItem == null || focusedItem == SelectedItem || !selectInputSameAsDeselect))
{
SelectedItem = null;
#if CLIENT
CharacterHealth.OpenHealthWindow = null;
#endif
}
else if (IsKeyHit(InputType.Deselect) && SelectedSecondaryItem != null)
else if (IsKeyHit(InputType.Deselect) && SelectedSecondaryItem != null && SelectedSecondaryItem.GetComponent<Ladder>() == null &&
(focusedItem == null || focusedItem == SelectedSecondaryItem || !selectInputSameAsDeselect))
{
SelectedSecondaryItem = null;
#if CLIENT
@@ -2789,6 +2796,10 @@ namespace Barotrauma
{
#if CLIENT
if (CharacterInventory.DraggingItemToWorld) { return; }
if (selectInputSameAsDeselect)
{
keys[(int)InputType.Deselect].Reset();
}
#endif
bool canInteract = focusedItem.TryInteract(this);
#if CLIENT
@@ -543,7 +543,7 @@ namespace Barotrauma
private void GetName(Rand.RandSync randSync, out string name)
{
var nameElement = CharacterConfigElement.GetChildElement("names") ?? CharacterConfigElement.GetChildElement("name");
ContentXElement nameElement = CharacterConfigElement.GetChildElement("names") ?? CharacterConfigElement.GetChildElement("name");
ContentPath namesXmlFile = nameElement?.GetAttributeContentPath("path") ?? ContentPath.Empty;
XElement namesXml = null;
if (!namesXmlFile.IsNullOrEmpty()) //names.xml is defined
@@ -554,8 +554,8 @@ namespace Barotrauma
else //the legacy firstnames.txt/lastnames.txt shit is defined
{
namesXml = new XElement("names", new XAttribute("format", "[firstname] [lastname]"));
var firstNamesPath = ReplaceVars(nameElement.GetAttributeContentPath("firstname")?.Value ?? "");
var lastNamesPath = ReplaceVars(nameElement.GetAttributeContentPath("lastname")?.Value ?? "");
string firstNamesPath = nameElement == null ? string.Empty : ReplaceVars(nameElement.GetAttributeContentPath("firstname")?.Value ?? "");
string lastNamesPath = nameElement == null ? string.Empty : ReplaceVars(nameElement.GetAttributeContentPath("lastname")?.Value ?? "");
if (File.Exists(firstNamesPath) && File.Exists(lastNamesPath))
{
var firstNames = File.ReadAllLines(firstNamesPath);
@@ -17,7 +17,7 @@
{
var affliction = character.CharacterHealth.GetAffliction(afflictionIdentifier);
if (affliction == null) { return false; }
return minimumPercentage <= affliction.Strength / affliction.Prefab.MaxStrength;
return affliction.Strength >= affliction.Prefab.ActivationThreshold && minimumPercentage <= affliction.Strength / affliction.Prefab.MaxStrength;
}
return false;
}
@@ -13,21 +13,23 @@ namespace Barotrauma.Abilities
protected override void ApplyEffect()
{
if (!SelectedItemHasTag(Character)) { return; }
if (!SelectedItemHasTag(Character, tag)) { return; }
Character closestCharacter = null;
float closestDistance = squaredMaxDistance;
foreach (Character crewCharacter in Character.GetFriendlyCrew(Character))
{
if (crewCharacter != Character && Vector2.DistanceSquared(Character.SimPosition, Character.GetRelativeSimPosition(crewCharacter)) is float tempDistance && tempDistance < closestDistance)
if (crewCharacter != Character &&
Vector2.DistanceSquared(Character.WorldPosition, crewCharacter.WorldPosition) is float tempDistance && tempDistance < closestDistance &&
SelectedItemHasTag(crewCharacter, tag))
{
closestCharacter = crewCharacter;
closestDistance = tempDistance;
}
}
if (closestCharacter == null || !SelectedItemHasTag(closestCharacter)) { return; }
if (closestCharacter == null) { return; }
if (closestDistance < squaredMaxDistance)
{
@@ -35,7 +37,7 @@ namespace Barotrauma.Abilities
ApplyEffectSpecific(closestCharacter);
}
bool SelectedItemHasTag(Character character) =>
static bool SelectedItemHasTag(Character character, string tag) =>
(character.SelectedItem != null && character.SelectedItem.HasTag(tag)) ||
(character.SelectedSecondaryItem != null && character.SelectedSecondaryItem.HasTag(tag));
}