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:
@@ -162,7 +162,7 @@ namespace Barotrauma
|
||||
System.Diagnostics.Debug.Assert(false);
|
||||
return false;
|
||||
}
|
||||
Inventory otherInventory = Items[index].inventory;
|
||||
Inventory otherInventory = Items[index].Inventory;
|
||||
if (otherInventory != null && createNetworkEvent)
|
||||
{
|
||||
new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, otherInventory.Owner.ID, true, true);
|
||||
@@ -213,7 +213,7 @@ namespace Barotrauma
|
||||
string toolTip = "";
|
||||
Rectangle highlightedSlot = Rectangle.Empty;
|
||||
|
||||
if (doubleClickedItem!=null && doubleClickedItem.inventory!=this)
|
||||
if (doubleClickedItem!=null && doubleClickedItem.Inventory!=this)
|
||||
{
|
||||
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ namespace Barotrauma
|
||||
if (removeItem)
|
||||
{
|
||||
item.Drop(null, false);
|
||||
if (item.inventory != null) item.inventory.RemoveItem(item);
|
||||
if (item.Inventory != null) item.Inventory.RemoveItem(item);
|
||||
}
|
||||
|
||||
Items[i] = item;
|
||||
item.inventory = this;
|
||||
item.Inventory = this;
|
||||
if (item.body != null)
|
||||
{
|
||||
item.body.Enabled = false;
|
||||
@@ -152,7 +152,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (Items[n] != item) continue;
|
||||
Items[n] = null;
|
||||
item.inventory = null;
|
||||
item.Inventory = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition) && draggingItem.container == this.Owner)
|
||||
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition) && draggingItem.Container == this.Owner)
|
||||
{
|
||||
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed)
|
||||
{
|
||||
|
||||
@@ -61,11 +61,29 @@ namespace Barotrauma
|
||||
|
||||
private bool inWater;
|
||||
|
||||
//the inventory in which the item is contained in
|
||||
public Inventory inventory;
|
||||
private Inventory inventory;
|
||||
|
||||
//the inventory in which the item is contained in
|
||||
public Inventory Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
set
|
||||
{
|
||||
inventory = value;
|
||||
|
||||
if (inventory != null) Container = inventory.Owner as Item;
|
||||
}
|
||||
}
|
||||
|
||||
public Item Container
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Item container;
|
||||
|
||||
public List<FixRequirement> FixRequirements;
|
||||
|
||||
public override string Name
|
||||
@@ -354,7 +372,7 @@ namespace Barotrauma
|
||||
if (c == null) return;
|
||||
|
||||
c.RemoveContained(contained);
|
||||
contained.container = null;
|
||||
contained.Container = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -517,7 +535,7 @@ namespace Barotrauma
|
||||
//effect.Apply(type, deltaTime, null, Character);
|
||||
//ApplyStatusEffect(effect, type, deltaTime, null, Character, limb);
|
||||
|
||||
if (container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(container);
|
||||
if (Container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(Container);
|
||||
//{
|
||||
// effect.Apply(type, deltaTime, container);
|
||||
// //container.ApplyStatusEffect(effect, type, deltaTime, container);
|
||||
@@ -558,7 +576,7 @@ namespace Barotrauma
|
||||
}
|
||||
ic.WasUsed = false;
|
||||
|
||||
if (container != null) ic.ApplyStatusEffects(ActionType.OnContained, deltaTime);
|
||||
if (Container != null) ic.ApplyStatusEffects(ActionType.OnContained, deltaTime);
|
||||
|
||||
if (!ic.IsActive) continue;
|
||||
|
||||
@@ -1005,7 +1023,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (container!=null) container.RemoveContained(this);
|
||||
if (Container!=null) Container.RemoveContained(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1079,7 +1097,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (ItemComponent ic in components) ic.Drop(dropper);
|
||||
|
||||
if (container != null) container.RemoveContained(this);
|
||||
if (Container != null) Container.RemoveContained(this);
|
||||
}
|
||||
|
||||
public void Equip(Character character)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Barotrauma
|
||||
item.Unequip(c);
|
||||
break;
|
||||
}
|
||||
item.container = container.Item;
|
||||
//item.Container = container.Item;
|
||||
container.IsActive = true;
|
||||
}
|
||||
return wasPut;
|
||||
|
||||
Reference in New Issue
Block a user