Faction Test 100.13.0.0
This commit is contained in:
@@ -55,7 +55,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void DrawElectricity(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (timer <= 0.0f) { return; }
|
||||
if (timer <= 0.0f && Screen.Selected is { IsEditor: false }) { return; }
|
||||
for (int i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
if (nodes[i].Length <= 1.0f) { continue; }
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using static Barotrauma.Inventory;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -250,6 +252,83 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public float GetContainedIndicatorState()
|
||||
{
|
||||
if (ShowConditionInContainedStateIndicator)
|
||||
{
|
||||
return item.Condition / item.MaxCondition;
|
||||
}
|
||||
|
||||
int targetSlot = Math.Max(ContainedStateIndicatorSlot, 0);
|
||||
if (targetSlot >= Inventory.Capacity) { return 0.0f; }
|
||||
|
||||
var containedItems = Inventory.GetItemsAt(targetSlot);
|
||||
if (containedItems == null) { return 0.0f; }
|
||||
|
||||
Item containedItem = containedItems.FirstOrDefault();
|
||||
if (ShowTotalStackCapacityInContainedStateIndicator)
|
||||
{
|
||||
// No item on the defined slot, check if the items on other slots can be used.
|
||||
containedItem ??=
|
||||
containedItems.FirstOrDefault() ??
|
||||
Inventory.AllItems.FirstOrDefault(it => CanBeContained(it, targetSlot));
|
||||
if (containedItem == null) { return 0.0f; }
|
||||
|
||||
int ignoredItemCount = 0;
|
||||
var subContainableItems = AllSubContainableItems;
|
||||
float capacity = GetMaxStackSize(targetSlot);
|
||||
if (subContainableItems != null)
|
||||
{
|
||||
bool useMainContainerCapacity = true;
|
||||
foreach (Item it in Inventory.AllItems)
|
||||
{
|
||||
// Ignore all items in the sub containers.
|
||||
foreach (RelatedItem ri in subContainableItems)
|
||||
{
|
||||
if (ri.MatchesItem(containedItem))
|
||||
{
|
||||
// The target item is in a subcontainer -> inverse the logic.
|
||||
useMainContainerCapacity = false;
|
||||
break;
|
||||
}
|
||||
if (ri.MatchesItem(it))
|
||||
{
|
||||
ignoredItemCount++;
|
||||
}
|
||||
}
|
||||
if (!useMainContainerCapacity) { break; }
|
||||
}
|
||||
if (useMainContainerCapacity)
|
||||
{
|
||||
capacity *= MainContainerCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore all items in the main container.
|
||||
ignoredItemCount = Inventory.AllItems.Count(it => subContainableItems.Any(ri => !ri.MatchesItem(it)));
|
||||
capacity *= Capacity - MainContainerCapacity;
|
||||
}
|
||||
}
|
||||
int itemCount = Inventory.AllItems.Count() - ignoredItemCount;
|
||||
return Math.Min(itemCount / Math.Max(capacity, 1), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (containedItem != null && (Inventory.Capacity == 1 || HasSubContainers))
|
||||
{
|
||||
int maxStackSize = Math.Min(containedItem.Prefab.MaxStackSize, GetMaxStackSize(targetSlot));
|
||||
if (maxStackSize > 1 || containedItem.Prefab.HideConditionBar)
|
||||
{
|
||||
return containedItems.Count() / (float)maxStackSize;
|
||||
}
|
||||
}
|
||||
return Inventory.Capacity == 1 || ContainedStateIndicatorSlot > -1 ?
|
||||
(containedItem == null ? 0.0f : containedItem.Condition / containedItem.MaxCondition) :
|
||||
Inventory.EmptySlotCount / (float)Inventory.Capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
if (hideItems || (item.body != null && !item.body.Enabled)) { return; }
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace Barotrauma.Items.Components
|
||||
private CoroutineHandle resetPredictionCoroutine;
|
||||
private float resetPredictionTimer;
|
||||
|
||||
private float currentBrightness;
|
||||
|
||||
public Vector2 DrawSize
|
||||
{
|
||||
get { return new Vector2(Light.Range * 2, Light.Range * 2); }
|
||||
@@ -29,14 +27,21 @@ namespace Barotrauma.Items.Components
|
||||
Light.Position = ParentBody != null ? ParentBody.Position : item.Position;
|
||||
}
|
||||
|
||||
partial void SetLightSourceState(bool enabled, float brightness)
|
||||
partial void SetLightSourceState(bool enabled, float? brightness)
|
||||
{
|
||||
if (Light == null) { return; }
|
||||
Light.Enabled = enabled;
|
||||
currentBrightness = brightness;
|
||||
if (brightness.HasValue)
|
||||
{
|
||||
lightBrightness = brightness.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightBrightness = enabled ? 1.0f : 0.0f;
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
Light.Color = LightColor.Multiply(brightness);
|
||||
Light.Color = LightColor.Multiply(lightBrightness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -519,7 +519,10 @@ namespace Barotrauma.Items.Components
|
||||
Color color = !hasPower ? NoPowerColor : turret.ActiveUser is null ? Color.DimGray : GUIStyle.Green;
|
||||
weaponSprite.Draw(batch, center, color, origin, rotation, scale, SpriteEffects.None);
|
||||
}
|
||||
});
|
||||
})
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
weaponChilds.Add(component, frame);
|
||||
}
|
||||
|
||||
@@ -1181,13 +1181,18 @@ namespace Barotrauma.Items.Components
|
||||
if (dockingPort.Item.Submarine == null) { continue; }
|
||||
if (dockingPort.Item.Submarine.Info.IsWreck) { continue; }
|
||||
// docking ports should be shown even if defined as not, if the submarine is the same as the sonar's
|
||||
if (!dockingPort.Item.Submarine.ShowSonarMarker && dockingPort.Item.Submarine != item.Submarine && !dockingPort.Item.Submarine.Info.IsOutpost) { continue; }
|
||||
if (!dockingPort.Item.Submarine.ShowSonarMarker && dockingPort.Item.Submarine != item.Submarine &&
|
||||
!dockingPort.Item.Submarine.Info.IsOutpost && !dockingPort.Item.Submarine.Info.IsBeacon)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//don't show the docking ports of the opposing team on the sonar
|
||||
if (item.Submarine != null &&
|
||||
item.Submarine != GameMain.NetworkMember?.RespawnManager?.RespawnShuttle &&
|
||||
dockingPort.Item.Submarine != GameMain.NetworkMember?.RespawnManager?.RespawnShuttle &&
|
||||
dockingPort.Item.Submarine.Info.Type != SubmarineType.Outpost)
|
||||
!dockingPort.Item.Submarine.Info.IsOutpost &&
|
||||
!dockingPort.Item.Submarine.Info.IsBeacon)
|
||||
{
|
||||
// specifically checking for friendlyNPC seems more logical here
|
||||
if (dockingPort.Item.Submarine.TeamID != item.Submarine.TeamID && dockingPort.Item.Submarine.TeamID != CharacterTeamType.FriendlyNPC) { continue; }
|
||||
|
||||
Reference in New Issue
Block a user