Unstable 0.16.2.0
This commit is contained in:
@@ -74,6 +74,13 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(true, false, description: "Should the OnUse StatusEffects trigger when docking (on vanilla docking ports these effects emit particles and play a sound).)")]
|
||||
public bool ApplyEffectsOnDocking
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Editable, Serialize(DirectionType.None, false, description: "Which direction the port is allowed to dock in. For example, \"Top\" would mean the port can dock to another port above it.\n"+
|
||||
"Normally there's no need to touch this setting, but if you notice the docking position is incorrect (for example due to some unusual docking port configuration without hulls or doors), you can use this to enforce the direction.")]
|
||||
public DirectionType ForceDockingDirection { get; set; }
|
||||
@@ -261,7 +268,7 @@ namespace Barotrauma.Items.Components
|
||||
DockingDir = GetDir(DockingTarget);
|
||||
DockingTarget.DockingDir = -DockingDir;
|
||||
|
||||
if (applyEffects)
|
||||
if (applyEffects && ApplyEffectsOnDocking)
|
||||
{
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (holdable.Attached)
|
||||
{
|
||||
GameAnalyticsManager.AddDesignEvent("ResourceCollected:" + (GameMain.GameSession?.GameMode?.Name ?? "none") + ":" + item.Prefab.Identifier);
|
||||
GameAnalyticsManager.AddDesignEvent("ResourceCollected:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "none") + ":" + item.Prefab.Identifier);
|
||||
holdable.DeattachFromWall();
|
||||
}
|
||||
trigger.Enabled = false;
|
||||
|
||||
@@ -841,9 +841,9 @@ namespace Barotrauma.Items.Components
|
||||
if (statusEffectLists == null) { return; }
|
||||
if (!statusEffectLists.TryGetValue(actionType, out List<StatusEffect> statusEffects)) { return; }
|
||||
|
||||
currentTargets.Clear();
|
||||
foreach (StatusEffect effect in statusEffects)
|
||||
{
|
||||
currentTargets.Clear();
|
||||
effect.SetUser(user);
|
||||
if (effect.HasTargetType(StatusEffect.TargetType.UseTarget))
|
||||
{
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
GameAnalyticsManager.AddDesignEvent("ItemDeconstructed:" + (GameMain.GameSession?.GameMode?.Name ?? "none") + ":" + targetItem.prefab.Identifier);
|
||||
GameAnalyticsManager.AddDesignEvent("ItemDeconstructed:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "none") + ":" + targetItem.prefab.Identifier);
|
||||
|
||||
if (targetItem.AllowDeconstruct && allowRemove)
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Barotrauma.Items.Components
|
||||
prevVoltage = Voltage;
|
||||
hasPower = Voltage > MinVoltage;
|
||||
|
||||
Force = MathHelper.Lerp(force, (Voltage < MinVoltage) ? 0.0f : targetForce, 0.1f);
|
||||
Force = MathHelper.Lerp(force, (Voltage < MinVoltage) ? 0.0f : targetForce, deltaTime * 10.0f);
|
||||
if (Math.Abs(Force) > 1.0f)
|
||||
{
|
||||
float voltageFactor = MinVoltage <= 0.0f ? 1.0f : Math.Min(Voltage, 1.0f);
|
||||
@@ -137,18 +137,19 @@ namespace Barotrauma.Items.Components
|
||||
currForce *= MathHelper.Lerp(0.5f, 2.0f, condition);
|
||||
if (item.Submarine.FlippedX) { currForce *= -1; }
|
||||
Vector2 forceVector = new Vector2(currForce, 0);
|
||||
item.Submarine.ApplyForce(forceVector);
|
||||
item.Submarine.ApplyForce(forceVector * deltaTime * Timing.FixedUpdateRate);
|
||||
UpdatePropellerDamage(deltaTime);
|
||||
#if CLIENT
|
||||
particleTimer -= deltaTime;
|
||||
if (particleTimer <= 0.0f)
|
||||
float particleInterval = 1.0f / particlesPerSec;
|
||||
particleTimer += deltaTime;
|
||||
while (particleTimer > particleInterval)
|
||||
{
|
||||
Vector2 particleVel = -forceVector.ClampLength(5000.0f) / 5.0f;
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", item.WorldPosition + PropellerPos * item.Scale,
|
||||
particleVel * Rand.Range(0.9f, 1.1f),
|
||||
particleVel * Rand.Range(0.8f, 1.1f),
|
||||
0.0f, item.CurrentHull);
|
||||
particleTimer = 1.0f / particlesPerSec;
|
||||
}
|
||||
particleTimer -= particleInterval;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ namespace Barotrauma.Items.Components
|
||||
for (int i = 0; i < (int)fabricationitemAmount.Value; i++)
|
||||
{
|
||||
float outCondition = fabricatedItem.OutCondition;
|
||||
GameAnalyticsManager.AddDesignEvent("ItemFabricated:" + (GameMain.GameSession?.GameMode?.Name ?? "none") + ":" + fabricatedItem.TargetItem.Identifier);
|
||||
GameAnalyticsManager.AddDesignEvent("ItemFabricated:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "none") + ":" + fabricatedItem.TargetItem.Identifier);
|
||||
if (i < amountFittingContainer)
|
||||
{
|
||||
Entity.Spawner.AddToSpawnQueue(fabricatedItem.TargetItem, outputContainer.Inventory, fabricatedItem.TargetItem.Health * outCondition, quality,
|
||||
|
||||
@@ -103,7 +103,20 @@ namespace Barotrauma.Items.Components
|
||||
if (TargetLevel != null)
|
||||
{
|
||||
float hullPercentage = 0.0f;
|
||||
if (item.CurrentHull != null) { hullPercentage = (item.CurrentHull.WaterVolume / item.CurrentHull.Volume) * 100.0f; }
|
||||
if (item.CurrentHull != null)
|
||||
{
|
||||
float hullWaterVolume = item.CurrentHull.WaterVolume;
|
||||
float totalHullVolume = item.CurrentHull.Volume;
|
||||
foreach (var linked in item.CurrentHull.linkedTo)
|
||||
{
|
||||
if ((linked is Hull linkedHull))
|
||||
{
|
||||
hullWaterVolume += linkedHull.WaterVolume;
|
||||
totalHullVolume += linkedHull.Volume;
|
||||
}
|
||||
}
|
||||
hullPercentage = hullWaterVolume / totalHullVolume * 100.0f;
|
||||
}
|
||||
FlowPercentage = ((float)TargetLevel - hullPercentage) * 10.0f;
|
||||
}
|
||||
|
||||
@@ -131,8 +144,8 @@ namespace Barotrauma.Items.Components
|
||||
//less effective when in a bad condition
|
||||
currFlow *= MathHelper.Lerp(0.5f, 1.0f, item.Condition / item.MaxCondition);
|
||||
|
||||
item.CurrentHull.WaterVolume += currFlow;
|
||||
if (item.CurrentHull.WaterVolume > item.CurrentHull.Volume) { item.CurrentHull.Pressure += 0.5f; }
|
||||
item.CurrentHull.WaterVolume += currFlow * deltaTime * Timing.FixedUpdateRate;
|
||||
if (item.CurrentHull.WaterVolume > item.CurrentHull.Volume) { item.CurrentHull.Pressure += 30.0f * deltaTime; }
|
||||
|
||||
Voltage -= deltaTime;
|
||||
}
|
||||
|
||||
@@ -738,8 +738,9 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
lastTarget = target;
|
||||
|
||||
float projectileNewSpeed = 0.5f;
|
||||
float projectileDeflectedNewSpeed = 0.1f;
|
||||
int remainingHits = Math.Max(MaxTargetsToHit - hits.Count, 0);
|
||||
float speedMultiplier = Math.Min(0.4f + remainingHits * 0.1f, 1.0f);
|
||||
float deflectedSpeedMultiplier = 0.1f;
|
||||
|
||||
AttackResult attackResult = new AttackResult();
|
||||
Character character = null;
|
||||
@@ -755,8 +756,8 @@ namespace Barotrauma.Items.Components
|
||||
// when hitting limbs with piercing ammo, don't lose as much speed
|
||||
if (MaxTargetsToHit > 1)
|
||||
{
|
||||
projectileNewSpeed = 1f;
|
||||
projectileDeflectedNewSpeed = 0.8f;
|
||||
speedMultiplier = 1f;
|
||||
deflectedSpeedMultiplier = 0.8f;
|
||||
}
|
||||
if (limb.IsSevered || limb.character == null || limb.character.Removed) { return false; }
|
||||
|
||||
@@ -869,7 +870,7 @@ namespace Barotrauma.Items.Components
|
||||
if (attackResult.AppliedDamageModifiers != null &&
|
||||
(attackResult.AppliedDamageModifiers.Any(dm => dm.DeflectProjectiles) && !StickToDeflective))
|
||||
{
|
||||
item.body.LinearVelocity *= projectileDeflectedNewSpeed;
|
||||
item.body.LinearVelocity *= deflectedSpeedMultiplier;
|
||||
}
|
||||
else if ( // When hitting characters the collision normal seems to sometimes point into wrong direction, resulting in a failed attempt to stick
|
||||
//Vector2.Dot(Vector2.Normalize(velocity), collisionNormal) < 0.0f &&
|
||||
@@ -901,13 +902,13 @@ namespace Barotrauma.Items.Components
|
||||
item.CreateServerEvent(this);
|
||||
}
|
||||
#endif
|
||||
item.body.LinearVelocity *= projectileNewSpeed;
|
||||
item.body.LinearVelocity *= speedMultiplier;
|
||||
|
||||
return Hitscan;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.body.LinearVelocity *= projectileNewSpeed;
|
||||
item.body.LinearVelocity *= speedMultiplier;
|
||||
}
|
||||
|
||||
var containedItems = item.OwnInventory?.AllItems;
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace Barotrauma.Items.Components
|
||||
ic.ReceiveSignal(signal, connection);
|
||||
}
|
||||
|
||||
if (recipient.Effects != null && signal.value != "0" && !string.IsNullOrEmpty(signal.value))
|
||||
if (recipient.Effects != null && signal.value != "0")
|
||||
{
|
||||
foreach (StatusEffect effect in recipient.Effects)
|
||||
{
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
if (item.body == null && powerConsumption <= 0.0f && Parent == null && turret == null &&
|
||||
if (item.body == null && powerConsumption <= 0.0f && Parent == null && turret == null && IsOn &&
|
||||
(statusEffectLists == null || !statusEffectLists.ContainsKey(ActionType.OnActive)) &&
|
||||
(IsActiveConditionals == null || IsActiveConditionals.Count == 0))
|
||||
{
|
||||
|
||||
@@ -235,6 +235,13 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool IsInteractable(Character character)
|
||||
{
|
||||
#if CLIENT
|
||||
if (Screen.Selected is EditorScreen)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (character != null && character.IsOnPlayerTeam)
|
||||
{
|
||||
return IsPlayerTeamInteractable;
|
||||
@@ -638,6 +645,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private float buoyancySineMagnitude;
|
||||
private float buoyancySineFrequency;
|
||||
private float buoyancyRandomForce;
|
||||
|
||||
public bool FireProof
|
||||
{
|
||||
get { return Prefab.FireProof; }
|
||||
@@ -866,9 +877,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body.FarseerBody.AngularDamping = element.GetAttributeFloat("angulardamping", 0.2f);
|
||||
body.FarseerBody.LinearDamping = element.GetAttributeFloat("lineardamping", 0.1f);
|
||||
body.FarseerBody.AngularDamping = subElement.GetAttributeFloat("angulardamping", 0.2f);
|
||||
body.FarseerBody.LinearDamping = subElement.GetAttributeFloat("lineardamping", 0.1f);
|
||||
buoyancySineMagnitude = subElement.GetAttributeFloat("buoyancysinemagnitude", 0f);
|
||||
buoyancySineFrequency = subElement.GetAttributeFloat("buoyancysinefrequency", 0f);
|
||||
buoyancyRandomForce = subElement.GetAttributeFloat("buoyancyrandom", 0f);
|
||||
body.UserData = this;
|
||||
break;
|
||||
case "trigger":
|
||||
@@ -1716,7 +1729,7 @@ namespace Barotrauma
|
||||
UpdateNetPosition(deltaTime);
|
||||
if (inWater)
|
||||
{
|
||||
ApplyWaterForces();
|
||||
ApplyWaterForces(deltaTime);
|
||||
CurrentHull?.ApplyFlowForces(deltaTime, this);
|
||||
}
|
||||
}
|
||||
@@ -1805,16 +1818,24 @@ namespace Barotrauma
|
||||
transformDirty = false;
|
||||
}
|
||||
|
||||
private float sineTime;
|
||||
/// <summary>
|
||||
/// Applies buoyancy, drag and angular drag caused by water
|
||||
/// </summary>
|
||||
private void ApplyWaterForces()
|
||||
private void ApplyWaterForces(float deltaTime)
|
||||
{
|
||||
if (body.Mass <= 0.0f || body.Density <= 0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (buoyancySineFrequency > 0)
|
||||
{
|
||||
if (sineTime >= float.MaxValue)
|
||||
{
|
||||
sineTime = float.MinValue;
|
||||
}
|
||||
sineTime += deltaTime * buoyancySineFrequency;
|
||||
}
|
||||
float forceFactor = 1.0f;
|
||||
if (CurrentHull != null)
|
||||
{
|
||||
@@ -1833,7 +1854,10 @@ namespace Barotrauma
|
||||
|
||||
Vector2 drag = body.LinearVelocity * volume;
|
||||
|
||||
body.ApplyForce((uplift - drag) * 10.0f);
|
||||
float sine = (float)Math.Sin(sineTime) * buoyancySineMagnitude;
|
||||
Vector2 sineForce = Vector2.UnitY * sine * volume;
|
||||
Vector2 randomForce = Vector2.UnitY * Rand.Range(-buoyancyRandomForce, buoyancyRandomForce, Rand.RandSync.Unsynced) * volume;
|
||||
body.ApplyForce((uplift - drag) * 10.0f + sineForce + randomForce);
|
||||
|
||||
//apply simple angular drag
|
||||
body.ApplyTorque(body.AngularVelocity * volume * -0.05f);
|
||||
@@ -1971,7 +1995,7 @@ namespace Barotrauma
|
||||
return connectedComponents;
|
||||
}
|
||||
|
||||
private void GetConnectedComponentsRecursive<T>(HashSet<Connection> alreadySearched, List<T> connectedComponents) where T : ItemComponent
|
||||
private void GetConnectedComponentsRecursive<T>(HashSet<Connection> alreadySearched, List<T> connectedComponents, bool ignoreInactiveRelays = false) where T : ItemComponent
|
||||
{
|
||||
ConnectionPanel connectionPanel = GetComponent<ConnectionPanel>();
|
||||
if (connectionPanel == null) { return; }
|
||||
@@ -1980,18 +2004,18 @@ namespace Barotrauma
|
||||
{
|
||||
if (alreadySearched.Contains(c)) { continue; }
|
||||
alreadySearched.Add(c);
|
||||
GetConnectedComponentsRecursive(c, alreadySearched, connectedComponents);
|
||||
GetConnectedComponentsRecursive(c, alreadySearched, connectedComponents, ignoreInactiveRelays);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Note: This function generates garbage and might be a bit too heavy to be used once per frame.
|
||||
/// </summary>
|
||||
public List<T> GetConnectedComponentsRecursive<T>(Connection c) where T : ItemComponent
|
||||
public List<T> GetConnectedComponentsRecursive<T>(Connection c, bool ignoreInactiveRelays = false) where T : ItemComponent
|
||||
{
|
||||
List<T> connectedComponents = new List<T>();
|
||||
HashSet<Connection> alreadySearched = new HashSet<Connection>();
|
||||
GetConnectedComponentsRecursive(c, alreadySearched, connectedComponents);
|
||||
GetConnectedComponentsRecursive(c, alreadySearched, connectedComponents, ignoreInactiveRelays);
|
||||
|
||||
return connectedComponents;
|
||||
}
|
||||
@@ -2008,7 +2032,7 @@ namespace Barotrauma
|
||||
("signal_in2", "signal_out")
|
||||
};
|
||||
|
||||
private void GetConnectedComponentsRecursive<T>(Connection c, HashSet<Connection> alreadySearched, List<T> connectedComponents) where T : ItemComponent
|
||||
private void GetConnectedComponentsRecursive<T>(Connection c, HashSet<Connection> alreadySearched, List<T> connectedComponents, bool ignoreInactiveRelays) where T : ItemComponent
|
||||
{
|
||||
alreadySearched.Add(c);
|
||||
|
||||
@@ -2033,12 +2057,18 @@ namespace Barotrauma
|
||||
foreach (Connection wifiOutput in receiverConnections)
|
||||
{
|
||||
if ((wifiOutput.IsOutput == recipient.IsOutput) || alreadySearched.Contains(wifiOutput)) { continue; }
|
||||
GetConnectedComponentsRecursive(wifiOutput, alreadySearched, connectedComponents);
|
||||
GetConnectedComponentsRecursive(wifiOutput, alreadySearched, connectedComponents, ignoreInactiveRelays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recipient.Item.GetConnectedComponentsRecursive(recipient, alreadySearched, connectedComponents);
|
||||
recipient.Item.GetConnectedComponentsRecursive(recipient, alreadySearched, connectedComponents, ignoreInactiveRelays);
|
||||
}
|
||||
|
||||
if (ignoreInactiveRelays)
|
||||
{
|
||||
var relay = GetComponent<RelayComponent>();
|
||||
if (relay != null && !relay.IsOn) { return; }
|
||||
}
|
||||
|
||||
foreach ((string input, string output) in connectionPairs)
|
||||
@@ -2049,7 +2079,7 @@ namespace Barotrauma
|
||||
if (pairedConnection != null)
|
||||
{
|
||||
if (alreadySearched.Contains(pairedConnection)) { continue; }
|
||||
GetConnectedComponentsRecursive(pairedConnection, alreadySearched, connectedComponents);
|
||||
GetConnectedComponentsRecursive(pairedConnection, alreadySearched, connectedComponents, ignoreInactiveRelays);
|
||||
}
|
||||
}
|
||||
else if (output == c.Name)
|
||||
@@ -2058,7 +2088,7 @@ namespace Barotrauma
|
||||
if (pairedConnection != null)
|
||||
{
|
||||
if (alreadySearched.Contains(pairedConnection)) { continue; }
|
||||
GetConnectedComponentsRecursive(pairedConnection, alreadySearched, connectedComponents);
|
||||
GetConnectedComponentsRecursive(pairedConnection, alreadySearched, connectedComponents, ignoreInactiveRelays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user