Build 0.17.13.0
This commit is contained in:
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -18,6 +17,8 @@ namespace Barotrauma.Items.Components
|
||||
const int MaxNodes = 100;
|
||||
const float MaxNodeDistance = 150.0f;
|
||||
|
||||
private bool waitForVoltageRecalculation;
|
||||
|
||||
public struct Node
|
||||
{
|
||||
public Vector2 WorldPosition;
|
||||
@@ -120,6 +121,7 @@ namespace Barotrauma.Items.Components
|
||||
CurrPowerConsumption = powerConsumption;
|
||||
Voltage = 0.0f;
|
||||
|
||||
waitForVoltageRecalculation = true;
|
||||
charging = true;
|
||||
timer = Duration;
|
||||
IsActive = true;
|
||||
@@ -134,6 +136,12 @@ namespace Barotrauma.Items.Components
|
||||
#if CLIENT
|
||||
frameOffset = Rand.Int(electricitySprite.FrameCount);
|
||||
#endif
|
||||
if (waitForVoltageRecalculation)
|
||||
{
|
||||
waitForVoltageRecalculation = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (timer <= 0.0f)
|
||||
{
|
||||
IsActive = false;
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
OwnerName = info.Name;
|
||||
OwnerJobId = info.Job?.Prefab.Identifier ?? Identifier.Empty;
|
||||
item.AddTag($"jobid:{OwnerJobId}");
|
||||
OwnerTagSet = info.Head.Preset.TagSet;
|
||||
OwnerHairIndex = head.HairIndex;
|
||||
OwnerBeardIndex = head.BeardIndex;
|
||||
|
||||
@@ -315,6 +315,15 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private Client GetUsingClient()
|
||||
{
|
||||
#if SERVER
|
||||
return GameMain.Server.ConnectedClients.Find(c => c.Character == user);
|
||||
#elif CLIENT
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Fabricate()
|
||||
{
|
||||
RefreshAvailableIngredients();
|
||||
@@ -327,9 +336,20 @@ namespace Barotrauma.Items.Components
|
||||
if (fabricatedItem.RequiredMoney > 0)
|
||||
{
|
||||
if (user == null) { return; }
|
||||
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign)
|
||||
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign mpCampaign)
|
||||
{
|
||||
user.Wallet.Deduct(fabricatedItem.RequiredMoney);
|
||||
#if CLIENT
|
||||
mpCampaign.TryPurchase(null, fabricatedItem.RequiredMoney);
|
||||
#elif SERVER
|
||||
if (GetUsingClient() is { } client)
|
||||
{
|
||||
mpCampaign.TryPurchase(client, fabricatedItem.RequiredMoney);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.Wallet.Deduct(fabricatedItem.RequiredMoney);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (GameMain.GameSession?.GameMode is CampaignMode campaign)
|
||||
{
|
||||
@@ -530,6 +550,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
floatQuality += user.Info.GetSavedStatValue(StatTypes.IncreaseFabricationQuality, tag);
|
||||
}
|
||||
if (!fabricatedItem.TargetItem.Tags.Contains(fabricatedItem.TargetItem.Identifier))
|
||||
{
|
||||
floatQuality += user.Info.GetSavedStatValue(StatTypes.IncreaseFabricationQuality, fabricatedItem.TargetItem.Identifier);
|
||||
}
|
||||
quality = (int)floatQuality;
|
||||
|
||||
const int MaxCraftingSkill = 100;
|
||||
@@ -548,17 +572,22 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (fabricableItem.RequiredMoney > 0)
|
||||
{
|
||||
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign)
|
||||
switch (GameMain.GameSession?.GameMode)
|
||||
{
|
||||
if (character?.Wallet == null || character.Wallet.Balance < fabricableItem.RequiredMoney) { return false; }
|
||||
}
|
||||
else if (GameMain.GameSession?.GameMode is CampaignMode campaign)
|
||||
{
|
||||
if (campaign.Bank.Balance < fabricableItem.RequiredMoney) { return false; }
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
case MultiPlayerCampaign mpCampaign:
|
||||
{
|
||||
if (!mpCampaign.CanAfford(fabricableItem.RequiredMoney, GetUsingClient())) { return false; }
|
||||
|
||||
break;
|
||||
}
|
||||
case CampaignMode campaign:
|
||||
{
|
||||
if (campaign.Bank.Balance < fabricableItem.RequiredMoney) { return false; }
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -565,16 +565,20 @@ namespace Barotrauma.Items.Components
|
||||
//Iterate through all connections in the group to get their minmax power and sum them
|
||||
foreach (Connection c in scrGroup.Connections)
|
||||
{
|
||||
Powered device = c.Item.GetComponent<Powered>();
|
||||
scrGroup.MinMaxPower += device.MinMaxPowerOut(c, grid.Load);
|
||||
foreach (var device in c.Item.GetComponents<Powered>())
|
||||
{
|
||||
scrGroup.MinMaxPower += device.MinMaxPowerOut(c, grid.Load);
|
||||
}
|
||||
}
|
||||
|
||||
//Iterate through all connections to get their final power out provided the min max information
|
||||
float addedPower = 0;
|
||||
foreach (Connection c in scrGroup.Connections)
|
||||
{
|
||||
Powered device = c.Item.GetComponent<Powered>();
|
||||
addedPower += device.GetConnectionPowerOut(c, grid.Power, scrGroup.MinMaxPower, grid.Load);
|
||||
foreach (var device in c.Item.GetComponents<Powered>())
|
||||
{
|
||||
addedPower += device.GetConnectionPowerOut(c, grid.Power, scrGroup.MinMaxPower, grid.Load);
|
||||
}
|
||||
}
|
||||
|
||||
//Add the power to the grid
|
||||
@@ -591,10 +595,12 @@ namespace Barotrauma.Items.Components
|
||||
grid.Voltage = newVoltage;
|
||||
|
||||
//Iterate through all connections on that grid and run their gridResolved function
|
||||
foreach (Connection con in grid.Connections)
|
||||
foreach (Connection c in grid.Connections)
|
||||
{
|
||||
Powered device = con.Item.GetComponent<Powered>();
|
||||
device?.GridResolved(con);
|
||||
foreach (var device in c.Item.GetComponents<Powered>())
|
||||
{
|
||||
device?.GridResolved(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user