Docking ports have a power connector that can be used for distributing power between docked subs, already connected wires in respawn shuttles and the tutorial subs can't be disconnected, flares burn longer
This commit is contained in:
@@ -96,6 +96,9 @@
|
||||
<sound file="dockingport2.ogg" type="OnSecondaryUse" range="1000.0"/>
|
||||
</DockingPort>
|
||||
|
||||
<PowerTransfer/>
|
||||
<Wire/>
|
||||
|
||||
<fixrequirement name="Mechanical repairs">
|
||||
<skill name="Construction" level="60"/>
|
||||
<item name="Welding Tool"/>
|
||||
@@ -105,6 +108,7 @@
|
||||
<requireditem name="Screwdriver" type="Equipped"/>
|
||||
<input name="toggle"/>
|
||||
<input name="set_state"/>
|
||||
<input name="power"/>
|
||||
<output name="state_out"/>
|
||||
<output name="proximity_sensor"/>
|
||||
</ConnectionPanel>
|
||||
@@ -123,6 +127,15 @@
|
||||
<sound file="dockingport2.ogg" type="OnSecondaryUse" range="1000.0"/>
|
||||
</DockingPort>
|
||||
|
||||
<fixrequirement name="Electrical repairs">
|
||||
<skill name="Electrical Engineering" level="40"/>
|
||||
<item name="Wire"/>
|
||||
<item name="Screwdriver"/>
|
||||
</fixrequirement>
|
||||
|
||||
<PowerTransfer/>
|
||||
<Wire/>
|
||||
|
||||
<fixrequirement name="Mechanical repairs">
|
||||
<skill name="Construction" level="60"/>
|
||||
<item name="Welding Tool"/>
|
||||
@@ -132,6 +145,7 @@
|
||||
<requireditem name="Screwdriver" type="Equipped"/>
|
||||
<input name="toggle"/>
|
||||
<input name="set_state"/>
|
||||
<input name="power"/>
|
||||
<output name="state_out"/>
|
||||
<output name="proximity_sensor"/>
|
||||
</ConnectionPanel>
|
||||
|
||||
@@ -268,7 +268,7 @@
|
||||
<LightComponent LightColor="1.0,0.0,0.0,1.0" Flicker="0.5" range="600" IsOn="false">
|
||||
<StatusEffect type="OnUse" target="This" IsOn="true"/>
|
||||
|
||||
<StatusEffect type="OnActive" target="This" Condition="-5.0">
|
||||
<StatusEffect type="OnActive" target="This" Condition="-1.0">
|
||||
<ParticleEmitter particle="flare"/>
|
||||
<ParticleEmitter particle="bubbles"/>
|
||||
</StatusEffect>
|
||||
|
||||
@@ -18,12 +18,19 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
public override IEnumerable<object> UpdateState()
|
||||
{
|
||||
//Submarine.Loaded.SetPosition(new Vector2(Submarine.Loaded.Position.X, 38500.0f));
|
||||
|
||||
//spawn some fish next to the player
|
||||
GameMain.GameScreen.BackgroundCreatureManager.SpawnSprites(2,
|
||||
Submarine.MainSub.Position + Character.Controlled.Position);
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
var wire = item.GetComponent<Wire>();
|
||||
if (wire != null && wire.Connections.Any(c => c != null))
|
||||
{
|
||||
wire.Locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(4.0f);
|
||||
|
||||
infoBox = CreateInfoFrame("Use WASD to move and the mouse to look around");
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Barotrauma.Items.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IsActive = true;
|
||||
|
||||
hullIds = new ushort?[2];
|
||||
@@ -131,18 +131,25 @@ namespace Barotrauma.Items.Components
|
||||
private void AttemptDock()
|
||||
{
|
||||
var adjacentPort = FindAdjacentPort();
|
||||
|
||||
if (adjacentPort != null) Dock(adjacentPort);
|
||||
}
|
||||
|
||||
public void Dock(DockingPort target)
|
||||
{
|
||||
if (item.Submarine.DockedTo.Contains(target.item.Submarine)) return;
|
||||
|
||||
|
||||
if (dockingTarget != null)
|
||||
{
|
||||
Undock();
|
||||
}
|
||||
|
||||
if (target.item.Submarine == item.Submarine)
|
||||
{
|
||||
DebugConsole.ThrowError("Error - tried to a submarine to itself");
|
||||
return;
|
||||
}
|
||||
|
||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
|
||||
if (!item.linkedTo.Contains(target.item)) item.linkedTo.Add(target.item);
|
||||
@@ -225,6 +232,32 @@ namespace Barotrauma.Items.Components
|
||||
joint.CollideConnected = true;
|
||||
}
|
||||
|
||||
private void ConnectWireBetweenPorts()
|
||||
{
|
||||
Wire wire = item.GetComponent<Wire>();
|
||||
if (wire == null) return;
|
||||
|
||||
wire.Hidden = true;
|
||||
wire.Locked = true;
|
||||
|
||||
if (Item.Connections == null) return;
|
||||
|
||||
var powerConnection = Item.Connections.Find(c => c.IsPower);
|
||||
if (powerConnection == null) return;
|
||||
|
||||
if (dockingTarget == null || dockingTarget.item.Connections == null) return;
|
||||
var recipient = dockingTarget.item.Connections.Find(c => c.IsPower);
|
||||
if (recipient == null) return;
|
||||
|
||||
wire.RemoveConnection(item);
|
||||
wire.RemoveConnection(dockingTarget.item);
|
||||
|
||||
powerConnection.AddLink(4, wire);
|
||||
wire.Connect(powerConnection, false);
|
||||
recipient.AddLink(4, wire);
|
||||
wire.Connect(recipient, false);
|
||||
}
|
||||
|
||||
private void CreateHull()
|
||||
{
|
||||
var hullRects = new Rectangle[] { item.WorldRect, dockingTarget.item.WorldRect };
|
||||
@@ -374,6 +407,12 @@ namespace Barotrauma.Items.Components
|
||||
dockingTarget.Undock();
|
||||
dockingTarget = null;
|
||||
|
||||
var wire = item.GetComponent<Wire>();
|
||||
if (wire != null)
|
||||
{
|
||||
wire.Drop(null);
|
||||
}
|
||||
|
||||
if (joint != null)
|
||||
{
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
@@ -427,17 +466,6 @@ namespace Barotrauma.Items.Components
|
||||
if (!docked)
|
||||
{
|
||||
Dock(dockingTarget);
|
||||
|
||||
//if (joint.BodyA.Mass < joint.BodyB.Mass)
|
||||
//{
|
||||
// joint.BodyA.SetTransform(joint.BodyA.Position + (joint.WorldAnchorB - joint.WorldAnchorA), 0.0f);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// joint.BodyB.SetTransform(joint.BodyB.Position + (joint.WorldAnchorA - joint.WorldAnchorB), 0.0f);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (joint is DistanceJoint)
|
||||
@@ -450,6 +478,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
PlaySound(ActionType.OnSecondaryUse, item.WorldPosition);
|
||||
|
||||
ConnectWireBetweenPorts();
|
||||
|
||||
|
||||
CreateJoint(true);
|
||||
|
||||
if (!item.linkedTo.Any(e => e is Hull) && !dockingTarget.item.linkedTo.Any(e => e is Hull))
|
||||
|
||||
@@ -175,6 +175,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
if (!canBeSelected) return;
|
||||
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public readonly bool IsOutput;
|
||||
|
||||
private static Item draggingConnected;
|
||||
private static Wire draggingConnected;
|
||||
|
||||
private List<StatusEffect> effects;
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Barotrauma.Items.Components
|
||||
//dropped or dragged from the panel to the players inventory
|
||||
if (draggingConnected != null)
|
||||
{
|
||||
int linkIndex = c.FindWireIndex(draggingConnected);
|
||||
int linkIndex = c.FindWireIndex(draggingConnected.Item);
|
||||
if (linkIndex>-1)
|
||||
{
|
||||
Inventory.draggingItem = c.Wires[linkIndex].Item;
|
||||
@@ -279,11 +279,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (panel.Connections.Find(c => c.Wires.Contains(equippedWire)) == null)
|
||||
{
|
||||
DrawWire(spriteBatch, equippedWire.Item, equippedWire.Item,
|
||||
DrawWire(spriteBatch, equippedWire, equippedWire.Item,
|
||||
new Vector2(x + width / 2, y + height - 100),
|
||||
new Vector2(x + width / 2, y + height), mouseInRect, false);
|
||||
|
||||
if (draggingConnected == equippedWire.Item) Inventory.draggingItem = equippedWire.Item;
|
||||
if (draggingConnected == equippedWire) Inventory.draggingItem = equippedWire.Item;
|
||||
|
||||
//break;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (draggingConnected != null)
|
||||
{
|
||||
DrawWire(spriteBatch, draggingConnected, draggingConnected, PlayerInput.MousePosition, new Vector2(x + width / 2, y + height), mouseInRect, false);
|
||||
DrawWire(spriteBatch, draggingConnected, draggingConnected.Item, PlayerInput.MousePosition, new Vector2(x + width / 2, y + height), mouseInRect, false);
|
||||
|
||||
if (!PlayerInput.LeftButtonHeld())
|
||||
{
|
||||
@@ -318,11 +318,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
for (int i = 0; i<MaxLinked; i++)
|
||||
{
|
||||
if (Wires[i]==null || draggingConnected == Wires[i].Item) continue;
|
||||
if (Wires[i]==null || Wires[i].Hidden || draggingConnected == Wires[i]) continue;
|
||||
|
||||
Connection recipient = Wires[i].OtherConnection(this);
|
||||
|
||||
DrawWire(spriteBatch, Wires[i].Item, (recipient == null) ? Wires[i].Item : recipient.item, position, wirePosition, mouseIn, wireEquipped);
|
||||
DrawWire(spriteBatch, Wires[i], (recipient == null) ? Wires[i].Item : recipient.item, position, wirePosition, mouseIn, wireEquipped);
|
||||
|
||||
wirePosition.Y += wireInterval;
|
||||
}
|
||||
@@ -336,31 +336,29 @@ namespace Barotrauma.Items.Components
|
||||
//find an empty cell for the new connection
|
||||
int index = FindWireIndex(null);
|
||||
|
||||
Wire wireComponent = draggingConnected.GetComponent<Wire>();
|
||||
|
||||
if (index > -1 && wireComponent != null && !Wires.Contains(wireComponent))
|
||||
if (index > -1 && !Wires.Contains(draggingConnected))
|
||||
{
|
||||
bool alreadyConnected = wireComponent.IsConnectedTo(item);
|
||||
bool alreadyConnected = draggingConnected.IsConnectedTo(item);
|
||||
|
||||
wireComponent.RemoveConnection(item);
|
||||
draggingConnected.RemoveConnection(item);
|
||||
|
||||
if (wireComponent.Connect(this, !alreadyConnected)) Wires[index] = wireComponent;
|
||||
if (draggingConnected.Connect(this, !alreadyConnected)) Wires[index] = draggingConnected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int screwIndex = (position.Y % 60 < 30) ? 0 : 1;
|
||||
|
||||
if (Wires.Any(w => w != null && w.Item != draggingConnected))
|
||||
if (Wires.Any(w => w != null && w != draggingConnected))
|
||||
{
|
||||
spriteBatch.Draw(panelTexture, position - new Vector2(16.0f, 16.0f), new Rectangle(screwIndex*32, 256, 32, 32), Color.White);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void DrawWire(SpriteBatch spriteBatch, Item wireItem, Item item, Vector2 end, Vector2 start, bool mouseIn, bool wireEquipped)
|
||||
private static void DrawWire(SpriteBatch spriteBatch, Wire wire, Item item, Vector2 end, Vector2 start, bool mouseIn, bool wireEquipped)
|
||||
{
|
||||
if (draggingConnected == wireItem)
|
||||
if (draggingConnected == wire)
|
||||
{
|
||||
if (!mouseIn) return;
|
||||
end = PlayerInput.MousePosition;
|
||||
@@ -377,16 +375,18 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
bool mouseOn =
|
||||
!wireEquipped &&
|
||||
(PlayerInput.MousePosition.X > Math.Min(start.X, end.X) &&
|
||||
((PlayerInput.MousePosition.X > Math.Min(start.X, end.X) &&
|
||||
PlayerInput.MousePosition.X < Math.Max(start.X, end.X) &&
|
||||
MathUtils.LineToPointDistance(start, end, PlayerInput.MousePosition) < 6) ||
|
||||
Vector2.Distance(end, PlayerInput.MousePosition)<20.0f ||
|
||||
new Rectangle((start.X < end.X) ? textX-100 : textX, (int)start.Y-5, 100, 14).Contains(PlayerInput.MousePosition);
|
||||
new Rectangle((start.X < end.X) ? textX-100 : textX, (int)start.Y-5, 100, 14).Contains(PlayerInput.MousePosition));
|
||||
|
||||
string label = wire.Locked ? item.Name +"\n(Locked)" : item.Name;
|
||||
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(start.X < end.X ? textX-GUI.SmallFont.MeasureString(item.Name).X : textX,start.Y -5.0f),
|
||||
item.Name,
|
||||
mouseOn ? Color.Gold : Color.White, Color.Black * 0.8f,
|
||||
new Vector2(start.X < end.X ? textX-GUI.SmallFont.MeasureString(label).X : textX,start.Y -5.0f),
|
||||
label,
|
||||
(mouseOn ? Color.Gold : Color.White) * (wire.Locked ? 0.6f : 1.0f), Color.Black * 0.8f,
|
||||
3, GUI.SmallFont);
|
||||
|
||||
var wireEnd = end + Vector2.Normalize(start - end) * 30.0f;
|
||||
@@ -403,7 +403,7 @@ namespace Barotrauma.Items.Components
|
||||
0.0f);
|
||||
}
|
||||
spriteBatch.Draw(wireVertical.Texture, new Rectangle(wireEnd.ToPoint(), new Point(12, (int)dist)), wireVertical.SourceRect,
|
||||
wireItem.Color * alpha,
|
||||
wire.Item.Color * alpha,
|
||||
MathUtils.VectorToAngle(end - start) + MathHelper.PiOver2, //angle of line (calulated above)
|
||||
new Vector2(6, 0), // point in line about which to rotate
|
||||
SpriteEffects.None,
|
||||
@@ -416,10 +416,14 @@ namespace Barotrauma.Items.Components
|
||||
if (mouseOn)
|
||||
{
|
||||
item.IsHighlighted = true;
|
||||
wireItem.IsHighlighted = true;
|
||||
wire.Item.IsHighlighted = true;
|
||||
|
||||
//start dragging the wire
|
||||
if (PlayerInput.LeftButtonHeld()) draggingConnected = wireItem;
|
||||
if (!wire.Locked)
|
||||
{
|
||||
//start dragging the wire
|
||||
if (PlayerInput.LeftButtonHeld()) draggingConnected = wire;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -466,7 +470,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (Wires[i]!=null)
|
||||
{
|
||||
Wires[i].Item.body.Enabled = false;
|
||||
if (Wires[i].Item.body != null) Wires[i].Item.body.Enabled = false;
|
||||
Wires[i].Connect(this, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Barotrauma.Items.Components
|
||||
private static Wire draggingWire;
|
||||
private static int? selectedNodeIndex;
|
||||
|
||||
public bool Hidden, Locked;
|
||||
|
||||
public Connection[] Connections
|
||||
{
|
||||
get { return connections; }
|
||||
@@ -109,7 +111,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
item.Submarine = newConnection.Item.Submarine;
|
||||
if (item.body != null) item.Submarine = newConnection.Item.Submarine;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
@@ -149,7 +151,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
if (item.Container != null) item.Container.RemoveContained(this.item);
|
||||
|
||||
item.body.Enabled = false;
|
||||
if (item.body != null) item.body.Enabled = false;
|
||||
|
||||
IsActive = false;
|
||||
|
||||
|
||||
@@ -82,13 +82,23 @@ namespace Barotrauma.Networking
|
||||
|
||||
var door = item.GetComponent<Door>();
|
||||
if (door != null) shuttleDoors.Add(door);
|
||||
|
||||
//lock all wires to prevent the players from messing up the electronics
|
||||
var connectionPanel = item.GetComponent<ConnectionPanel>();
|
||||
if (connectionPanel != null)
|
||||
{
|
||||
foreach (Connection connection in connectionPanel.Connections)
|
||||
{
|
||||
Array.ForEach(connection.Wires, w => { if (w != null) w.Locked = true; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shuttleSteering != null)
|
||||
{
|
||||
shuttleSteering.TargetPosition = ConvertUnits.ToSimUnits(Level.Loaded.StartPosition);
|
||||
}
|
||||
|
||||
|
||||
var server = networkMember as GameServer;
|
||||
if (server != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user