- syncing docking ports
- linkedsubmarine saving fixes, path can be changed and sub reloaded in editinghub - lightsources don't constantly recheck convex hulls of another sub if subs are docked - position update networkevents arent sent for subs that are docked to the main sub
This commit is contained in:
@@ -345,8 +345,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
|
||||
|
||||
if (dockingTarget == null)
|
||||
{
|
||||
dockingState = MathHelper.Lerp(dockingState, 0.0f, deltaTime * 10.0f);
|
||||
@@ -411,7 +409,7 @@ namespace Barotrauma.Items.Components
|
||||
drawPos - Vector2.UnitX * (rect.Width / 2 * dockingState),
|
||||
new Rectangle(
|
||||
rect.X, rect.Y,
|
||||
(int)(rect.Width / 2 * dockingState), rect.Height), Color.Red);
|
||||
(int)(rect.Width / 2 * dockingState), rect.Height), Color.White);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -433,7 +431,7 @@ namespace Barotrauma.Items.Components
|
||||
drawPos - Vector2.UnitY * (rect.Height / 2 * dockingState),
|
||||
new Rectangle(
|
||||
rect.X, rect.Y,
|
||||
rect.Width, (int)(rect.Height / 2 * dockingState)), Color.Red);
|
||||
rect.Width, (int)(rect.Height / 2 * dockingState)), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -456,6 +454,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f)
|
||||
{
|
||||
if (GameMain.Client != null) return;
|
||||
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "toggle":
|
||||
@@ -466,6 +466,50 @@ namespace Barotrauma.Items.Components
|
||||
Docked = signal != "0";
|
||||
break;
|
||||
}
|
||||
|
||||
item.NewComponentEvent(this, false, true);
|
||||
}
|
||||
|
||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||
{
|
||||
message.Write(docked);
|
||||
|
||||
if (docked)
|
||||
{
|
||||
message.Write(dockingTarget.item.ID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
bool isDocked = message.ReadBoolean();
|
||||
|
||||
if (isDocked)
|
||||
{
|
||||
ushort dockingTargetID = message.ReadUInt16();
|
||||
Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
|
||||
if (targetEntity == null || !(targetEntity is Item))
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid docking port network event (can't dock to "+targetEntity.ToString()+")");
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
Undock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,10 +204,17 @@ namespace Barotrauma.Items.Components
|
||||
// position.Y += item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
|
||||
//}
|
||||
|
||||
|
||||
Submarine sub = null;
|
||||
if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine;
|
||||
if (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine;
|
||||
|
||||
if (item.Submarine != sub)
|
||||
{
|
||||
ClearConnections();
|
||||
Nodes.Clear();
|
||||
}
|
||||
|
||||
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
|
||||
|
||||
//if (Vector2.Distance(position, nodes[nodes.Count - 1]) > nodeDistance*10)
|
||||
|
||||
Reference in New Issue
Block a user