- 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);
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
|
||||
Vector2 mouseDrawPos = CursorWorldPosition;
|
||||
mouseDrawPos.Y = -mouseDrawPos.Y;
|
||||
@@ -1625,7 +1625,7 @@ namespace Barotrauma
|
||||
|
||||
Vector2 closestItemPos = closestItem != null ? closestItem.DrawPosition : Vector2.Zero;
|
||||
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;
|
||||
|
||||
|
||||
@@ -581,6 +581,11 @@ namespace Barotrauma
|
||||
reactor.ShutDownTemp = power == 0 ? 0 : 7000.0f;
|
||||
reactor.AutoTemp = true;
|
||||
reactor.Temperature = power;
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
reactorItem.CreateServerEvent(reactor);
|
||||
}
|
||||
break;
|
||||
case "shake":
|
||||
GameMain.GameScreen.Cam.Shake = 10.0f;
|
||||
|
||||
@@ -47,9 +47,7 @@ namespace Barotrauma.Items.Components
|
||||
private float[] loadGraph;
|
||||
|
||||
private float load;
|
||||
|
||||
private float lastUpdate;
|
||||
|
||||
|
||||
private PropertyTask powerUpTask;
|
||||
|
||||
private GUITickBox autoTempTickBox;
|
||||
|
||||
@@ -10,20 +10,22 @@ namespace Barotrauma.Items.Components
|
||||
class PowerContainer : Powered, IDrawableComponent, IServerSerializable, IClientSerializable
|
||||
{
|
||||
//[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
|
||||
float maxRechargeSpeed;
|
||||
private float maxRechargeSpeed;
|
||||
|
||||
//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)
|
||||
float rechargeSpeed;
|
||||
private float rechargeSpeed;
|
||||
|
||||
float maxOutput;
|
||||
private float maxOutput;
|
||||
|
||||
private float lastSentCharge;
|
||||
|
||||
public float CurrPowerOutput
|
||||
{
|
||||
@@ -53,6 +55,12 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (!MathUtils.IsValid(value)) return;
|
||||
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)
|
||||
{
|
||||
|
||||
DebugConsole.NewMessage("writing recharge speed " + (rechargeSpeed / MaxRechargeSpeed * 10), Color.White);
|
||||
msg.WriteRangedInteger(0, 10, (int)(rechargeSpeed / MaxRechargeSpeed * 10));
|
||||
|
||||
float chargeRatio = MathHelper.Clamp(charge / capacity, 0.0f, 1.0f);
|
||||
|
||||
@@ -405,6 +405,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
Launch(projectile);
|
||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
Always, OnPicked, OnUse, OnSecondaryUse,
|
||||
@@ -28,6 +27,8 @@ namespace Barotrauma
|
||||
|
||||
class Item : MapEntity, IDamageable, IPropertyObject, IServerSerializable, IClientSerializable
|
||||
{
|
||||
const float MaxVel = 64.0f;
|
||||
|
||||
public static List<Item> ItemList = new List<Item>();
|
||||
private ItemPrefab prefab;
|
||||
|
||||
@@ -817,22 +818,19 @@ namespace Barotrauma
|
||||
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
|
||||
rect.X = (int)(displayPos.X - rect.Width / 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);
|
||||
|
||||
/*if (GameMain.Client != null)
|
||||
{
|
||||
body.MoveToTargetPosition();
|
||||
}*/
|
||||
|
||||
if (!inWater || Container != null || body == null) return;
|
||||
|
||||
if (body.LinearVelocity != Vector2.Zero && body.LinearVelocity.Length() > 1000.0f)
|
||||
{
|
||||
body.ResetDynamics();
|
||||
}
|
||||
|
||||
|
||||
if (!inWater || Container != null) return;
|
||||
|
||||
ApplyWaterForces();
|
||||
|
||||
if(CurrentHull != null) CurrentHull.ApplyFlowForces(deltaTime, this);
|
||||
@@ -2104,16 +2102,20 @@ namespace Barotrauma
|
||||
msg.WriteRangedSingle(MathUtils.WrapAngleTwoPi(body.Rotation), 0.0f, MathHelper.TwoPi, 7);
|
||||
|
||||
#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 + ")");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
msg.Write(body.FarseerBody.Awake);
|
||||
if (body.FarseerBody.Awake)
|
||||
{
|
||||
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.Y, -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, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||
}
|
||||
|
||||
msg.WritePadBits();
|
||||
@@ -2136,9 +2138,9 @@ namespace Barotrauma
|
||||
if (body.FarseerBody.Awake)
|
||||
{
|
||||
newVelocity = new Vector2(
|
||||
msg.ReadRangedSingle(-32.0f, 32.0f, 12),
|
||||
msg.ReadRangedSingle(-32.0f, 32.0f, 12));
|
||||
if ((newVelocity-body.LinearVelocity).Length()>8.0f) body.LinearVelocity = newVelocity;
|
||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
||||
if ((newVelocity - body.LinearVelocity).Length() > 8.0f) body.LinearVelocity = newVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user