Server log, ai characters steer away from the abyss
This commit is contained in:
@@ -466,7 +466,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
if (sendingTime < lastReceivedMessage) return;
|
||||
|
||||
|
||||
@@ -158,10 +158,13 @@ namespace Barotrauma.Items.Components
|
||||
item.SetTransform(rightHand.SimPosition, 0.0f);
|
||||
}
|
||||
|
||||
bool alreadySelected = character.HasSelectedItem(item);
|
||||
if (picker.TrySelectItem(item))
|
||||
{
|
||||
item.body.Enabled = true;
|
||||
IsActive = true;
|
||||
|
||||
if (!alreadySelected) Barotrauma.Networking.GameServer.Log(character.Name+" equipped "+item.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +174,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
picker.DeselectItem(item);
|
||||
|
||||
Barotrauma.Networking.GameServer.Log(character.Name + " unequipped " + item.Name);
|
||||
|
||||
item.body.Enabled = false;
|
||||
IsActive = false;
|
||||
}
|
||||
@@ -296,7 +301,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
Vector2 newPos = Vector2.Zero;
|
||||
|
||||
|
||||
@@ -135,12 +135,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
leftHand.Disabled = true;
|
||||
leftHand.pullJoint.Enabled = true;
|
||||
leftHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * (float)Math.Sin(pickTimer*10.0f)*0.1f;
|
||||
leftHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * ((pickTimer / 10.0f) % 0.1f);
|
||||
|
||||
rightHand.Disabled = true;
|
||||
rightHand.pullJoint.Enabled = true;
|
||||
rightHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * (float)Math.Sin(pickTimer*10.0f) * 0.1f;
|
||||
|
||||
rightHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * ((pickTimer / 10.0f) % 0.1f);
|
||||
|
||||
pickTimer += CoroutineManager.DeltaTime;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
protected void DropConnectedWires(Character character)
|
||||
{
|
||||
if (character == null) return;
|
||||
Vector2 pos = character == null ? item.SimPosition : character.SimPosition;
|
||||
|
||||
var connectionPanel = item.GetComponent<ConnectionPanel>();
|
||||
if (connectionPanel == null) return;
|
||||
@@ -173,7 +173,7 @@ namespace Barotrauma.Items.Components
|
||||
if (w == null) continue;
|
||||
|
||||
w.Item.Drop(character);
|
||||
w.Item.SetTransform(character.SimPosition, 0.0f);
|
||||
w.Item.SetTransform(pos, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime)
|
||||
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,10 @@ namespace Barotrauma.Items.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (character!=null) item.SendSignal(ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out");
|
||||
Entity focusTarget = null;
|
||||
|
||||
if (character == null) return;
|
||||
|
||||
|
||||
foreach (Connection c in item.Connections)
|
||||
{
|
||||
@@ -162,17 +165,28 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (c2 == null || c2.Item == null || !c2.Item.Prefab.FocusOnSelected) continue;
|
||||
|
||||
Vector2 centerPos = c2.Item.WorldPosition;
|
||||
|
||||
if (character == Character.Controlled && cam != null)
|
||||
{
|
||||
Lights.LightManager.ViewTarget = c2.Item;
|
||||
cam.TargetPos = c2.Item.WorldPosition;
|
||||
}
|
||||
focusTarget = c2.Item;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (focusTarget == null)
|
||||
{
|
||||
item.SendSignal(ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out");
|
||||
return;
|
||||
}
|
||||
|
||||
if (character == Character.Controlled && cam != null)
|
||||
{
|
||||
Lights.LightManager.ViewTarget = focusTarget;
|
||||
cam.TargetPos = focusTarget.WorldPosition;
|
||||
}
|
||||
|
||||
if (!character.IsNetworkPlayer || character.ViewTarget == focusTarget)
|
||||
{
|
||||
item.SendSignal(ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out");
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
if (sendingTime < lastNetworkUpdate) return;
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
if (sendingTime < lastNetworkUpdate) return;
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
float newFlow = 0.0f;
|
||||
bool newActive;
|
||||
@@ -230,6 +230,15 @@ namespace Barotrauma.Items.Components
|
||||
IsActive = newActive;
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null)
|
||||
{
|
||||
Networking.GameServer.Log("Pump settings adjusted by " + sender.name);
|
||||
Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -361,6 +361,8 @@ namespace Barotrauma.Items.Components
|
||||
private void MeltDown()
|
||||
{
|
||||
if (item.Condition <= 0.0f) return;
|
||||
|
||||
GameServer.Log("Reactor meltdown!");
|
||||
|
||||
new RepairTask(item, 60.0f, "Reactor meltdown!");
|
||||
item.Condition = 0.0f;
|
||||
@@ -539,7 +541,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
if (sendingTime < lastUpdate) return;
|
||||
|
||||
@@ -574,6 +576,17 @@ namespace Barotrauma.Items.Components
|
||||
FissionRate = newFissionRate;
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null)
|
||||
{
|
||||
Networking.GameServer.Log("Reactor settings adjusted by " + sender.name);
|
||||
Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+coolingRate+" Fission rate: "+fissionRate);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
Vector2 newTargetVelocity = Vector2.Zero;
|
||||
bool newAutoPilot = false;
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
float newRechargeSpeed = 0f;
|
||||
float newCharge = 0.0f;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Barotrauma.Items.Components
|
||||
private static Sprite wireCorner, wireVertical, wireHorizontal;
|
||||
|
||||
//how many wires can be linked to a single connector
|
||||
private const int MaxLinked = 5;
|
||||
public const int MaxLinked = 5;
|
||||
|
||||
public readonly string Name;
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Barotrauma.Items.Components
|
||||
foreach (Connection c in Connections)
|
||||
{
|
||||
Wire[] wires = Array.FindAll(c.Wires, w => w != null);
|
||||
message.Write((byte)wires.Length);
|
||||
message.WriteRangedInteger(0, Connection.MaxLinked, wires.Length);
|
||||
for (int i = 0 ; i < wires.Length; i++)
|
||||
{
|
||||
message.Write(wires[i].Item.ID);
|
||||
@@ -139,15 +139,24 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null)
|
||||
{
|
||||
Networking.GameServer.Log(item.Name + " rewired by " + sender.name);
|
||||
}
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("connectionpanel update");
|
||||
foreach (Connection c in Connections)
|
||||
{
|
||||
//int wireCount = c.Wires.Length;
|
||||
c.ClearConnections();
|
||||
|
||||
byte wireCount = message.ReadByte();
|
||||
int wireCount = message.ReadRangedInteger(0, Connection.MaxLinked);
|
||||
|
||||
for (int i = 0; i < wireCount; i++)
|
||||
{
|
||||
@@ -161,6 +170,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
c.Wires[i] = wireComponent;
|
||||
wireComponent.Connect(c, false);
|
||||
|
||||
var otherConnection = c.Wires[i].OtherConnection(c);
|
||||
Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name));
|
||||
}
|
||||
c.UpdateRecipients();
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
Nodes.Clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user