- Fixed railgun sounds not playing at the clients' end
- Server sends updates for batteries when their charge changes (not strictly necessary assuming the rest of the electrical grid stays in sync, but just in case) - Reactor state is synced with clients if modified through the debug console - Increased maximum item velocity to 64 units/s, all item are clamped to the max vel
This commit is contained in:
@@ -1617,7 +1617,7 @@ namespace Barotrauma
|
|||||||
//GUI.DrawLine(spriteBatch, remoteVec, localVec, Color.Yellow, 0, 10);
|
//GUI.DrawLine(spriteBatch, remoteVec, localVec, Color.Yellow, 0, 10);
|
||||||
if (localPos1 != null) GUI.DrawLine(spriteBatch, remoteVec, localVec1, Color.Lime, 0, 2);
|
if (localPos1 != null) GUI.DrawLine(spriteBatch, remoteVec, localVec1, Color.Lime, 0, 2);
|
||||||
if (localPos2 != null) GUI.DrawLine(spriteBatch, remoteVec + Vector2.One, localVec2 + Vector2.One, Color.Red, 0, 2);
|
if (localPos2 != null) GUI.DrawLine(spriteBatch, remoteVec + Vector2.One, localVec2 + Vector2.One, Color.Red, 0, 2);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
Vector2 mouseDrawPos = CursorWorldPosition;
|
Vector2 mouseDrawPos = CursorWorldPosition;
|
||||||
mouseDrawPos.Y = -mouseDrawPos.Y;
|
mouseDrawPos.Y = -mouseDrawPos.Y;
|
||||||
@@ -1625,7 +1625,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector2 closestItemPos = closestItem != null ? closestItem.DrawPosition : Vector2.Zero;
|
Vector2 closestItemPos = closestItem != null ? closestItem.DrawPosition : Vector2.Zero;
|
||||||
closestItemPos.Y = -closestItemPos.Y;
|
closestItemPos.Y = -closestItemPos.Y;
|
||||||
GUI.DrawLine(spriteBatch, closestItemPos - new Vector2(0, 5), closestItemPos + new Vector2(0, 5), Color.Lime, 0, 10);
|
GUI.DrawLine(spriteBatch, closestItemPos - new Vector2(0, 5), closestItemPos + new Vector2(0, 5), Color.Lime, 0, 10);*/
|
||||||
|
|
||||||
if (this == controlled || GUI.DisableHUD) return;
|
if (this == controlled || GUI.DisableHUD) return;
|
||||||
|
|
||||||
|
|||||||
@@ -581,6 +581,11 @@ namespace Barotrauma
|
|||||||
reactor.ShutDownTemp = power == 0 ? 0 : 7000.0f;
|
reactor.ShutDownTemp = power == 0 ? 0 : 7000.0f;
|
||||||
reactor.AutoTemp = true;
|
reactor.AutoTemp = true;
|
||||||
reactor.Temperature = power;
|
reactor.Temperature = power;
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
reactorItem.CreateServerEvent(reactor);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "shake":
|
case "shake":
|
||||||
GameMain.GameScreen.Cam.Shake = 10.0f;
|
GameMain.GameScreen.Cam.Shake = 10.0f;
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private float load;
|
private float load;
|
||||||
|
|
||||||
private float lastUpdate;
|
|
||||||
|
|
||||||
private PropertyTask powerUpTask;
|
private PropertyTask powerUpTask;
|
||||||
|
|
||||||
private GUITickBox autoTempTickBox;
|
private GUITickBox autoTempTickBox;
|
||||||
|
|||||||
@@ -10,20 +10,22 @@ namespace Barotrauma.Items.Components
|
|||||||
class PowerContainer : Powered, IDrawableComponent, IServerSerializable, IClientSerializable
|
class PowerContainer : Powered, IDrawableComponent, IServerSerializable, IClientSerializable
|
||||||
{
|
{
|
||||||
//[power/min]
|
//[power/min]
|
||||||
float capacity;
|
private float capacity;
|
||||||
|
|
||||||
float charge;
|
private float charge;
|
||||||
|
|
||||||
float rechargeVoltage, outputVoltage;
|
private float rechargeVoltage, outputVoltage;
|
||||||
|
|
||||||
//how fast the battery can be recharged
|
//how fast the battery can be recharged
|
||||||
float maxRechargeSpeed;
|
private float maxRechargeSpeed;
|
||||||
|
|
||||||
//how fast it's currently being recharged (can be changed, so that
|
//how fast it's currently being recharged (can be changed, so that
|
||||||
//charging can be slowed down or disabled if there's a shortage of power)
|
//charging can be slowed down or disabled if there's a shortage of power)
|
||||||
float rechargeSpeed;
|
private float rechargeSpeed;
|
||||||
|
|
||||||
float maxOutput;
|
private float maxOutput;
|
||||||
|
|
||||||
|
private float lastSentCharge;
|
||||||
|
|
||||||
public float CurrPowerOutput
|
public float CurrPowerOutput
|
||||||
{
|
{
|
||||||
@@ -53,6 +55,12 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (!MathUtils.IsValid(value)) return;
|
if (!MathUtils.IsValid(value)) return;
|
||||||
charge = MathHelper.Clamp(value, 0.0f, capacity);
|
charge = MathHelper.Clamp(value, 0.0f, capacity);
|
||||||
|
|
||||||
|
if (Math.Abs(charge - lastSentCharge) > 1.0f)
|
||||||
|
{
|
||||||
|
if (GameMain.Server != null) item.CreateServerEvent(this);
|
||||||
|
lastSentCharge = charge;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,8 +289,6 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
DebugConsole.NewMessage("writing recharge speed " + (rechargeSpeed / MaxRechargeSpeed * 10), Color.White);
|
|
||||||
msg.WriteRangedInteger(0, 10, (int)(rechargeSpeed / MaxRechargeSpeed * 10));
|
msg.WriteRangedInteger(0, 10, (int)(rechargeSpeed / MaxRechargeSpeed * 10));
|
||||||
|
|
||||||
float chargeRatio = MathHelper.Clamp(charge / capacity, 0.0f, 1.0f);
|
float chargeRatio = MathHelper.Clamp(charge / capacity, 0.0f, 1.0f);
|
||||||
|
|||||||
@@ -405,6 +405,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
Launch(projectile);
|
Launch(projectile);
|
||||||
|
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
|
|
||||||
public enum ActionType
|
public enum ActionType
|
||||||
{
|
{
|
||||||
Always, OnPicked, OnUse, OnSecondaryUse,
|
Always, OnPicked, OnUse, OnSecondaryUse,
|
||||||
@@ -28,6 +27,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
class Item : MapEntity, IDamageable, IPropertyObject, IServerSerializable, IClientSerializable
|
class Item : MapEntity, IDamageable, IPropertyObject, IServerSerializable, IClientSerializable
|
||||||
{
|
{
|
||||||
|
const float MaxVel = 64.0f;
|
||||||
|
|
||||||
public static List<Item> ItemList = new List<Item>();
|
public static List<Item> ItemList = new List<Item>();
|
||||||
private ItemPrefab prefab;
|
private ItemPrefab prefab;
|
||||||
|
|
||||||
@@ -817,21 +818,18 @@ namespace Barotrauma
|
|||||||
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
|
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
|
||||||
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
||||||
rect.Y = (int)(displayPos.Y + rect.Height / 2.0f);
|
rect.Y = (int)(displayPos.Y + rect.Height / 2.0f);
|
||||||
|
|
||||||
|
if (Math.Abs(body.LinearVelocity.X) > MaxVel || Math.Abs(body.LinearVelocity.Y) > MaxVel)
|
||||||
|
{
|
||||||
|
body.LinearVelocity = new Vector2(
|
||||||
|
MathHelper.Clamp(body.LinearVelocity.X, -MaxVel, MaxVel),
|
||||||
|
MathHelper.Clamp(body.LinearVelocity.Y, -MaxVel, MaxVel));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateNetPosition(deltaTime);
|
UpdateNetPosition(deltaTime);
|
||||||
|
|
||||||
/*if (GameMain.Client != null)
|
if (!inWater || Container != null) return;
|
||||||
{
|
|
||||||
body.MoveToTargetPosition();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (!inWater || Container != null || body == null) return;
|
|
||||||
|
|
||||||
if (body.LinearVelocity != Vector2.Zero && body.LinearVelocity.Length() > 1000.0f)
|
|
||||||
{
|
|
||||||
body.ResetDynamics();
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyWaterForces();
|
ApplyWaterForces();
|
||||||
|
|
||||||
@@ -2104,16 +2102,20 @@ namespace Barotrauma
|
|||||||
msg.WriteRangedSingle(MathUtils.WrapAngleTwoPi(body.Rotation), 0.0f, MathHelper.TwoPi, 7);
|
msg.WriteRangedSingle(MathUtils.WrapAngleTwoPi(body.Rotation), 0.0f, MathHelper.TwoPi, 7);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (Math.Abs(body.LinearVelocity.X) > 32.0f || Math.Abs(body.LinearVelocity.Y) > 32.0f)
|
if (Math.Abs(body.LinearVelocity.X) > MaxVel || Math.Abs(body.LinearVelocity.Y) > MaxVel)
|
||||||
|
{
|
||||||
|
|
||||||
DebugConsole.ThrowError("Item velocity out of range (" + body.LinearVelocity + ")");
|
DebugConsole.ThrowError("Item velocity out of range (" + body.LinearVelocity + ")");
|
||||||
|
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
msg.Write(body.FarseerBody.Awake);
|
msg.Write(body.FarseerBody.Awake);
|
||||||
if (body.FarseerBody.Awake)
|
if (body.FarseerBody.Awake)
|
||||||
{
|
{
|
||||||
body.FarseerBody.Enabled = true;
|
body.FarseerBody.Enabled = true;
|
||||||
msg.WriteRangedSingle(MathHelper.Clamp(body.LinearVelocity.X, -32.0f, 32.0f), -32.0f, 32.0f, 12);
|
msg.WriteRangedSingle(MathHelper.Clamp(body.LinearVelocity.X, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||||
msg.WriteRangedSingle(MathHelper.Clamp(body.LinearVelocity.Y, -32.0f, 32.0f), -32.0f, 32.0f, 12);
|
msg.WriteRangedSingle(MathHelper.Clamp(body.LinearVelocity.Y, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.WritePadBits();
|
msg.WritePadBits();
|
||||||
@@ -2136,9 +2138,9 @@ namespace Barotrauma
|
|||||||
if (body.FarseerBody.Awake)
|
if (body.FarseerBody.Awake)
|
||||||
{
|
{
|
||||||
newVelocity = new Vector2(
|
newVelocity = new Vector2(
|
||||||
msg.ReadRangedSingle(-32.0f, 32.0f, 12),
|
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
||||||
msg.ReadRangedSingle(-32.0f, 32.0f, 12));
|
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
||||||
if ((newVelocity-body.LinearVelocity).Length()>8.0f) body.LinearVelocity = newVelocity;
|
if ((newVelocity - body.LinearVelocity).Length() > 8.0f) body.LinearVelocity = newVelocity;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user