v0.18.15.0

This commit is contained in:
Regalis11
2022-07-14 16:54:36 +03:00
parent 497045de7e
commit 4a03ee5ab2
36 changed files with 240 additions and 151 deletions
@@ -191,7 +191,7 @@ namespace Barotrauma.Items.Components
while (impactQueue.Count > 0)
{
var impact = impactQueue.Dequeue();
HandleImpact(impact.Body);
HandleImpact(impact);
}
//in case handling the impact does something to the picker
if (picker == null) { return; }
@@ -342,7 +342,7 @@ namespace Barotrauma.Items.Components
}
hitTargets.Add(targetCharacter);
}
else if (f2.Body.UserData is Structure targetStructure)
else if ((f2.Body.UserData as Structure ?? f2.UserData as Structure) is Structure targetStructure)
{
if (AllowHitMultiple)
{
@@ -380,8 +380,9 @@ namespace Barotrauma.Items.Components
return true;
}
private void HandleImpact(Body target)
private void HandleImpact(Fixture targetFixture)
{
var target = targetFixture.Body;
if (User == null || User.Removed || target == null)
{
RestoreCollision();
@@ -410,7 +411,7 @@ namespace Barotrauma.Items.Components
targetCharacter.LastDamageSource = item;
Attack.DoDamage(User, targetCharacter, item.WorldPosition, 1.0f);
}
else if (target.UserData is Structure targetStructure)
else if ((target.UserData as Structure ?? targetFixture.UserData as Structure) is Structure targetStructure)
{
if (targetStructure.Removed) { return; }
Attack.DoDamage(User, targetStructure, item.WorldPosition, 1.0f);
@@ -742,7 +742,7 @@ namespace Barotrauma.Items.Components
limb.body?.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass * 0.1f, item.SimPosition);
return false;
}
if (!FriendlyFire && User != null && limb.character.IsFriendly(User))
if (!FriendlyFire && User != null && limb.character.IsFriendly(User) && HumanAIController.IsOnFriendlyTeam(limb.character, User))
{
return false;
}
@@ -238,6 +238,12 @@ namespace Barotrauma.Items.Components
base.OnItemLoaded();
SetLightSourceState(IsActive, lightBrightness);
turret = item.GetComponent<Turret>();
#if CLIENT
if (Screen.Selected.IsEditor)
{
OnMapLoaded();
}
#endif
}
public override void OnMapLoaded()
@@ -1,12 +1,11 @@
using System;
using System.Text.RegularExpressions;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
class RegExFindComponent : ItemComponent
{
private static readonly TimeSpan timeout = TimeSpan.FromSeconds(Timing.Step);
private static readonly TimeSpan timeout = TimeSpan.FromMilliseconds(1);
private string expression;
@@ -63,10 +62,9 @@ namespace Barotrauma.Items.Components
get { return expression; }
set
{
if (expression == value) return;
if (expression == value) { return; }
expression = value;
previousReceivedSignal = "";
try
{
regex = new Regex(
@@ -74,11 +72,12 @@ namespace Barotrauma.Items.Components
options: RegexOptions.None,
matchTimeout: timeout);
}
catch
{
return;
}
//reactivate the component, in case some faulty/malicious expression caused it to time out and deactivate itself
IsActive = true;
}
}
@@ -105,11 +104,16 @@ namespace Barotrauma.Items.Components
}
catch (Exception e)
{
item.SendSignal(
e is RegexMatchTimeoutException
? "TIMEOUT"
: "ERROR",
"signal_out");
if (e is RegexMatchTimeoutException)
{
item.SendSignal("TIMEOUT", "signal_out");
//deactivate the component if the expression caused it to time out
IsActive = false;
}
else
{
item.SendSignal("ERROR", "signal_out");
}
previousResult = false;
return;
}