Item.Container bugfix (affected at least railguns in MP), merged the "your crew has died" message box with shiftsummary, reliable reactor syncing, prevent artifacts dropping out of the level

This commit is contained in:
Regalis
2016-01-12 01:02:05 +02:00
parent 64e62545a5
commit 5513637fe5
21 changed files with 132 additions and 89 deletions

View File

@@ -222,7 +222,7 @@ namespace Barotrauma.Items.Components
IsActive = true;
if (hideItems || (item.body!=null && !item.body.Enabled)) item.body.Enabled = false;
item.container = this.item;
//item.Container = this.item;
return true;
}

View File

@@ -10,6 +10,8 @@ namespace Barotrauma.Items.Components
{
class Reactor : Powered
{
const float NetworkUpdateInterval = 3.0f;
//the rate at which the reactor is being run un
//higher rates generate more power (and heat)
private float fissionRate;
@@ -50,6 +52,9 @@ namespace Barotrauma.Items.Components
private PropertyTask powerUpTask;
private bool unsentChanges;
private float sendUpdateTimer;
[Editable, HasDefaultValue(9500.0f, true)]
public float MeltDownTemp
{
@@ -248,6 +253,15 @@ namespace Barotrauma.Items.Components
AvailableFuel = 0.0f;
item.SendSignal(((int)temperature).ToString(), "temperature_out");
sendUpdateTimer = Math.Max(sendUpdateTimer - deltaTime, 0.0f);
if (unsentChanges && sendUpdateTimer<= 0.0f)
{
item.NewComponentEvent(this, true, true);
sendUpdateTimer = NetworkUpdateInterval;
unsentChanges = false;
}
}
public override void UpdateBroken(float deltaTime, Camera cam)
@@ -353,9 +367,7 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
IsActive = true;
bool valueChanged = false;
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
@@ -380,12 +392,12 @@ namespace Barotrauma.Items.Components
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 450, y + 80), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 110, 40, 40), "+", true))
{
valueChanged = true;
unsentChanges = true;
ShutDownTemp += 100.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 500, y + 110, 40, 40), "-", true))
{
valueChanged = true;
unsentChanges = true;
ShutDownTemp -= 100.0f;
}
@@ -393,7 +405,7 @@ namespace Barotrauma.Items.Components
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 450, y + 180), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 210, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
{
valueChanged = true;
unsentChanges = true;
autoTemp = !autoTemp;
}
@@ -407,12 +419,12 @@ namespace Barotrauma.Items.Components
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 30, 40, 40), "+", true))
{
valueChanged = true;
unsentChanges = true;
FissionRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 80, 40, 40), "-", true))
{
valueChanged = true;
unsentChanges = true;
FissionRate -= 1.0f;
}
@@ -422,21 +434,17 @@ namespace Barotrauma.Items.Components
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 30, 40, 40), "+", true))
{
valueChanged = true;
unsentChanges = true;
CoolingRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 80, 40, 40), "-", true))
{
valueChanged = true;
unsentChanges = true;
CoolingRate -= 1.0f;
}
//y = y - 260;
if (valueChanged)
{
item.NewComponentEvent(this, true, false);
}
}
static void UpdateGraph<T>(IList<T> graph, T newValue)

View File

@@ -122,7 +122,7 @@ namespace Barotrauma.Items.Components
}
currPowerConsumption = MathHelper.Lerp(currPowerConsumption, rechargeSpeed, 0.05f);
charge += currPowerConsumption*voltage / 3600.0f;
Charge += currPowerConsumption*voltage / 3600.0f;
}
//provide power to the grid
else if (gridLoad > 0.0f)

View File

@@ -100,7 +100,7 @@ namespace Barotrauma.Items.Components
light.Submarine = item.CurrentHull.Submarine;
}
if (item.container != null)
if (item.Container != null)
{
light.Color = Color.Transparent;
return;

View File

@@ -133,7 +133,7 @@ namespace Barotrauma.Items.Components
if (ic == this) continue;
ic.Drop(null);
}
if (item.container != null) item.container.RemoveContained(this.item);
if (item.Container != null) item.Container.RemoveContained(this.item);
item.body.Enabled = false;

View File

@@ -156,7 +156,7 @@ namespace Barotrauma.Items.Components
projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.WorldRect.X + barrelPos.X, item.WorldRect.Y - barrelPos.Y)), -rotation);
projectiles[0].Use(deltaTime);
if (projectile.container != null) projectile.container.RemoveContained(projectile);
if (projectile.Container != null) projectile.Container.RemoveContained(projectile);
return true;
}