Build 0.20.9.0
This commit is contained in:
@@ -51,7 +51,7 @@ namespace Barotrauma
|
||||
return slotString == null ? Array.Empty<string>() : slotString.Split(',');
|
||||
}
|
||||
|
||||
public CharacterInventory(XElement element, Character character)
|
||||
public CharacterInventory(XElement element, Character character, bool spawnInitialItems)
|
||||
: base(character, ParseSlotTypes(element).Length)
|
||||
{
|
||||
this.character = character;
|
||||
@@ -84,6 +84,8 @@ namespace Barotrauma
|
||||
|
||||
InitProjSpecific(element);
|
||||
|
||||
if (!spawnInitialItems) { return; }
|
||||
|
||||
#if CLIENT
|
||||
//clients don't create items until the server says so
|
||||
if (GameMain.Client != null) { return; }
|
||||
@@ -94,7 +96,7 @@ namespace Barotrauma
|
||||
if (!subElement.Name.ToString().Equals("item", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
|
||||
string itemIdentifier = subElement.GetAttributeString("identifier", "");
|
||||
if (!(MapEntityPrefab.Find(null, itemIdentifier) is ItemPrefab itemPrefab))
|
||||
if (!ItemPrefab.Prefabs.TryGet(itemIdentifier, out var itemPrefab))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in character inventory \"" + character.SpeciesName + "\" - item \"" + itemIdentifier + "\" not found.");
|
||||
continue;
|
||||
@@ -200,6 +202,7 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
CreateSlots();
|
||||
#endif
|
||||
CharacterHUD.RecreateHudTextsIfControlling(character);
|
||||
//if the item was equipped and there are more items in the same stack, equip one of those items
|
||||
if (tryEquipFromSameStack && wasEquipped)
|
||||
{
|
||||
@@ -498,6 +501,7 @@ namespace Barotrauma
|
||||
HintManager.OnObtainedItem(character, item);
|
||||
}
|
||||
#endif
|
||||
CharacterHUD.RecreateHudTextsIfControlling(character);
|
||||
if (item.CampaignInteractionType == CampaignMode.InteractionType.Cargo)
|
||||
{
|
||||
item.CampaignInteractionType = CampaignMode.InteractionType.None;
|
||||
|
||||
@@ -47,6 +47,13 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
return ContainableItems == null || ContainableItems.Count == 0 || ContainableItems.Any(c => c.MatchesItem(itemPrefab));
|
||||
}
|
||||
|
||||
public bool MatchesItem(Identifier identifierOrTag)
|
||||
{
|
||||
return
|
||||
ContainableItems == null || ContainableItems.Count == 0 ||
|
||||
ContainableItems.Any(c => c.Identifiers.Contains(identifierOrTag) && !c.ExcludedIdentifiers.Contains(identifierOrTag));
|
||||
}
|
||||
}
|
||||
|
||||
public readonly NamedEvent<ItemContainer> OnContainedItemsChanged = new NamedEvent<ItemContainer>();
|
||||
@@ -374,7 +381,7 @@ namespace Barotrauma.Items.Components
|
||||
// Set the contained items active if there's an item inserted inside the container. Enables e.g. the rifle flashlight when it's attached to the rifle (put inside of it).
|
||||
SetContainedActive(true);
|
||||
}
|
||||
|
||||
CharacterHUD.RecreateHudTextsIfFocused(item, containedItem);
|
||||
OnContainedItemsChanged.Invoke(this);
|
||||
}
|
||||
|
||||
@@ -386,9 +393,9 @@ namespace Barotrauma.Items.Components
|
||||
public void OnItemRemoved(Item containedItem)
|
||||
{
|
||||
activeContainedItems.RemoveAll(i => i.Item == containedItem);
|
||||
|
||||
//deactivate if the inventory is empty
|
||||
IsActive = activeContainedItems.Count > 0 || Inventory.AllItems.Any(it => it.body != null);
|
||||
CharacterHUD.RecreateHudTextsIfFocused(item, containedItem);
|
||||
OnContainedItemsChanged.Invoke(this);
|
||||
}
|
||||
|
||||
@@ -664,6 +671,18 @@ namespace Barotrauma.Items.Components
|
||||
return relatedItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the first slot whose restrictions match the specified tag or identifier
|
||||
/// </summary>
|
||||
public int? FindSuitableSubContainerIndex(Identifier itemTagOrIdentifier)
|
||||
{
|
||||
for (int i = 0; i < slotRestrictions.Length; i++)
|
||||
{
|
||||
if (slotRestrictions[i].MatchesItem(itemTagOrIdentifier)) { return i; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(Signal signal, Connection connection)
|
||||
{
|
||||
switch (connection.Name)
|
||||
|
||||
@@ -603,6 +603,13 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
partial void UpdateRequiredTimeProjSpecific();
|
||||
|
||||
private static bool AnyOneHasRecipeForItem(Character user, ItemPrefab item)
|
||||
{
|
||||
return
|
||||
(user != null && user.HasRecipeForItem(item.Identifier)) ||
|
||||
GameSession.GetSessionCrewCharacters(CharacterType.Bot).Any(c => c.HasRecipeForItem(item.Identifier));
|
||||
}
|
||||
|
||||
private bool CanBeFabricated(FabricationRecipe fabricableItem, IReadOnlyDictionary<Identifier, List<Item>> availableIngredients, Character character)
|
||||
{
|
||||
@@ -610,8 +617,7 @@ namespace Barotrauma.Items.Components
|
||||
if (fabricableItem.RequiresRecipe)
|
||||
{
|
||||
if (character == null) { return false; }
|
||||
if (!character.HasRecipeForItem(fabricableItem.TargetItem.Identifier) &&
|
||||
GameSession.GetSessionCrewCharacters(CharacterType.Bot).None(c => c.HasRecipeForItem(fabricableItem.TargetItem.Identifier)))
|
||||
if (!AnyOneHasRecipeForItem(character, fabricableItem.TargetItem))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -678,9 +684,10 @@ namespace Barotrauma.Items.Components
|
||||
//fabricating takes 100 times longer if degree of success is close to 0
|
||||
//characters with a higher skill than required can fabricate up to 100% faster
|
||||
float time = fabricableItem.RequiredTime / item.StatManager.GetAdjustedValue(ItemTalentStats.FabricationSpeed, FabricationSpeed) / MathHelper.Clamp(t, 0.01f, 2.0f);
|
||||
if (user is not null && fabricableItem.TargetItem is { } it && it.Tags.Contains("medical"))
|
||||
|
||||
if (user?.Info is { } info && fabricableItem.TargetItem is { } it)
|
||||
{
|
||||
time *= 1f + user.GetStatValue(StatTypes.FabricateMedicineSpeedMultiplier);
|
||||
time /= 1f + it.Tags.Sum(tag => info.GetSavedStatValue(StatTypes.FabricationSpeed, tag));
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,8 @@ namespace Barotrauma.Items.Components
|
||||
public List<Hull> LinkedHulls = new List<Hull>();
|
||||
}
|
||||
|
||||
private DateTime resetDataTime;
|
||||
|
||||
private bool hasPower;
|
||||
|
||||
private readonly Dictionary<Hull, HullData> hullDatas;
|
||||
|
||||
[Editable, Serialize(false, IsPropertySaveable.Yes, description: "Does the machine require inputs from water detectors in order to show the water levels inside rooms.")]
|
||||
public bool RequireWaterDetectors
|
||||
{
|
||||
@@ -77,7 +73,6 @@ namespace Barotrauma.Items.Components
|
||||
: base(item, element)
|
||||
{
|
||||
IsActive = true;
|
||||
hullDatas = new Dictionary<Hull, HullData>();
|
||||
InitProjSpecific();
|
||||
}
|
||||
|
||||
@@ -85,37 +80,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
//reset data if we haven't received anything in a while
|
||||
//(so that outdated hull info won't be shown if detectors stop sending signals)
|
||||
if (DateTime.Now > resetDataTime)
|
||||
{
|
||||
foreach (HullData hullData in hullDatas.Values)
|
||||
{
|
||||
if (!hullData.Distort)
|
||||
{
|
||||
if (Timing.TotalTime > hullData.LastOxygenDataTime + 1.0) { hullData.ReceivedOxygenAmount = null; }
|
||||
if (Timing.TotalTime > hullData.LastWaterDataTime + 1.0) { hullData.ReceivedWaterAmount = null; }
|
||||
}
|
||||
}
|
||||
resetDataTime = DateTime.Now + new TimeSpan(0, 0, 1);
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
if (cardRefreshTimer > cardRefreshDelay)
|
||||
{
|
||||
if (item.Submarine is { } sub)
|
||||
{
|
||||
UpdateIDCards(sub);
|
||||
}
|
||||
|
||||
cardRefreshTimer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cardRefreshTimer += deltaTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
hasPower = Voltage > MinVoltage;
|
||||
if (hasPower)
|
||||
{
|
||||
@@ -140,67 +104,5 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
return picker != null;
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(Signal signal, Connection connection)
|
||||
{
|
||||
Item source = signal.source;
|
||||
if (source == null || source.CurrentHull == null) { return; }
|
||||
|
||||
Hull sourceHull = source.CurrentHull;
|
||||
if (!hullDatas.TryGetValue(sourceHull, out HullData hullData))
|
||||
{
|
||||
hullData = new HullData();
|
||||
hullDatas.Add(sourceHull, hullData);
|
||||
}
|
||||
|
||||
if (hullData.Distort) { return; }
|
||||
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "water_data_in":
|
||||
//cheating a bit because water detectors don't actually send the water level
|
||||
bool fromWaterDetector = source.GetComponent<WaterDetector>() != null;
|
||||
hullData.ReceivedWaterAmount = null;
|
||||
hullData.LastWaterDataTime = Timing.TotalTime;
|
||||
if (fromWaterDetector)
|
||||
{
|
||||
hullData.ReceivedWaterAmount = WaterDetector.GetWaterPercentage(sourceHull);
|
||||
}
|
||||
foreach (var linked in sourceHull.linkedTo)
|
||||
{
|
||||
if (!(linked is Hull linkedHull)) { continue; }
|
||||
if (!hullDatas.TryGetValue(linkedHull, out HullData linkedHullData))
|
||||
{
|
||||
linkedHullData = new HullData();
|
||||
hullDatas.Add(linkedHull, linkedHullData);
|
||||
}
|
||||
linkedHullData.ReceivedWaterAmount = null;
|
||||
if (fromWaterDetector)
|
||||
{
|
||||
linkedHullData.ReceivedWaterAmount = WaterDetector.GetWaterPercentage(linkedHull);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "oxygen_data_in":
|
||||
if (!float.TryParse(signal.value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out float oxy))
|
||||
{
|
||||
oxy = Rand.Range(0.0f, 100.0f);
|
||||
}
|
||||
hullData.ReceivedOxygenAmount = oxy;
|
||||
hullData.LastOxygenDataTime = Timing.TotalTime;
|
||||
foreach (var linked in sourceHull.linkedTo)
|
||||
{
|
||||
if (linked is not Hull linkedHull) { continue; }
|
||||
if (!hullDatas.TryGetValue(linkedHull, out HullData linkedHullData))
|
||||
{
|
||||
linkedHullData = new HullData();
|
||||
hullDatas.Add(linkedHull, linkedHullData);
|
||||
}
|
||||
linkedHullData.ReceivedOxygenAmount = oxy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
const float NetworkUpdateIntervalHigh = 0.5f;
|
||||
|
||||
const float TemperatureBoostAmount = 20;
|
||||
const float TemperatureBoostAmount = 25;
|
||||
|
||||
//the rate at which the reactor is being run on (higher rate -> higher temperature)
|
||||
private float fissionRate;
|
||||
@@ -26,10 +26,6 @@ namespace Barotrauma.Items.Components
|
||||
//amount of power generated balanced with the load)
|
||||
private bool autoTemp;
|
||||
|
||||
//automatical adjustment to the power output when
|
||||
//turbine output and temperature are in the optimal range
|
||||
private float autoAdjustAmount;
|
||||
|
||||
private float fuelConsumptionRate;
|
||||
|
||||
private float meltDownTimer, meltDownDelay;
|
||||
@@ -53,6 +49,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private float temperatureBoost;
|
||||
|
||||
public bool AllowTemperatureBoost => Math.Abs(temperatureBoost) < TemperatureBoostAmount * 0.9f;
|
||||
|
||||
private bool _powerOn;
|
||||
|
||||
[Serialize(defaultValue: false, isSaveable: IsPropertySaveable.Yes)]
|
||||
@@ -314,7 +312,7 @@ namespace Barotrauma.Items.Components
|
||||
Temperature += MathHelper.Clamp(Math.Sign(temperatureDiff) * 10.0f * deltaTime, -Math.Abs(temperatureDiff), Math.Abs(temperatureDiff));
|
||||
temperatureBoost = adjustValueWithoutOverShooting(temperatureBoost, 0.0f, deltaTime);
|
||||
#if CLIENT
|
||||
temperatureBoostUpButton.Enabled = temperatureBoostDownButton.Enabled = Math.Abs(temperatureBoost) < TemperatureBoostAmount * 0.9f;
|
||||
temperatureBoostUpButton.Enabled = temperatureBoostDownButton.Enabled = AllowTemperatureBoost;
|
||||
#endif
|
||||
|
||||
FissionRate = MathHelper.Lerp(fissionRate, Math.Min(TargetFissionRate, AvailableFuel), deltaTime);
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (container?.Inventory == null) { return; }
|
||||
|
||||
bool recreateHudTexts = false;
|
||||
for (var i = 0; i < container.Inventory.Capacity; i++)
|
||||
{
|
||||
if (i < 0 || GrowableSeeds.Length <= i) { continue; }
|
||||
@@ -257,6 +258,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (growable != null)
|
||||
{
|
||||
recreateHudTexts |= GrowableSeeds[i] != growable;
|
||||
GrowableSeeds[i] = growable;
|
||||
growable.IsActive = true;
|
||||
}
|
||||
@@ -267,11 +269,14 @@ namespace Barotrauma.Items.Components
|
||||
// Kill the plant if it's somehow removed
|
||||
oldGrowable.Decayed = true;
|
||||
oldGrowable.IsActive = false;
|
||||
recreateHudTexts = true;
|
||||
}
|
||||
|
||||
GrowableSeeds[i] = null;
|
||||
}
|
||||
}
|
||||
#if CLIENT
|
||||
CharacterHUD.RecreateHudTexts |= recreateHudTexts;
|
||||
#endif
|
||||
|
||||
// server handles this
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
//[power/min]
|
||||
private float capacity;
|
||||
private float adjustedCapacity;
|
||||
|
||||
private float charge, prevCharge;
|
||||
|
||||
@@ -66,7 +67,11 @@ namespace Barotrauma.Items.Components
|
||||
public float Capacity
|
||||
{
|
||||
get => capacity;
|
||||
set { capacity = Math.Max(value, 1.0f); }
|
||||
set
|
||||
{
|
||||
capacity = Math.Max(value, 1.0f);
|
||||
adjustedCapacity = GetCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
[Editable, Serialize(0.0f, IsPropertySaveable.Yes, description: "The current charge of the device.")]
|
||||
@@ -76,10 +81,10 @@ namespace Barotrauma.Items.Components
|
||||
set
|
||||
{
|
||||
if (!MathUtils.IsValid(value)) return;
|
||||
charge = MathHelper.Clamp(value, 0.0f, capacity);
|
||||
charge = MathHelper.Clamp(value, 0.0f, adjustedCapacity);
|
||||
|
||||
//send a network event if the charge has changed by more than 5%
|
||||
if (Math.Abs(charge - lastSentCharge) / capacity > 0.05f)
|
||||
if (Math.Abs(charge - lastSentCharge) / adjustedCapacity > 0.05f)
|
||||
{
|
||||
#if SERVER
|
||||
if (GameMain.Server != null && (!item.Submarine?.Loading ?? true)) { item.CreateServerEvent(this); }
|
||||
@@ -89,7 +94,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public float ChargePercentage => MathUtils.Percentage(Charge, GetCapacity());
|
||||
public float ChargePercentage => MathUtils.Percentage(Charge, adjustedCapacity);
|
||||
|
||||
[Editable, Serialize(10.0f, IsPropertySaveable.Yes, description: "How fast the device can be recharged. For example, a recharge speed of 100 kW and a capacity of 1000 kW*min would mean it takes 10 minutes to fully charge the device.")]
|
||||
public float MaxRechargeSpeed
|
||||
@@ -157,6 +162,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
adjustedCapacity = GetCapacity();
|
||||
if (item.Connections == null)
|
||||
{
|
||||
IsActive = false;
|
||||
@@ -164,7 +170,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
isRunning = true;
|
||||
float chargeRatio = charge / capacity;
|
||||
float chargeRatio = charge / adjustedCapacity;
|
||||
|
||||
if (chargeRatio > 0.0f)
|
||||
{
|
||||
@@ -180,7 +186,7 @@ namespace Barotrauma.Items.Components
|
||||
item.SendSignal(((int)Math.Round(CurrPowerOutput)).ToString(), "power_value_out");
|
||||
item.SendSignal(((int)Math.Round(loadReading)).ToString(), "load_value_out");
|
||||
item.SendSignal(((int)Math.Round(Charge)).ToString(), "charge");
|
||||
item.SendSignal(((int)Math.Round(Charge / capacity * 100)).ToString(), "charge_%");
|
||||
item.SendSignal(((int)Math.Round(Charge / adjustedCapacity * 100)).ToString(), "charge_%");
|
||||
item.SendSignal(((int)Math.Round(RechargeSpeed / maxRechargeSpeed * 100)).ToString(), "charge_rate");
|
||||
}
|
||||
|
||||
@@ -193,16 +199,16 @@ namespace Barotrauma.Items.Components
|
||||
if (connection == powerIn)
|
||||
{
|
||||
//Don't draw power if fully charged
|
||||
if (charge >= capacity)
|
||||
if (charge >= adjustedCapacity)
|
||||
{
|
||||
charge = capacity;
|
||||
charge = adjustedCapacity;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Condition <= 0.0f) { return 0.0f; }
|
||||
|
||||
float missingCharge = capacity - charge;
|
||||
float missingCharge = adjustedCapacity - charge;
|
||||
float targetRechargeSpeed = rechargeSpeed;
|
||||
|
||||
if (ExponentialRechargeSpeed)
|
||||
@@ -239,7 +245,7 @@ namespace Barotrauma.Items.Components
|
||||
if (connection == powerOut)
|
||||
{
|
||||
float maxOutput;
|
||||
float chargeRatio = prevCharge / capacity;
|
||||
float chargeRatio = prevCharge / adjustedCapacity;
|
||||
if (chargeRatio < 0.1f)
|
||||
{
|
||||
maxOutput = Math.Max(chargeRatio * 10.0f, 0.0f) * MaxOutPut;
|
||||
@@ -292,7 +298,7 @@ namespace Barotrauma.Items.Components
|
||||
else
|
||||
{
|
||||
//Decrease charge based on how much power is leaving the device
|
||||
Charge = Math.Clamp(Charge - CurrPowerOutput / 60 * UpdateInterval, 0, GetCapacity());
|
||||
Charge = Math.Clamp(Charge - CurrPowerOutput / 60 * UpdateInterval, 0, adjustedCapacity);
|
||||
prevCharge = Charge;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,13 +639,16 @@ namespace Barotrauma.Items.Components
|
||||
ItemContainer projectileContainer = projectiles.First().Item.Container?.GetComponent<ItemContainer>();
|
||||
if (projectileContainer != null && projectileContainer.Item != item)
|
||||
{
|
||||
projectileContainer.Item.Use(deltaTime, null);
|
||||
//Use root container (e.g. loader) too in case it needs to react to firing somehow
|
||||
var rootContainer = projectileContainer.Item.GetRootContainer();
|
||||
if (rootContainer != projectileContainer.Item)
|
||||
if (rootContainer != null && rootContainer != projectileContainer.Item)
|
||||
{
|
||||
rootContainer.Use(deltaTime, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectileContainer.Item.Use(deltaTime, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -576,11 +576,13 @@ namespace Barotrauma
|
||||
if (selectedSlot?.Inventory == this) { selectedSlot.ForceTooltipRefresh = true; }
|
||||
}
|
||||
#endif
|
||||
CharacterHUD.RecreateHudTextsIfControlling(user);
|
||||
|
||||
if (item.body != null)
|
||||
{
|
||||
item.body.Enabled = false;
|
||||
item.body.BodyType = FarseerPhysics.BodyType.Dynamic;
|
||||
item.SetTransform(item.SimPosition, rotation: 0.0f, findNewHull: false);
|
||||
}
|
||||
|
||||
#if SERVER
|
||||
@@ -924,6 +926,7 @@ namespace Barotrauma
|
||||
if (selectedSlot?.Inventory == this) { selectedSlot.ForceTooltipRefresh = true; }
|
||||
}
|
||||
#endif
|
||||
CharacterHUD.RecreateHudTextsIfFocused(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1092,6 +1092,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var holdables = components.Where(c => c is Holdable);
|
||||
if (holdables.Count() > 1)
|
||||
{
|
||||
DebugConsole.AddWarning($"Item {Prefab.Identifier} has multiple {nameof(Holdable)} components ({string.Join(", ", holdables.Select(h => h.GetType().Name))}).");
|
||||
}
|
||||
|
||||
InsertToList();
|
||||
ItemList.Add(this);
|
||||
if (Prefab.IsDangerous) { dangerousItems.Add(this); }
|
||||
@@ -1104,7 +1110,6 @@ namespace Barotrauma
|
||||
if (HasTag("logic")) { isLogic = true; }
|
||||
|
||||
ApplyStatusEffects(ActionType.OnSpawn, 1.0f);
|
||||
Components.ForEach(c => c.ApplyStatusEffects(ActionType.OnSpawn, 1.0f));
|
||||
RecalculateConditionValues();
|
||||
#if CLIENT
|
||||
Submarine.ForceVisibilityRecheck();
|
||||
@@ -2881,11 +2886,14 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components) { ic.Equip(character); }
|
||||
|
||||
CharacterHUD.RecreateHudTextsIfControlling(character);
|
||||
}
|
||||
|
||||
public void Unequip(Character character)
|
||||
{
|
||||
foreach (ItemComponent ic in components) { ic.Unequip(character); }
|
||||
CharacterHUD.RecreateHudTextsIfControlling(character);
|
||||
}
|
||||
|
||||
public List<(object obj, SerializableProperty property)> GetProperties<T>()
|
||||
@@ -3427,12 +3435,15 @@ namespace Barotrauma
|
||||
//if the item was in full condition considering the unmodified health
|
||||
//(not taking possible HealthMultipliers added by mods into account),
|
||||
//make sure it stays in full condition
|
||||
bool wasFullCondition = prevCondition >= item.Prefab.Health;
|
||||
if (wasFullCondition)
|
||||
if (item.condition > 0)
|
||||
{
|
||||
item.condition = item.MaxCondition;
|
||||
bool wasFullCondition = prevCondition >= item.Prefab.Health;
|
||||
if (wasFullCondition)
|
||||
{
|
||||
item.condition = item.MaxCondition;
|
||||
}
|
||||
item.condition = MathHelper.Clamp(item.condition, 0, item.MaxCondition);
|
||||
}
|
||||
item.condition = MathHelper.Clamp(item.condition, 0, item.MaxCondition);
|
||||
}
|
||||
item.lastSentCondition = item.condition;
|
||||
item.RecalculateConditionValues();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Barotrauma
|
||||
|
||||
public bool IgnoreInEditor { get; set; }
|
||||
|
||||
private ImmutableHashSet<Identifier> excludedIdentifiers;
|
||||
public ImmutableHashSet<Identifier> ExcludedIdentifiers { get; private set; }
|
||||
|
||||
private RelationType type;
|
||||
|
||||
@@ -87,20 +87,20 @@ namespace Barotrauma
|
||||
|
||||
public string JoinedExcludedIdentifiers
|
||||
{
|
||||
get { return string.Join(",", excludedIdentifiers); }
|
||||
get { return string.Join(",", ExcludedIdentifiers); }
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
|
||||
excludedIdentifiers = value.Split(',').Select(s => s.Trim()).ToIdentifiers().ToImmutableHashSet();
|
||||
ExcludedIdentifiers = value.Split(',').Select(s => s.Trim()).ToIdentifiers().ToImmutableHashSet();
|
||||
}
|
||||
}
|
||||
|
||||
public bool MatchesItem(Item item)
|
||||
{
|
||||
if (item == null) { return false; }
|
||||
if (excludedIdentifiers.Contains(item.Prefab.Identifier)) { return false; }
|
||||
foreach (var excludedIdentifier in excludedIdentifiers)
|
||||
if (ExcludedIdentifiers.Contains(item.Prefab.Identifier)) { return false; }
|
||||
foreach (var excludedIdentifier in ExcludedIdentifiers)
|
||||
{
|
||||
if (item.HasTag(excludedIdentifier)) { return false; }
|
||||
}
|
||||
@@ -118,8 +118,8 @@ namespace Barotrauma
|
||||
public bool MatchesItem(ItemPrefab itemPrefab)
|
||||
{
|
||||
if (itemPrefab == null) { return false; }
|
||||
if (excludedIdentifiers.Contains(itemPrefab.Identifier)) { return false; }
|
||||
foreach (var excludedIdentifier in excludedIdentifiers)
|
||||
if (ExcludedIdentifiers.Contains(itemPrefab.Identifier)) { return false; }
|
||||
foreach (var excludedIdentifier in ExcludedIdentifiers)
|
||||
{
|
||||
if (itemPrefab.Tags.Contains(excludedIdentifier)) { return false; }
|
||||
}
|
||||
@@ -138,7 +138,7 @@ namespace Barotrauma
|
||||
public RelatedItem(Identifier[] identifiers, Identifier[] excludedIdentifiers)
|
||||
{
|
||||
this.Identifiers = identifiers.Select(id => id.Value.Trim().ToIdentifier()).ToImmutableHashSet();
|
||||
this.excludedIdentifiers = excludedIdentifiers.Select(id => id.Value.Trim().ToIdentifier()).ToImmutableHashSet();
|
||||
this.ExcludedIdentifiers = excludedIdentifiers.Select(id => id.Value.Trim().ToIdentifier()).ToImmutableHashSet();
|
||||
|
||||
statusEffects = new List<StatusEffect>();
|
||||
}
|
||||
@@ -230,7 +230,7 @@ namespace Barotrauma
|
||||
element.Add(new XAttribute(nameof(ItemPos), ItemPos.Value));
|
||||
}
|
||||
|
||||
if (excludedIdentifiers.Count > 0)
|
||||
if (ExcludedIdentifiers.Count > 0)
|
||||
{
|
||||
element.Add(new XAttribute("excludedidentifiers", JoinedExcludedIdentifiers));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user