Build 0.21.6.0 (1.0 pre-patch)
This commit is contained in:
@@ -329,6 +329,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void UpdateSignalsProjSpecific()
|
||||
{
|
||||
if (signals == null) { return; }
|
||||
for (int i = 0; i < signals.Length && i < uiElements.Count; i++)
|
||||
{
|
||||
if (uiElements[i] is GUITextBox tb)
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace Barotrauma.Items.Components
|
||||
public static Color editorHighlightColor = Color.Yellow;
|
||||
public static Color editorSelectedColor = Color.Red;
|
||||
|
||||
partial class WireSection
|
||||
public partial class WireSection
|
||||
{
|
||||
public VertexPositionColorTexture[] vertices;
|
||||
public VertexPositionColorTexture[] shiftedVertices;
|
||||
|
||||
private float cachedWidth = 0f;
|
||||
|
||||
private void RecalculateVertices(Wire wire, float width)
|
||||
private void RecalculateVertices(Sprite wireSprite, float width)
|
||||
{
|
||||
if (MathUtils.NearlyEqual(cachedWidth, width)) { return; }
|
||||
cachedWidth = width;
|
||||
@@ -45,13 +45,13 @@ namespace Barotrauma.Items.Components
|
||||
expandDir.X = -expandDir.Y;
|
||||
expandDir.Y = -temp;
|
||||
|
||||
Rectangle srcRect = wire.wireSprite.SourceRect;
|
||||
Rectangle srcRect = wireSprite.SourceRect;
|
||||
|
||||
expandDir *= width * srcRect.Height * 0.5f;
|
||||
|
||||
Vector2 rectLocation = srcRect.Location.ToVector2();
|
||||
Vector2 rectSize = srcRect.Size.ToVector2();
|
||||
Vector2 textureSize = new Vector2(wire.wireSprite.Texture.Width, wire.wireSprite.Texture.Height);
|
||||
Vector2 textureSize = new Vector2(wireSprite.Texture.Width, wireSprite.Texture.Height);
|
||||
|
||||
Vector2 topLeftUv = rectLocation / textureSize;
|
||||
Vector2 bottomRightUv = (rectLocation + rectSize) / textureSize;
|
||||
@@ -67,10 +67,10 @@ namespace Barotrauma.Items.Components
|
||||
shiftedVertices = (VertexPositionColorTexture[])vertices.Clone();
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Wire wire, Color color, Vector2 offset, float depth, float width = 0.3f)
|
||||
public void Draw(ISpriteBatch spriteBatch, Sprite wireSprite, Color color, Vector2 offset, float depth, float width = 0.3f)
|
||||
{
|
||||
if (width <= 0f) { return; }
|
||||
RecalculateVertices(wire, width);
|
||||
RecalculateVertices(wireSprite, width);
|
||||
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
@@ -79,21 +79,22 @@ namespace Barotrauma.Items.Components
|
||||
shiftedVertices[i].Position.X += offset.X;
|
||||
shiftedVertices[i].Position.Y -= offset.Y;
|
||||
}
|
||||
spriteBatch.Draw(wire.wireSprite.Texture,
|
||||
spriteBatch.Draw(
|
||||
wireSprite.Texture,
|
||||
shiftedVertices,
|
||||
depth);
|
||||
}
|
||||
|
||||
public static void Draw(SpriteBatch spriteBatch, Wire wire, Vector2 start, Vector2 end, Color color, float depth, float width = 0.3f)
|
||||
public static void Draw(ISpriteBatch spriteBatch, Sprite wireSprite, Vector2 start, Vector2 end, Color color, float depth, float width = 0.3f)
|
||||
{
|
||||
start.Y = -start.Y;
|
||||
end.Y = -end.Y;
|
||||
|
||||
spriteBatch.Draw(wire.wireSprite.Texture,
|
||||
start, wire.wireSprite.SourceRect, color,
|
||||
spriteBatch.Draw(wireSprite.Texture,
|
||||
start, wireSprite.SourceRect, color,
|
||||
MathUtils.VectorToAngle(end - start),
|
||||
new Vector2(0.0f, wire.wireSprite.size.Y / 2.0f),
|
||||
new Vector2((Vector2.Distance(start, end)) / wire.wireSprite.size.X, width),
|
||||
new Vector2(0.0f, wireSprite.size.Y / 2.0f),
|
||||
new Vector2((Vector2.Distance(start, end)) / wireSprite.size.X, width),
|
||||
SpriteEffects.None,
|
||||
depth);
|
||||
}
|
||||
@@ -123,7 +124,7 @@ namespace Barotrauma.Items.Components
|
||||
get => draggingWire;
|
||||
}
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
public static Sprite ExtractWireSprite(ContentXElement element)
|
||||
{
|
||||
if (defaultWireSprite == null)
|
||||
{
|
||||
@@ -133,6 +134,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
}
|
||||
|
||||
Sprite overrideSprite = null;
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().Equals("wiresprite", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -142,9 +144,14 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
wireSprite = overrideSprite ?? defaultWireSprite;
|
||||
return overrideSprite ?? defaultWireSprite;
|
||||
}
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
wireSprite = ExtractWireSprite(element);
|
||||
if (wireSprite != defaultWireSprite) { overrideSprite = wireSprite; }
|
||||
}
|
||||
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
|
||||
{
|
||||
@@ -181,20 +188,20 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
foreach (WireSection section in sections)
|
||||
{
|
||||
section.Draw(spriteBatch, this, Screen.Selected == GameMain.GameScreen ? higlightColor : editorHighlightColor, drawOffset, depth + 0.00001f, Width * 2.0f);
|
||||
section.Draw(spriteBatch, wireSprite, Screen.Selected == GameMain.GameScreen ? higlightColor : editorHighlightColor, drawOffset, depth + 0.00001f, Width * 2.0f);
|
||||
}
|
||||
}
|
||||
else if (item.IsSelected)
|
||||
{
|
||||
foreach (WireSection section in sections)
|
||||
{
|
||||
section.Draw(spriteBatch, this, editorSelectedColor, drawOffset, depth + 0.00001f, Width * 2.0f);
|
||||
section.Draw(spriteBatch, wireSprite, editorSelectedColor, drawOffset, depth + 0.00001f, Width * 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (WireSection section in sections)
|
||||
{
|
||||
section.Draw(spriteBatch, this, item.Color, drawOffset, depth, Width);
|
||||
section.Draw(spriteBatch, wireSprite, item.Color, drawOffset, depth, Width);
|
||||
}
|
||||
|
||||
if (nodes.Count > 0)
|
||||
@@ -239,13 +246,13 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
WireSection.Draw(
|
||||
spriteBatch, this,
|
||||
new Vector2(nodes[nodes.Count - 1].X, nodes[nodes.Count - 1].Y) + drawOffset,
|
||||
spriteBatch, wireSprite,
|
||||
nodes[^1] + drawOffset,
|
||||
new Vector2(newNodePos.X, newNodePos.Y) + drawOffset,
|
||||
item.Color, 0.0f, Width);
|
||||
|
||||
WireSection.Draw(
|
||||
spriteBatch, this,
|
||||
spriteBatch, wireSprite,
|
||||
new Vector2(newNodePos.X, newNodePos.Y) + drawOffset,
|
||||
item.DrawPosition,
|
||||
item.Color, itemDepth, Width);
|
||||
@@ -255,8 +262,8 @@ namespace Barotrauma.Items.Components
|
||||
else
|
||||
{
|
||||
WireSection.Draw(
|
||||
spriteBatch, this,
|
||||
new Vector2(nodes[nodes.Count - 1].X, nodes[nodes.Count - 1].Y) + drawOffset,
|
||||
spriteBatch, wireSprite,
|
||||
nodes[^1] + drawOffset,
|
||||
item.DrawPosition,
|
||||
item.Color, 0.0f, Width);
|
||||
}
|
||||
@@ -294,12 +301,12 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 endPos = start + new Vector2((float)Math.Sin(angle), -(float)Math.Cos(angle)) * 50.0f;
|
||||
|
||||
WireSection.Draw(
|
||||
spriteBatch, this,
|
||||
spriteBatch, wireSprite,
|
||||
start, endPos,
|
||||
GUIStyle.Orange, depth + 0.00001f, 0.2f);
|
||||
|
||||
WireSection.Draw(
|
||||
spriteBatch, this,
|
||||
spriteBatch, wireSprite,
|
||||
start, start + (endPos - start) * 0.7f,
|
||||
item.Color, depth, 0.3f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user