(d9829ac) v0.9.4.0
This commit is contained in:
@@ -113,7 +113,13 @@ namespace Barotrauma
|
||||
if (item == null) return null;
|
||||
|
||||
var container = item.GetComponent<ItemContainer>();
|
||||
if (container == null || !container.KeepOpenWhenEquipped || !character.HasEquippedItem(container.Item)) return null;
|
||||
if (container == null ||
|
||||
!character.CanAccessInventory(container.Inventory) ||
|
||||
!container.KeepOpenWhenEquipped ||
|
||||
!character.HasEquippedItem(container.Item))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return container.Inventory;
|
||||
}
|
||||
@@ -133,7 +139,7 @@ namespace Barotrauma
|
||||
|
||||
public override void CreateSlots()
|
||||
{
|
||||
if (slots == null) slots = new InventorySlot[capacity];
|
||||
if (slots == null) { slots = new InventorySlot[capacity]; }
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
@@ -179,9 +185,11 @@ namespace Barotrauma
|
||||
highlightedSubInventorySlots.RemoveWhere(s => s.Inventory.OpenState <= 0.0f);
|
||||
foreach (var subSlot in highlightedSubInventorySlots)
|
||||
{
|
||||
subSlot.Slot = slots[subSlot.SlotIndex];
|
||||
if (subSlot.ParentInventory == this && subSlot.SlotIndex > 0 && subSlot.SlotIndex < slots.Length)
|
||||
{
|
||||
subSlot.Slot = slots[subSlot.SlotIndex];
|
||||
}
|
||||
}
|
||||
//highlightedSubInventorySlots.Clear();
|
||||
|
||||
screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
CalculateBackgroundFrame();
|
||||
@@ -475,7 +483,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
List<SlotReference> hideSubInventories = new List<SlotReference>();
|
||||
highlightedSubInventorySlots.RemoveWhere(s => s.SlotIndex < 0 || s.SlotIndex >= Items.Length || Items[s.SlotIndex] == null);
|
||||
highlightedSubInventorySlots.RemoveWhere(s =>
|
||||
s.ParentInventory == this &&
|
||||
((s.SlotIndex < 0 || s.SlotIndex >= Items.Length || Items[s.SlotIndex] == null) || (Character.Controlled != null && !Character.Controlled.CanAccessInventory(s.Inventory))));
|
||||
foreach (var highlightedSubInventorySlot in highlightedSubInventorySlots)
|
||||
{
|
||||
if (highlightedSubInventorySlot.ParentInventory == this)
|
||||
@@ -522,6 +532,9 @@ namespace Barotrauma
|
||||
|
||||
if (character.SelectedCharacter == null) // Permanently open subinventories only available when the default UI layout is in use -> not when grabbing characters
|
||||
{
|
||||
//remove the highlighted slots of other characters' inventories when not grabbing anyone
|
||||
highlightedSubInventorySlots.RemoveWhere(s => s.ParentInventory != this && s.ParentInventory?.Owner is Character);
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
var item = Items[i];
|
||||
@@ -531,7 +544,10 @@ namespace Barotrauma
|
||||
if (character.HasEquippedItem(item)) // Keep a subinventory display open permanently when the container is equipped
|
||||
{
|
||||
var itemContainer = item.GetComponent<ItemContainer>();
|
||||
if (itemContainer != null && itemContainer.KeepOpenWhenEquipped && !highlightedSubInventorySlots.Any(s => s.Inventory == itemContainer.Inventory))
|
||||
if (itemContainer != null &&
|
||||
itemContainer.KeepOpenWhenEquipped &&
|
||||
character.CanAccessInventory(itemContainer.Inventory) &&
|
||||
!highlightedSubInventorySlots.Any(s => s.Inventory == itemContainer.Inventory))
|
||||
{
|
||||
ShowSubInventory(new SlotReference(this, slots[i], i, false, itemContainer.Inventory), deltaTime, cam, hideSubInventories, true);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Barotrauma.Items.Components
|
||||
//openState when the vertices of the convex hull were last calculated
|
||||
private float lastConvexHullState;
|
||||
|
||||
[Serialize("1,1", false)]
|
||||
[Serialize("1,1", false, description: "The scale of the shadow-casting area of the door (relative to the actual size of the door).")]
|
||||
public Vector2 ShadowScale
|
||||
{
|
||||
get;
|
||||
@@ -102,7 +102,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
Color color = item.SpriteColor;
|
||||
if (brokenSprite == null)
|
||||
@@ -115,7 +115,7 @@ namespace Barotrauma.Items.Components
|
||||
if (stuck > 0.0f && weldedSprite != null)
|
||||
{
|
||||
Vector2 weldSpritePos = new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height / 2.0f);
|
||||
if (item.Submarine != null) weldSpritePos += item.Submarine.Position;
|
||||
if (item.Submarine != null) weldSpritePos += item.Submarine.DrawPosition;
|
||||
weldSpritePos.Y = -weldSpritePos.Y;
|
||||
|
||||
weldedSprite.Draw(spriteBatch,
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Barotrauma.Items.Components
|
||||
string style = subElement.Attribute("style") == null ?
|
||||
null : subElement.GetAttributeString("style", "");
|
||||
|
||||
GuiFrame = new GUIFrame(RectTransform.Load(subElement, GUI.Canvas), style, color);
|
||||
GuiFrame = new GUIFrame(RectTransform.Load(subElement, GUI.Canvas, Anchor.Center), style, color);
|
||||
DefaultLayout = GUILayoutSettings.Load(subElement);
|
||||
break;
|
||||
case "alternativelayout":
|
||||
|
||||
@@ -33,49 +33,49 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
[Serialize("0.0,0.0", false), Editable]
|
||||
#else
|
||||
[Serialize("0.0,0.0", false)]
|
||||
[Editable]
|
||||
#endif
|
||||
[Serialize("0.0,0.0", false, description: "The position where the contained items get drawn at (offset from the upper left corner of the sprite in pixels).")]
|
||||
public Vector2 ItemPos { get; set; }
|
||||
|
||||
#if DEBUG
|
||||
[Serialize("0.0,0.0", false), Editable]
|
||||
#else
|
||||
[Serialize("0.0,0.0", false)]
|
||||
[Editable]
|
||||
#endif
|
||||
[Serialize("0.0,0.0", false, description: "The interval at which the contained items are spaced apart from each other (in pixels).")]
|
||||
public Vector2 ItemInterval { get; set; }
|
||||
[Serialize(100, false)]
|
||||
[Serialize(100, false, description: "How many items are placed in a row before starting a new row.")]
|
||||
public int ItemsPerRow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Depth at which the contained sprites are drawn. If not set, the original depth of the item sprites is used.
|
||||
/// </summary>
|
||||
[Serialize(-1.0f, false)]
|
||||
[Serialize(-1.0f, false, description: "Depth at which the contained sprites are drawn. If not set, the original depth of the item sprites is used.")]
|
||||
public float ContainedSpriteDepth { get; set; }
|
||||
|
||||
|
||||
private float itemRotation;
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, false, description: "The rotation in which the contained sprites are drawn (in degrees).")]
|
||||
public float ItemRotation
|
||||
{
|
||||
get { return MathHelper.ToDegrees(itemRotation); }
|
||||
set { itemRotation = MathHelper.ToRadians(value); }
|
||||
}
|
||||
|
||||
[Serialize(null, false)]
|
||||
[Serialize(null, false, description: "An optional text displayed above the item's inventory.")]
|
||||
public string UILabel { get; set; }
|
||||
|
||||
[Serialize(false, false)]
|
||||
[Serialize(false, false, description: "If enabled, the condition of this item is displayed in the indicator that would normally show the state of the contained items." +
|
||||
" May be useful for items such as ammo boxes and magazines that spawn projectiles as needed," +
|
||||
" and use the condition to determine how many projectiles can be spawned in total.")]
|
||||
public bool ShowConditionInContainedStateIndicator
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(false, false)]
|
||||
[Serialize(false, false, description: "Should the inventory of this item be kept open when the item is equipped by a character.")]
|
||||
public bool KeepOpenWhenEquipped { get; set; }
|
||||
[Serialize(false, false)]
|
||||
[Serialize(false, false, description: "Can the inventory of this item be moved around on the screen by the player.")]
|
||||
public bool MovableFrame { get; set; }
|
||||
|
||||
public Vector2 DrawSize
|
||||
@@ -132,13 +132,13 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
if (hideItems || (item.body != null && !item.body.Enabled)) { return; }
|
||||
DrawContainedItems(spriteBatch);
|
||||
DrawContainedItems(spriteBatch, itemDepth);
|
||||
}
|
||||
|
||||
public void DrawContainedItems(SpriteBatch spriteBatch)
|
||||
public void DrawContainedItems(SpriteBatch spriteBatch, float itemDepth)
|
||||
{
|
||||
Vector2 transformedItemPos = ItemPos * item.Scale;
|
||||
Vector2 transformedItemInterval = ItemInterval * item.Scale;
|
||||
@@ -199,20 +199,28 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
containedItem.body.SetTransformIgnoreContacts(containedItem.body.SimPosition, currentRotation);
|
||||
}
|
||||
|
||||
Vector2 origin = containedItem.Sprite.Origin;
|
||||
if (item.FlippedX) { origin.X = containedItem.Sprite.SourceRect.Width - origin.X; }
|
||||
if (item.FlippedY) { origin.Y = containedItem.Sprite.SourceRect.Height - origin.Y; }
|
||||
|
||||
float containedSpriteDepth = ContainedSpriteDepth < 0.0f ? containedItem.Sprite.Depth : ContainedSpriteDepth;
|
||||
containedSpriteDepth = itemDepth + (containedSpriteDepth - item.SpriteDepth) / 10000.0f;
|
||||
|
||||
containedItem.Sprite.Draw(
|
||||
spriteBatch,
|
||||
new Vector2(currentItemPos.X, -currentItemPos.Y),
|
||||
containedItem.GetSpriteColor(),
|
||||
-currentRotation,
|
||||
origin,
|
||||
- currentRotation,
|
||||
containedItem.Scale,
|
||||
spriteEffects,
|
||||
depth: ContainedSpriteDepth < 0.0f ? containedItem.Sprite.Depth : ContainedSpriteDepth);
|
||||
depth: containedSpriteDepth);
|
||||
|
||||
foreach (ItemContainer ic in containedItem.GetComponents<ItemContainer>())
|
||||
{
|
||||
if (ic.hideItems) continue;
|
||||
ic.DrawContainedItems(spriteBatch);
|
||||
ic.DrawContainedItems(spriteBatch, containedSpriteDepth);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private float[] charWidths;
|
||||
|
||||
[Serialize("0,0,0,0", true)]
|
||||
[Serialize("0,0,0,0", true, description: "The amount of padding around the text in pixels (left,top,right,bottom). ")]
|
||||
public Vector4 Padding
|
||||
{
|
||||
get { return TextBlock.Padding; }
|
||||
@@ -28,7 +28,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
private string text;
|
||||
[Serialize("", true, translationTextTag: "Label."), Editable(100)]
|
||||
[Serialize("", true, translationTextTag: "Label.", description: "The text displayed in the label."), Editable(100)]
|
||||
public string Text
|
||||
{
|
||||
get { return text; }
|
||||
@@ -54,7 +54,7 @@ namespace Barotrauma.Items.Components
|
||||
private set;
|
||||
}
|
||||
|
||||
[Editable, Serialize("0.0,0.0,0.0,1.0", true)]
|
||||
[Editable, Serialize("0,0,0,255", true, description: "The color of the text displayed on the label (R,G,B,A).")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return textColor; }
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
[Editable(0.0f, 10.0f), Serialize(1.0f, true)]
|
||||
[Editable(0.0f, 10.0f), Serialize(1.0f, true, description: "The scale of the text displayed on the label.")]
|
||||
public float TextScale
|
||||
{
|
||||
get { return textBlock == null ? 1.0f : textBlock.TextScale; }
|
||||
@@ -76,7 +76,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
private bool scrollable;
|
||||
[Serialize(false, true)]
|
||||
[Serialize(false, true, description: "Should the text scroll horizontally across the item if it's too long to be displayed all at once.")]
|
||||
public bool Scrollable
|
||||
{
|
||||
get { return scrollable; }
|
||||
@@ -89,7 +89,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(20.0f, true)]
|
||||
[Serialize(20.0f, true, description: "How fast the text scrolls across the item (only valid if Scrollable is set to true).")]
|
||||
public float ScrollSpeed
|
||||
{
|
||||
get;
|
||||
@@ -202,7 +202,7 @@ namespace Barotrauma.Items.Components
|
||||
TextBlock.Text = sb.ToString();
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
var drawPos = new Vector2(
|
||||
item.DrawPosition.X - item.Rect.Width / 2.0f,
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return light; }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
if (light.LightSprite != null && (item.body == null || item.body.Enabled) && lightBrightness > 0.0f)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void FlipX(bool relativeToSub)
|
||||
{
|
||||
if (light?.LightSprite != null)
|
||||
if (light?.LightSprite != null && item.Prefab.CanSpriteFlipX)
|
||||
{
|
||||
light.LightSpriteEffect = light.LightSpriteEffect == SpriteEffects.None ?
|
||||
SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Barotrauma.Items.Components
|
||||
if (spriteIndex >= propellerSprite.FrameCount) spriteIndex = 0.0f;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (propellerSprite != null)
|
||||
{
|
||||
|
||||
@@ -271,11 +271,14 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Rectangle slotRect = outputContainer.Inventory.slots[0].Rect;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Rectangle(
|
||||
slotRect.X, slotRect.Y + (int)(slotRect.Height * (1.0f - progressState)),
|
||||
slotRect.Width, (int)(slotRect.Height * progressState)),
|
||||
Color.Green * 0.5f, isFilled: true);
|
||||
if (fabricatedItem != null)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Rectangle(
|
||||
slotRect.X, slotRect.Y + (int)(slotRect.Height * (1.0f - progressState)),
|
||||
slotRect.Width, (int)(slotRect.Height * progressState)),
|
||||
Color.Green * 0.5f, isFilled: true);
|
||||
}
|
||||
|
||||
itemIcon.Draw(
|
||||
spriteBatch,
|
||||
|
||||
@@ -79,6 +79,11 @@ namespace Barotrauma.Items.Components
|
||||
displayedSubs.AddRange(item.Submarine.DockedTo);
|
||||
}
|
||||
|
||||
public override void FlipX(bool relativeToSub)
|
||||
{
|
||||
CreateHUD();
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
{
|
||||
//recreate HUD if the subs we should display have changed
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
var btnText = warningBtn.GetChild<GUITextBlock>();
|
||||
btnText.Font = GUI.Font;
|
||||
btnText.Wrap = true;
|
||||
btnText.Wrap = false;
|
||||
btnText.SetTextPos();
|
||||
warningButtons.Add(warningTexts[i], warningBtn);
|
||||
}
|
||||
|
||||
@@ -27,12 +27,16 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUITickBox directionalTickBox;
|
||||
private GUIScrollBar directionalSlider;
|
||||
private Vector2? pingDragDirection = null;
|
||||
|
||||
private GUILayoutGroup activeControlsContainer;
|
||||
private GUIFrame controlContainer;
|
||||
|
||||
private GUICustomComponent sonarView;
|
||||
|
||||
private Sprite directionalPingBackground;
|
||||
private Sprite[] directionalPingButton;
|
||||
|
||||
private float displayBorderSize;
|
||||
|
||||
private List<SonarBlip> sonarBlips;
|
||||
@@ -149,14 +153,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
showDirectionalIndicatorTimer = 1.0f;
|
||||
float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, scroll);
|
||||
pingDirection = new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle));
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
SetPingDirection(new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle)));
|
||||
return true;
|
||||
}
|
||||
},
|
||||
Range = new Vector2(0,MathHelper.TwoPi)
|
||||
};
|
||||
|
||||
signalWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedControlContainer.RectTransform), "", Color.Orange, textAlignment: Alignment.Center);
|
||||
@@ -178,6 +178,14 @@ namespace Barotrauma.Items.Components
|
||||
case "directionalpingcircle":
|
||||
directionalPingCircle = new Sprite(subElement);
|
||||
break;
|
||||
case "directionalpingbackground":
|
||||
directionalPingBackground = new Sprite(subElement);
|
||||
break;
|
||||
case "directionalpingbutton":
|
||||
if (directionalPingButton == null) { directionalPingButton = new Sprite[3]; }
|
||||
int index = subElement.GetAttributeInt("index", 0);
|
||||
directionalPingButton[index] = new Sprite(subElement);
|
||||
break;
|
||||
case "screenoverlay":
|
||||
screenOverlay = new Sprite(subElement);
|
||||
break;
|
||||
@@ -206,6 +214,16 @@ namespace Barotrauma.Items.Components
|
||||
controlContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
}
|
||||
|
||||
private void SetPingDirection(Vector2 direction)
|
||||
{
|
||||
pingDirection = direction;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
{
|
||||
zoomSlider.BarScroll = MathUtils.InverseLerp(MinZoom, MaxZoom, zoom);
|
||||
@@ -352,6 +370,43 @@ namespace Barotrauma.Items.Components
|
||||
prevDockingDist = float.MaxValue;
|
||||
}
|
||||
|
||||
if (steering != null && directionalPingButton != null)
|
||||
{
|
||||
steering.SteerRadius = useDirectionalPing && pingDragDirection != null ?
|
||||
-1.0f :
|
||||
PlayerInput.LeftButtonDown() || !PlayerInput.LeftButtonHeld() ?
|
||||
(float?)((sonarView.Rect.Width / 2) - (directionalPingButton[0].size.X * sonarView.Rect.Width / screenBackground.size.X)) :
|
||||
null;
|
||||
}
|
||||
|
||||
if (useDirectionalPing && PlayerInput.LeftButtonHeld())
|
||||
{
|
||||
if ((MouseInDirectionalPingRing(sonarView.Rect, false) && PlayerInput.LeftButtonDown()) || pingDragDirection != null)
|
||||
{
|
||||
Vector2 newDragDir = Vector2.Normalize(PlayerInput.MousePosition - sonarView.Rect.Center.ToVector2());
|
||||
if (pingDragDirection == null && !MouseInDirectionalPingRing(sonarView.Rect, true))
|
||||
{
|
||||
directionalSlider.BarScrollValue = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(newDragDir));
|
||||
directionalSlider.OnMoved(directionalSlider, directionalSlider.BarScroll);
|
||||
}
|
||||
else if (pingDragDirection != null)
|
||||
{
|
||||
float newAngle = MathUtils.VectorToAngle(newDragDir);
|
||||
float oldAngle = MathUtils.VectorToAngle(pingDragDirection.Value);
|
||||
float pingAngle = MathUtils.VectorToAngle(pingDirection);
|
||||
pingAngle = MathUtils.WrapAngleTwoPi(pingAngle + MathUtils.GetShortestAngle(oldAngle, newAngle));
|
||||
directionalSlider.BarScrollValue = pingAngle;
|
||||
directionalSlider.OnMoved(directionalSlider, directionalSlider.BarScroll);
|
||||
}
|
||||
|
||||
pingDragDirection = newDragDir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pingDragDirection = null;
|
||||
}
|
||||
|
||||
for (var pingIndex = 0; pingIndex < activePingsCount; ++pingIndex)
|
||||
{
|
||||
var activePing = activePings[pingIndex];
|
||||
@@ -391,6 +446,28 @@ namespace Barotrauma.Items.Components
|
||||
prevPassivePingRadius = passivePingRadius;
|
||||
}
|
||||
|
||||
private bool MouseInDirectionalPingRing(Rectangle rect, bool onButton)
|
||||
{
|
||||
if (!useDirectionalPing || directionalPingButton == null) { return false; }
|
||||
|
||||
float endRadius = rect.Width / 2.0f;
|
||||
float startRadius = endRadius - directionalPingButton[0].size.X * rect.Width / screenBackground.size.X;
|
||||
|
||||
Vector2 center = rect.Center.ToVector2();
|
||||
|
||||
float dist = Vector2.DistanceSquared(PlayerInput.MousePosition,center);
|
||||
|
||||
bool retVal = (dist >= startRadius*startRadius) && (dist < endRadius*endRadius);
|
||||
if (onButton)
|
||||
{
|
||||
float pingAngle = MathUtils.VectorToAngle(pingDirection);
|
||||
float mouseAngle = MathUtils.VectorToAngle(Vector2.Normalize(PlayerInput.MousePosition - center));
|
||||
retVal &= Math.Abs(MathUtils.GetShortestAngle(mouseAngle, pingAngle)) < MathHelper.ToRadians(DirectionalPingSector * 0.5f);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private void DrawSonar(SpriteBatch spriteBatch, Rectangle rect)
|
||||
{
|
||||
displayBorderSize = 0.2f;
|
||||
@@ -403,6 +480,24 @@ namespace Barotrauma.Items.Components
|
||||
screenBackground.Draw(spriteBatch, center, 0.0f, rect.Width / screenBackground.size.X);
|
||||
}
|
||||
|
||||
if (useDirectionalPing)
|
||||
{
|
||||
directionalPingBackground?.Draw(spriteBatch, center, 0.0f, rect.Width / directionalPingBackground.size.X);
|
||||
if (directionalPingButton != null)
|
||||
{
|
||||
int buttonSprIndex = 0;
|
||||
if (pingDragDirection != null)
|
||||
{
|
||||
buttonSprIndex = 2;
|
||||
}
|
||||
else if (MouseInDirectionalPingRing(rect, true))
|
||||
{
|
||||
buttonSprIndex = 1;
|
||||
}
|
||||
directionalPingButton[buttonSprIndex]?.Draw(spriteBatch, center, MathUtils.VectorToAngle(pingDirection), rect.Width / directionalPingBackground.size.X);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMode == Mode.Active && currentPingIndex != -1)
|
||||
{
|
||||
var activePing = activePings[currentPingIndex];
|
||||
|
||||
@@ -47,6 +47,10 @@ namespace Barotrauma.Items.Components
|
||||
private Sprite maintainPosIndicator, maintainPosOriginIndicator;
|
||||
private Sprite steeringIndicator;
|
||||
|
||||
private List<DockingPort> connectedPorts = new List<DockingPort>();
|
||||
private float checkConnectedPortsTimer;
|
||||
private const float CheckConnectedPortsInterval = 1.0f;
|
||||
|
||||
private Vector2 keyboardInput = Vector2.Zero;
|
||||
private float inputCumulation;
|
||||
|
||||
@@ -86,6 +90,19 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
} = true;
|
||||
|
||||
private float steerRadius;
|
||||
public float? SteerRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return steerRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
steerRadius = value ?? (steerArea.Rect.Width / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DockingPort> DockingSources = new List<DockingPort>();
|
||||
public DockingPort ActiveDockingSource, DockingTarget;
|
||||
|
||||
@@ -317,7 +334,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
item.SendSignal(0, "1", "toggle_docking", sender: Character.Controlled);
|
||||
item.SendSignal(0, "1", "toggle_docking", sender: null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -384,6 +401,8 @@ namespace Barotrauma.Items.Components
|
||||
statusContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
steerArea.RectTransform.NonScaledSize = new Point(viewSize);
|
||||
dockingContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
|
||||
steerRadius = steerArea.Rect.Width / 2;
|
||||
}
|
||||
|
||||
private void FindConnectedDockingPort()
|
||||
@@ -661,7 +680,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
pressureWarningText.Visible = item.Submarine != null && item.Submarine.AtDamageDepth && Timing.TotalTime % 1.0f < 0.5f;
|
||||
|
||||
if (Vector2.Distance(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerArea.Rect.Width / 2)
|
||||
if (Vector2.DistanceSquared(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerRadius * steerRadius)
|
||||
{
|
||||
if (PlayerInput.LeftButtonHeld())
|
||||
{
|
||||
@@ -735,10 +754,21 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
if (!UseAutoDocking) { return; }
|
||||
|
||||
if (checkConnectedPortsTimer <= 0.0f)
|
||||
{
|
||||
Connection dockingConnection = item.Connections?.FirstOrDefault(c => c.Name == "toggle_docking");
|
||||
if (dockingConnection != null)
|
||||
{
|
||||
connectedPorts = item.GetConnectedComponentsRecursive<DockingPort>(dockingConnection);
|
||||
}
|
||||
checkConnectedPortsTimer = CheckConnectedPortsInterval;
|
||||
}
|
||||
|
||||
float closestDist = DockingAssistThreshold * DockingAssistThreshold;
|
||||
DockingModeEnabled = false;
|
||||
foreach (DockingPort sourcePort in DockingPort.List)
|
||||
|
||||
foreach (DockingPort sourcePort in connectedPorts)
|
||||
{
|
||||
if (sourcePort.Docked || sourcePort.Item.Submarine == null) { continue; }
|
||||
if (sourcePort.Item.Submarine != controlledSub) { continue; }
|
||||
@@ -826,6 +856,7 @@ namespace Barotrauma.Items.Components
|
||||
int msgStartPos = msg.BitPosition;
|
||||
|
||||
bool autoPilot = msg.ReadBoolean();
|
||||
bool dockingButtonClicked = msg.ReadBoolean();
|
||||
Vector2 newSteeringInput = steeringInput;
|
||||
Vector2 newTargetVelocity = targetVelocity;
|
||||
float newSteeringAdjustSpeed = steeringAdjustSpeed;
|
||||
@@ -833,6 +864,11 @@ namespace Barotrauma.Items.Components
|
||||
Vector2? newPosToMaintain = null;
|
||||
bool headingToStart = false;
|
||||
|
||||
if (dockingButtonClicked)
|
||||
{
|
||||
item.SendSignal(0, "1", "toggle_docking", sender: null);
|
||||
}
|
||||
|
||||
if (autoPilot)
|
||||
{
|
||||
maintainPos = msg.ReadBoolean();
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Barotrauma.Items.Components
|
||||
chargeIndicator.Color = ToolBox.GradientLerp(chargeRatio, Color.Red, Color.Orange, Color.Green);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
if (indicatorSize.X <= 1.0f || indicatorSize.Y <= 1.0f) return;
|
||||
|
||||
@@ -143,7 +143,10 @@ namespace Barotrauma.Items.Components
|
||||
float rechargeRate = msg.ReadRangedInteger(0, 10) / 10.0f;
|
||||
RechargeSpeed = rechargeRate * MaxRechargeSpeed;
|
||||
#if CLIENT
|
||||
rechargeSpeedSlider.BarScroll = rechargeRate;
|
||||
if (rechargeSpeedSlider != null)
|
||||
{
|
||||
rechargeSpeedSlider.BarScroll = rechargeRate;
|
||||
}
|
||||
#endif
|
||||
Charge = msg.ReadRangedSingle(0.0f, 1.0f, 8) * capacity;
|
||||
}
|
||||
|
||||
@@ -16,21 +16,17 @@ namespace Barotrauma.Items.Components
|
||||
: IDrawableComponent
|
||||
#endif
|
||||
{
|
||||
public ParticleEmitter ParticleEmitter
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#if DEBUG
|
||||
public Vector2 DrawSize
|
||||
{
|
||||
get { return GameMain.DebugDraw ? Vector2.One * Range : Vector2.Zero; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private List<ParticleEmitter> ParticleEmitterHitStructure = new List<ParticleEmitter>();
|
||||
private List<ParticleEmitter> ParticleEmitterHitCharacter = new List<ParticleEmitter>();
|
||||
private List<Pair<RelatedItem, ParticleEmitter>> ParticleEmitterHitItem = new List<Pair<RelatedItem, ParticleEmitter>>();
|
||||
private List<ParticleEmitter> particleEmitters = new List<ParticleEmitter>();
|
||||
private List<ParticleEmitter> particleEmitterHitStructure = new List<ParticleEmitter>();
|
||||
private List<ParticleEmitter> particleEmitterHitCharacter = new List<ParticleEmitter>();
|
||||
private List<Pair<RelatedItem, ParticleEmitter>> particleEmitterHitItem = new List<Pair<RelatedItem, ParticleEmitter>>();
|
||||
|
||||
private float prevProgressBarState;
|
||||
|
||||
@@ -41,7 +37,7 @@ namespace Barotrauma.Items.Components
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "particleemitter":
|
||||
ParticleEmitter = new ParticleEmitter(subElement);
|
||||
particleEmitters.Add(new ParticleEmitter(subElement));
|
||||
break;
|
||||
case "particleemitterhititem":
|
||||
string[] identifiers = subElement.GetAttributeStringArray("identifiers", new string[0]);
|
||||
@@ -49,16 +45,16 @@ namespace Barotrauma.Items.Components
|
||||
string[] excludedIdentifiers = subElement.GetAttributeStringArray("excludedidentifiers", new string[0]);
|
||||
if (excludedIdentifiers.Length == 0) excludedIdentifiers = subElement.GetAttributeStringArray("excludedidentifier", new string[0]);
|
||||
|
||||
ParticleEmitterHitItem.Add(
|
||||
particleEmitterHitItem.Add(
|
||||
new Pair<RelatedItem, ParticleEmitter>(
|
||||
new RelatedItem(identifiers, excludedIdentifiers),
|
||||
new ParticleEmitter(subElement)));
|
||||
break;
|
||||
case "particleemitterhitstructure":
|
||||
ParticleEmitterHitStructure.Add(new ParticleEmitter(subElement));
|
||||
particleEmitterHitStructure.Add(new ParticleEmitter(subElement));
|
||||
break;
|
||||
case "particleemitterhitcharacter":
|
||||
ParticleEmitterHitCharacter.Add(new ParticleEmitter(subElement));
|
||||
particleEmitterHitCharacter.Add(new ParticleEmitter(subElement));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -67,12 +63,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void UseProjSpecific(float deltaTime, Vector2 raystart)
|
||||
{
|
||||
if (ParticleEmitter != null)
|
||||
foreach (ParticleEmitter particleEmitter in particleEmitters)
|
||||
{
|
||||
float particleAngle = item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi);
|
||||
ParticleEmitter.Emit(
|
||||
particleEmitter.Emit(
|
||||
deltaTime, ConvertUnits.ToDisplayUnits(raystart),
|
||||
item.CurrentHull, particleAngle, ParticleEmitter.Prefab.CopyEntityAngle ? -particleAngle : 0);
|
||||
item.CurrentHull, particleAngle, particleEmitter.Prefab.CopyEntityAngle ? -particleAngle : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +90,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Vector2 particlePos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
if (targetStructure.Submarine != null) particlePos += targetStructure.Submarine.DrawPosition;
|
||||
foreach (var emitter in ParticleEmitterHitStructure)
|
||||
foreach (var emitter in particleEmitterHitStructure)
|
||||
{
|
||||
float particleAngle = item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi);
|
||||
emitter.Emit(deltaTime, particlePos, item.CurrentHull, particleAngle + MathHelper.Pi, -particleAngle + MathHelper.Pi);
|
||||
@@ -105,7 +101,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
Vector2 particlePos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
if (targetCharacter.Submarine != null) particlePos += targetCharacter.Submarine.DrawPosition;
|
||||
foreach (var emitter in ParticleEmitterHitCharacter)
|
||||
foreach (var emitter in particleEmitterHitCharacter)
|
||||
{
|
||||
float particleAngle = item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi);
|
||||
emitter.Emit(deltaTime, particlePos, item.CurrentHull, particleAngle + MathHelper.Pi, -particleAngle + MathHelper.Pi);
|
||||
@@ -133,7 +129,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Vector2 particlePos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
if (targetItem.Submarine != null) particlePos += targetItem.Submarine.DrawPosition;
|
||||
foreach (var emitter in ParticleEmitterHitItem)
|
||||
foreach (var emitter in particleEmitterHitItem)
|
||||
{
|
||||
if (!emitter.First.MatchesItem(targetItem)) continue;
|
||||
float particleAngle = item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi);
|
||||
@@ -141,7 +137,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (GameMain.DebugDraw && IsActive)
|
||||
{
|
||||
|
||||
@@ -10,16 +10,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Repairable : ItemComponent, IDrawableComponent
|
||||
{
|
||||
public GUIButton RepairButton
|
||||
{
|
||||
get { return repairButton; }
|
||||
}
|
||||
private GUIButton repairButton;
|
||||
public GUIButton SabotageButton
|
||||
{
|
||||
get { return sabotageButton; }
|
||||
}
|
||||
private GUIButton sabotageButton;
|
||||
public GUIButton RepairButton { get; private set; }
|
||||
|
||||
public GUIButton SabotageButton { get; private set; }
|
||||
|
||||
private GUIProgressBar progressBar;
|
||||
|
||||
private List<ParticleEmitter> particleEmitters = new List<ParticleEmitter>();
|
||||
@@ -33,7 +27,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private FixActions requestStartFixAction;
|
||||
|
||||
[Serialize("", false)]
|
||||
[Serialize("", false, description: "An optional description of the needed repairs displayed in the repair interface.")]
|
||||
public string Description
|
||||
{
|
||||
get;
|
||||
@@ -83,7 +77,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
repairButtonText = TextManager.Get("RepairButton");
|
||||
repairingText = TextManager.Get("Repairing");
|
||||
repairButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.TopCenter), repairButtonText)
|
||||
RepairButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.TopCenter), repairButtonText)
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
@@ -94,7 +88,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
sabotageButtonText = TextManager.Get("SabotageButton");
|
||||
sabotagingText = TextManager.Get("Sabotaging");
|
||||
sabotageButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.BottomCenter), sabotageButtonText)
|
||||
SabotageButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.BottomCenter), sabotageButtonText)
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
@@ -165,14 +159,14 @@ namespace Barotrauma.Items.Components
|
||||
progressBar.BarSize = item.Condition / item.MaxCondition;
|
||||
progressBar.Color = ToolBox.GradientLerp(progressBar.BarSize, Color.Red, Color.Orange, Color.Green);
|
||||
|
||||
repairButton.Enabled = (currentFixerAction == FixActions.None || (CurrentFixer == character && currentFixerAction != FixActions.Repair)) && item.ConditionPercentage <= ShowRepairUIThreshold;
|
||||
repairButton.Text = (currentFixerAction == FixActions.None || CurrentFixer != character || currentFixerAction != FixActions.Repair) ?
|
||||
RepairButton.Enabled = (currentFixerAction == FixActions.None || (CurrentFixer == character && currentFixerAction != FixActions.Repair)) && item.ConditionPercentage <= ShowRepairUIThreshold;
|
||||
RepairButton.Text = (currentFixerAction == FixActions.None || CurrentFixer != character || currentFixerAction != FixActions.Repair) ?
|
||||
repairButtonText :
|
||||
repairingText + new string('.', ((int)(Timing.TotalTime * 2.0f) % 3) + 1);
|
||||
|
||||
sabotageButton.Visible = character.IsTraitor;
|
||||
sabotageButton.Enabled = (currentFixerAction == FixActions.None || (CurrentFixer == character && currentFixerAction != FixActions.Sabotage)) && character.IsTraitor && item.ConditionPercentage > MinSabotageCondition;
|
||||
sabotageButton.Text = (currentFixerAction == FixActions.None || CurrentFixer != character || currentFixerAction != FixActions.Sabotage || !character.IsTraitor) ?
|
||||
SabotageButton.Visible = character.IsTraitor;
|
||||
SabotageButton.Enabled = (currentFixerAction == FixActions.None || (CurrentFixer == character && currentFixerAction != FixActions.Sabotage)) && character.IsTraitor && item.ConditionPercentage > MinSabotageCondition;
|
||||
SabotageButton.Text = (currentFixerAction == FixActions.None || CurrentFixer != character || currentFixerAction != FixActions.Sabotage || !character.IsTraitor) ?
|
||||
sabotageButtonText :
|
||||
sabotagingText + new string('.', ((int)(Timing.TotalTime * 2.0f) % 3) + 1);
|
||||
|
||||
@@ -193,7 +187,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (GameMain.DebugDraw && Character.Controlled?.FocusedItem == item)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return new Vector2(rangeX, rangeY) * 2.0f; }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (!editing || !MapEntity.SelectedList.Contains(item)) return;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return new Vector2(range * 2); }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (!editing || !MapEntity.SelectedList.Contains(item)) return;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return sectionExtents; }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (sections.Count == 0 && !IsActive || Hidden)
|
||||
{
|
||||
@@ -154,6 +154,18 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public static void UpdateEditing(List<Wire> wires)
|
||||
{
|
||||
Wire equippedWire =
|
||||
Character.Controlled?.SelectedItems[0]?.GetComponent<Wire>() ??
|
||||
Character.Controlled?.SelectedItems[1]?.GetComponent<Wire>();
|
||||
if (equippedWire != null)
|
||||
{
|
||||
if (PlayerInput.LeftButtonClicked() && Character.Controlled.SelectedConstruction == null)
|
||||
{
|
||||
equippedWire.Use(1.0f, Character.Controlled);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//dragging a node of some wire
|
||||
if (draggingWire != null)
|
||||
{
|
||||
|
||||
@@ -33,14 +33,14 @@ namespace Barotrauma.Items.Components
|
||||
TextManager.Get("NotBreathing")
|
||||
};
|
||||
|
||||
[Serialize(500.0f, false)]
|
||||
[Serialize(500.0f, false, description: "How close to a target the user must be to see their health data (in pixels).")]
|
||||
public float Range
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(50.0f, false)]
|
||||
[Serialize(50.0f, false, description: "The range within which the health info texts fades out.")]
|
||||
public float FadeOutRange
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private Vector2 crosshairPos, crosshairPointerPos;
|
||||
|
||||
private Dictionary<string, Widget> widgets = new Dictionary<string, Widget>();
|
||||
private readonly Dictionary<string, Widget> widgets = new Dictionary<string, Widget>();
|
||||
private float prevAngle;
|
||||
|
||||
private bool flashLowPower;
|
||||
@@ -33,30 +33,30 @@ namespace Barotrauma.Items.Components
|
||||
private float flashTimer;
|
||||
private float flashLength = 1;
|
||||
|
||||
private List<ParticleEmitter> particleEmitters = new List<ParticleEmitter>();
|
||||
private readonly List<ParticleEmitter> particleEmitters = new List<ParticleEmitter>();
|
||||
|
||||
[Editable, Serialize("0.0,0.0,0.0,0.0", true)]
|
||||
[Editable, Serialize("0,0,0,0", true, description: "Optional screen tint color when the item is being operated (R,G,B,A).")]
|
||||
public Color HudTint
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(false, false)]
|
||||
[Serialize(false, false, description: "Should the charge of the connected batteries/supercapacitors be shown at the top of the screen when operating the item.")]
|
||||
public bool ShowChargeIndicator
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(false, false)]
|
||||
[Serialize(false, false, description: "Should the available ammunition be shown at the top of the screen when operating the item.")]
|
||||
public bool ShowProjectileIndicator
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
[Serialize(0.0f, false, description: "How far the barrel \"recoils back\" when the turret is fired (in pixels).")]
|
||||
public float RecoilDistance
|
||||
{
|
||||
get;
|
||||
@@ -240,7 +240,7 @@ namespace Barotrauma.Items.Components
|
||||
crosshairPointerPos = PlayerInput.MousePosition;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
Vector2 drawPos = new Vector2(item.Rect.X + transformedBarrelPos.X, item.Rect.Y - transformedBarrelPos.Y);
|
||||
if (item.Submarine != null) drawPos += item.Submarine.DrawPosition;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return Vector2.Zero; }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
if (dockingState == 0.0f) return;
|
||||
|
||||
@@ -105,5 +105,56 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
|
||||
{
|
||||
bool isDocked = msg.ReadBoolean();
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (hulls[i] == null) continue;
|
||||
item.linkedTo.Remove(hulls[i]);
|
||||
hulls[i].Remove();
|
||||
hulls[i] = null;
|
||||
}
|
||||
|
||||
if (gap != null)
|
||||
{
|
||||
item.linkedTo.Remove(gap);
|
||||
gap.Remove();
|
||||
gap = null;
|
||||
}
|
||||
|
||||
if (isDocked)
|
||||
{
|
||||
ushort dockingTargetID = msg.ReadUInt16();
|
||||
|
||||
bool isLocked = msg.ReadBoolean();
|
||||
|
||||
Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
|
||||
if (targetEntity == null || !(targetEntity is Item))
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid docking port network event (can't dock to " + targetEntity?.ToString() ?? "null" + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
DockingTarget = (targetEntity as Item).GetComponent<DockingPort>();
|
||||
if (DockingTarget == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid docking port network event (" + targetEntity + " doesn't have a docking port component)");
|
||||
return;
|
||||
}
|
||||
|
||||
Dock(DockingTarget);
|
||||
|
||||
if (isLocked)
|
||||
{
|
||||
Lock(isNetworkMessage: true, forcePosition: true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Undock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,14 @@ namespace Barotrauma
|
||||
|
||||
public static SlotReference SelectedSlot
|
||||
{
|
||||
get { return selectedSlot; }
|
||||
get
|
||||
{
|
||||
if (selectedSlot?.ParentInventory?.Owner == null || selectedSlot.ParentInventory.Owner.Removed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return selectedSlot;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CreateSlots()
|
||||
@@ -430,6 +437,8 @@ namespace Barotrauma
|
||||
|
||||
if (canMove)
|
||||
{
|
||||
subInventory.HideTimer = 1.0f;
|
||||
subInventory.OpenState = 1.0f;
|
||||
if (subInventory.movableFrameRect.Contains(PlayerInput.MousePosition) && PlayerInput.RightButtonClicked())
|
||||
{
|
||||
container.Inventory.savedPosition = container.Inventory.originalPos;
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace Barotrauma
|
||||
public float LastImpactSoundTime;
|
||||
public const float ImpactSoundInterval = 0.2f;
|
||||
|
||||
private bool editingHUDRefreshPending;
|
||||
private float editingHUDRefreshTimer;
|
||||
|
||||
class SpriteState
|
||||
{
|
||||
public float RotationState;
|
||||
@@ -33,7 +36,7 @@ namespace Barotrauma
|
||||
public bool IsActive = true;
|
||||
}
|
||||
|
||||
private Dictionary<ItemPrefab.DecorativeSprite, SpriteState> spriteAnimState = new Dictionary<ItemPrefab.DecorativeSprite, SpriteState>();
|
||||
private Dictionary<DecorativeSprite, SpriteState> spriteAnimState = new Dictionary<DecorativeSprite, SpriteState>();
|
||||
|
||||
private Sprite activeSprite;
|
||||
public override Sprite Sprite
|
||||
@@ -128,11 +131,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (BrokenItemSprite brokenSprite in Prefab.BrokenSprites)
|
||||
for (int i = 0; i < Prefab.BrokenSprites.Count;i++)
|
||||
{
|
||||
if (condition <= brokenSprite.MaxCondition)
|
||||
float minCondition = i > 0 ? Prefab.BrokenSprites[i - i].MaxCondition : 0.0f;
|
||||
if (condition <= minCondition ||
|
||||
condition <= Prefab.BrokenSprites[i].MaxCondition && !Prefab.BrokenSprites[i].FadeIn)
|
||||
{
|
||||
activeSprite = brokenSprite.Sprite;
|
||||
activeSprite = Prefab.BrokenSprites[i].Sprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -211,18 +216,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
float depth = GetDrawDepth();
|
||||
if (activeSprite != null)
|
||||
{
|
||||
SpriteEffects oldEffects = activeSprite.effects;
|
||||
activeSprite.effects ^= SpriteEffects;
|
||||
SpriteEffects oldBrokenSpriteEffects = SpriteEffects.None;
|
||||
if (fadeInBrokenSprite != null)
|
||||
if (fadeInBrokenSprite != null && fadeInBrokenSprite.Sprite != activeSprite)
|
||||
{
|
||||
oldBrokenSpriteEffects = fadeInBrokenSprite.Sprite.effects;
|
||||
fadeInBrokenSprite.Sprite.effects ^= SpriteEffects;
|
||||
}
|
||||
|
||||
float depth = GetDrawDepth();
|
||||
if (body == null)
|
||||
{
|
||||
bool flipHorizontal = (SpriteEffects & SpriteEffects.FlipHorizontally) != 0;
|
||||
@@ -304,9 +309,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
activeSprite.effects = oldEffects;
|
||||
if (fadeInBrokenSprite != null)
|
||||
if (fadeInBrokenSprite != null && fadeInBrokenSprite.Sprite != activeSprite)
|
||||
{
|
||||
fadeInBrokenSprite.Sprite.effects = oldEffects;
|
||||
fadeInBrokenSprite.Sprite.effects = oldBrokenSpriteEffects;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +319,7 @@ namespace Barotrauma
|
||||
//causing them to be removed from the list
|
||||
for (int i = drawableComponents.Count - 1; i >= 0; i--)
|
||||
{
|
||||
drawableComponents[i].Draw(spriteBatch, editing);
|
||||
drawableComponents[i].Draw(spriteBatch, editing, depth);
|
||||
}
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
@@ -437,21 +442,23 @@ namespace Barotrauma
|
||||
|
||||
public override void UpdateEditing(Camera cam)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData as Item != this)
|
||||
if (editingHUD == null || editingHUD.UserData as Item != this ||
|
||||
(editingHUDRefreshPending && editingHUDRefreshTimer <= 0.0f))
|
||||
{
|
||||
editingHUD = CreateEditingHUD(Screen.Selected != GameMain.SubEditorScreen);
|
||||
editingHUDRefreshTimer = 1.0f;
|
||||
}
|
||||
|
||||
if (Screen.Selected != GameMain.SubEditorScreen) return;
|
||||
if (Screen.Selected != GameMain.SubEditorScreen) { return; }
|
||||
|
||||
if (Character.Controlled == null) activeHUDs.Clear();
|
||||
if (Character.Controlled == null) { activeHUDs.Clear(); }
|
||||
|
||||
if (!Linkable) return;
|
||||
if (!Linkable) { return; }
|
||||
|
||||
if (!PlayerInput.KeyDown(Keys.Space)) return;
|
||||
if (!PlayerInput.KeyDown(Keys.Space)) { return; }
|
||||
bool lClick = PlayerInput.LeftButtonClicked();
|
||||
bool rClick = PlayerInput.RightButtonClicked();
|
||||
if (!lClick && !rClick) return;
|
||||
if (!lClick && !rClick) { return; }
|
||||
|
||||
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
var otherEntity = mapEntityList.FirstOrDefault(e => e != this && e.IsHighlighted && e.IsMouseOn(position));
|
||||
@@ -472,6 +479,8 @@ namespace Barotrauma
|
||||
|
||||
public GUIComponent CreateEditingHUD(bool inGame = false)
|
||||
{
|
||||
editingHUDRefreshPending = false;
|
||||
|
||||
int heightScaled = (int)(20 * GUI.Scale);
|
||||
editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GUI.Canvas, Anchor.CenterRight) { MinSize = new Point(400, 0) }) { UserData = this };
|
||||
GUIListBox listBox = new GUIListBox(new RectTransform(new Vector2(0.95f, 0.8f), editingHUD.RectTransform, Anchor.Center), style: null)
|
||||
@@ -672,6 +681,13 @@ namespace Barotrauma
|
||||
editingHUDCreated = editingHUD != null && editingHUD != prevEditingHUD;
|
||||
}
|
||||
|
||||
if (editingHUD == null ||
|
||||
!(GUI.KeyboardDispatcher.Subscriber is GUITextBox textBox) ||
|
||||
!editingHUD.IsParentOf(textBox))
|
||||
{
|
||||
editingHUDRefreshTimer -= deltaTime;
|
||||
}
|
||||
|
||||
List<ItemComponent> prevActiveHUDs = new List<ItemComponent>(activeHUDs);
|
||||
List<ItemComponent> activeComponents = new List<ItemComponent>(components);
|
||||
foreach (MapEntity entity in linkedTo)
|
||||
@@ -916,6 +932,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case NetEntityEvent.Type.ChangeProperty:
|
||||
ReadPropertyChange(msg, false);
|
||||
editingHUDRefreshPending = true;
|
||||
break;
|
||||
case NetEntityEvent.Type.Invalid:
|
||||
break;
|
||||
@@ -954,6 +971,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case NetEntityEvent.Type.ChangeProperty:
|
||||
WritePropertyChange(msg, extraData, true);
|
||||
editingHUDRefreshTimer = 1.0f;
|
||||
break;
|
||||
case NetEntityEvent.Type.Combine:
|
||||
UInt16 combineTargetID = (UInt16)extraData[1];
|
||||
@@ -969,6 +987,7 @@ namespace Barotrauma
|
||||
|
||||
if (parentInventory != null || body == null || !body.Enabled || Removed)
|
||||
{
|
||||
positionBuffer.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,138 +47,6 @@ namespace Barotrauma
|
||||
|
||||
partial class ItemPrefab : MapEntityPrefab
|
||||
{
|
||||
public class DecorativeSprite
|
||||
{
|
||||
public Sprite Sprite { get; private set; }
|
||||
|
||||
public enum AnimationType
|
||||
{
|
||||
None,
|
||||
Sine,
|
||||
Noise
|
||||
}
|
||||
|
||||
[Serialize("0,0", false)]
|
||||
public Vector2 Offset { get; private set; }
|
||||
|
||||
[Serialize(AnimationType.None, false)]
|
||||
public AnimationType OffsetAnim { get; private set; }
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
public float OffsetAnimSpeed { get; private set; }
|
||||
|
||||
private float rotationSpeedRadians;
|
||||
[Serialize(0.0f, false)]
|
||||
public float RotationSpeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return MathHelper.ToDegrees(rotationSpeedRadians);
|
||||
}
|
||||
private set
|
||||
{
|
||||
rotationSpeedRadians = MathHelper.ToRadians(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
public float Rotation { get; private set; }
|
||||
|
||||
[Serialize(AnimationType.None, false)]
|
||||
public AnimationType RotationAnim { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If > 0, only one sprite of the same group is used (chosen randomly)
|
||||
/// </summary>
|
||||
[Serialize(0, false)]
|
||||
public int RandomGroupID { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sprite is only drawn if these conditions are fulfilled
|
||||
/// </summary>
|
||||
public List<PropertyConditional> IsActiveConditionals { get; private set; } = new List<PropertyConditional>();
|
||||
/// <summary>
|
||||
/// The sprite is only animated if these conditions are fulfilled
|
||||
/// </summary>
|
||||
public List<PropertyConditional> AnimationConditionals { get; private set; } = new List<PropertyConditional>();
|
||||
|
||||
public DecorativeSprite(XElement element, string path = "", bool lazyLoad = false)
|
||||
{
|
||||
Sprite = new Sprite(element, path, lazyLoad: lazyLoad);
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
List<PropertyConditional> conditionalList = null;
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "conditional":
|
||||
case "isactiveconditional":
|
||||
conditionalList = IsActiveConditionals;
|
||||
break;
|
||||
case "animationconditional":
|
||||
conditionalList = AnimationConditionals;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
if (attribute.Name.ToString().ToLowerInvariant() == "targetitemcomponent") { continue; }
|
||||
conditionalList.Add(new PropertyConditional(attribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 GetOffset(ref float offsetState)
|
||||
{
|
||||
if (OffsetAnimSpeed <= 0.0f)
|
||||
{
|
||||
return Offset;
|
||||
}
|
||||
switch (OffsetAnim)
|
||||
{
|
||||
case AnimationType.Sine:
|
||||
offsetState = offsetState % (MathHelper.TwoPi / OffsetAnimSpeed);
|
||||
return Offset * (float)Math.Sin(offsetState * OffsetAnimSpeed);
|
||||
case AnimationType.Noise:
|
||||
offsetState = offsetState % (1.0f / (OffsetAnimSpeed * 0.1f));
|
||||
|
||||
float t = offsetState * 0.1f * OffsetAnimSpeed;
|
||||
return new Vector2(
|
||||
Offset.X * (PerlinNoise.GetPerlin(t, t) - 0.5f),
|
||||
Offset.Y * (PerlinNoise.GetPerlin(t + 0.5f, t + 0.5f) - 0.5f));
|
||||
default:
|
||||
return Offset;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetRotation(ref float rotationState)
|
||||
{
|
||||
if (rotationSpeedRadians <= 0.0f)
|
||||
{
|
||||
return Rotation;
|
||||
}
|
||||
switch (OffsetAnim)
|
||||
{
|
||||
case AnimationType.Sine:
|
||||
rotationState = rotationState % (MathHelper.TwoPi / rotationSpeedRadians);
|
||||
return Rotation * (float)Math.Sin(rotationState * rotationSpeedRadians);
|
||||
case AnimationType.Noise:
|
||||
rotationState = rotationState % (1.0f / rotationSpeedRadians);
|
||||
return Rotation * PerlinNoise.GetPerlin(rotationState * rotationSpeedRadians, rotationState * rotationSpeedRadians);
|
||||
default:
|
||||
return rotationState * rotationSpeedRadians;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
Sprite?.Remove();
|
||||
Sprite = null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<BrokenItemSprite> BrokenSprites = new List<BrokenItemSprite>();
|
||||
public List<DecorativeSprite> DecorativeSprites = new List<DecorativeSprite>();
|
||||
public List<ContainedItemSprite> ContainedSprites = new List<ContainedItemSprite>();
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return Vector2.Zero; }
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user