- 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:
Regalis
2017-04-10 20:13:33 +03:00
parent 887735ff32
commit fac31b4892
6 changed files with 45 additions and 33 deletions

View File

@@ -47,9 +47,7 @@ namespace Barotrauma.Items.Components
private float[] loadGraph;
private float load;
private float lastUpdate;
private PropertyTask powerUpTask;
private GUITickBox autoTempTickBox;

View File

@@ -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);

View File

@@ -405,6 +405,7 @@ namespace Barotrauma.Items.Components
}
Launch(projectile);
PlaySound(ActionType.OnUse, item.WorldPosition);
}
}
}