Unstable 0.17.1.0

This commit is contained in:
Markus Isberg
2022-03-17 01:25:04 +09:00
parent 3974067915
commit 6d410cc1b7
302 changed files with 5878 additions and 3317 deletions
@@ -370,7 +370,10 @@ namespace Barotrauma.Items.Components
public Item GetFocusTarget()
{
item.SendSignal(new Signal(MathHelper.ToDegrees(targetRotation).ToString("G", CultureInfo.InvariantCulture), sender: user), "position_out");
var positionOut = item.Connections.Find(c => c.Name == "position_out");
if (positionOut == null) { return null; }
item.SendSignal(new Signal(MathHelper.ToDegrees(targetRotation).ToString("G", CultureInfo.InvariantCulture), sender: user), positionOut);
for (int i = item.LastSentSignalRecipients.Count - 1; i >= 0; i--)
{
@@ -380,7 +383,16 @@ namespace Barotrauma.Items.Components
return item.LastSentSignalRecipients[i].Item;
}
}
foreach (var recipientPanel in item.GetConnectedComponentsRecursive<ConnectionPanel>(positionOut, allowTraversingBackwards: false))
{
if (recipientPanel.Item.Condition <= 0.0f) { continue; }
if (recipientPanel.Item.Prefab.FocusOnSelected)
{
return recipientPanel.Item;
}
}
return null;
}
@@ -221,7 +221,7 @@ namespace Barotrauma.Items.Components
}
float condition = deconstructProduct.CopyCondition ?
percentageHealth * itemPrefab.Health :
percentageHealth * itemPrefab.Health * deconstructProduct.OutConditionMax :
itemPrefab.Health * Rand.Range(deconstructProduct.OutConditionMin, deconstructProduct.OutConditionMax);
if (DeconstructItemsSimultaneously && deconstructProduct.RequiredOtherItem.Length > 0)
@@ -354,7 +354,14 @@ namespace Barotrauma.Items.Components
{
foreach (Item containedItem in availableItem.OwnInventory.AllItemsMod)
{
containedItem.Drop(dropper: null);
if (availableItem.GetComponent<ItemContainer>()?.RemoveContainedItemsOnDeconstruct ?? false)
{
Entity.Spawner.AddItemToRemoveQueue(containedItem);
}
else
{
containedItem.Drop(dropper: null);
}
}
}
@@ -169,7 +169,7 @@ namespace Barotrauma.Items.Components
hull.BallastFlora = new BallastFloraBehavior(hull, ballastFloraPrefab, offset, firstGrowth: true);
#if SERVER
hull.BallastFlora.SendNetworkMessage(hull.BallastFlora, BallastFloraBehavior.NetworkHeader.Spawn);
hull.BallastFlora.SendNetworkMessage(new BallastFloraBehavior.SpawnEventData());
#endif
}
@@ -1,11 +1,9 @@
using Barotrauma.Networking;
using Barotrauma.Extensions;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Extensions;
using System.Globalization;
using System.Linq;
namespace Barotrauma.Items.Components
{
@@ -287,7 +285,7 @@ namespace Barotrauma.Items.Components
}
else if (autoTemp)
{
UpdateAutoTemp(10.0f, deltaTime * 2f);
UpdateAutoTemp(2.0f, deltaTime);
}
@@ -300,7 +298,14 @@ namespace Barotrauma.Items.Components
if (!item.HasTag("reactorfuel")) { continue; }
if (fissionRate > 0.0f)
{
item.Condition -= fissionRate / 100.0f * fuelConsumptionRate * deltaTime;
bool isConnectedToFriendlyOutpost = Level.IsLoadedOutpost &&
Item.Submarine?.TeamID == CharacterTeamType.Team1 &&
Item.Submarine.GetConnectedSubs().Any(s => s.Info.IsOutpost && s.TeamID == CharacterTeamType.FriendlyNPC);
if (!isConnectedToFriendlyOutpost)
{
item.Condition -= fissionRate / 100.0f * fuelConsumptionRate * deltaTime;
}
}
fuelLeft += item.ConditionPercentage;
}
@@ -418,7 +423,7 @@ namespace Barotrauma.Items.Components
{
float idealLoad = MaxPowerOutput / minMaxPower.ReactorMaxOutput * loadLeft;
float loadAdjust = MathHelper.Clamp((ratio - 0.5f) * 25 + idealLoad - (turbineOutput / 100 * MaxPowerOutput), -MaxPowerOutput / 100, MaxPowerOutput / 100);
newLoad = MathHelper.Clamp(loadLeft - (expectedPower + output) + loadAdjust, 0, loadLeft);
newLoad = MathHelper.Clamp(loadLeft - (expectedPower - output) + loadAdjust, 0, loadLeft);
}
if (float.IsNegative(newLoad))
@@ -498,7 +503,6 @@ namespace Barotrauma.Items.Components
if (temperature > optimalTemperature.Y)
{
float prevFireTimer = fireTimer;
fireTimer += MathHelper.Lerp(deltaTime * 2.0f, deltaTime, item.Condition / item.MaxCondition);
#if SERVER
if (fireTimer > Math.Min(5.0f, FireDelay / 2) && blameOnBroken?.Character?.SelectedConstruction == item)
@@ -506,9 +510,10 @@ namespace Barotrauma.Items.Components
GameMain.Server.KarmaManager.OnReactorOverHeating(item, blameOnBroken.Character, deltaTime);
}
#endif
if (fireTimer >= FireDelay && prevFireTimer < fireDelay)
if (fireTimer >= FireDelay)
{
new FireSource(item.WorldPosition);
fireTimer = 0.0f;
}
}
else
@@ -349,7 +349,7 @@ namespace Barotrauma.Items.Components
}
}
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
public void ServerEventRead(IReadMessage msg, Client c)
{
bool isActive = msg.ReadBoolean();
bool directionalPing = useDirectionalPing;
@@ -394,7 +394,7 @@ namespace Barotrauma.Items.Components
#endif
}
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
{
msg.Write(currentMode == Mode.Active);
if (currentMode == Mode.Active)
@@ -225,7 +225,7 @@ namespace Barotrauma.Items.Components
var dockingConnection = item.Connections.FirstOrDefault(c => c.Name == "toggle_docking");
if (dockingConnection != null)
{
var connectedPorts = item.GetConnectedComponentsRecursive<DockingPort>(dockingConnection);
var connectedPorts = item.GetConnectedComponentsRecursive<DockingPort>(dockingConnection, allowTraversingBackwards: false);
DockingSources.AddRange(connectedPorts.Where(p => p.Item.Submarine != null && !p.Item.Submarine.Info.IsOutpost));
}
}
@@ -271,13 +271,9 @@ namespace Barotrauma.Items.Components
item.CreateClientEvent(this);
correctionTimer = CorrectionDelay;
}
else
#endif
#if SERVER
if (GameMain.Server != null)
{
item.CreateServerEvent(this);
}
item.CreateServerEvent(this);
#endif
networkUpdateTimer = 0.1f;