(361a8d556) LevelResource fixes:

- If collecting the resource doesn't require any items, allow it to be picked up withour a repair tool. Closes #1325
- Fixed deattach timer not being synced (the methods were implemented, but the server never sent any events). Closes #1292
- Fixed ridiculously small mineral colliders that made it hard to hit them with the plasma cutter (body size was not updated when the sprites were changed?).
This commit is contained in:
Joonas Rikkonen
2019-03-28 18:12:37 +02:00
parent c76fb32e15
commit b9574dde2d
5 changed files with 61 additions and 384 deletions
@@ -2,12 +2,15 @@
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Linq;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
partial class LevelResource : ItemComponent, IServerSerializable
{
private float lastSentDeattachTimer;
[Serialize(1.0f, false)]
public float DeattachDuration
{
@@ -21,12 +24,29 @@ namespace Barotrauma.Items.Components
get { return deattachTimer; }
set
{
deattachTimer = Math.Max(0.0f, value);
//clients don't deattach the item until the server says so (handled in ClientRead)
if ((GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) && deattachTimer >= DeattachDuration)
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
{
return;
}
deattachTimer = Math.Max(0.0f, value);
#if SERVER
if (deattachTimer >= DeattachDuration)
{
if (holdable.Attached){ item.CreateServerEvent(this); }
holdable.DeattachFromWall();
}
else if (Math.Abs(lastSentDeattachTimer - deattachTimer) > 0.1f)
{
item.CreateServerEvent(this);
lastSentDeattachTimer = deattachTimer;
}
#else
if (deattachTimer >= DeattachDuration)
{
holdable.DeattachFromWall();
}
#endif
}
}
@@ -67,7 +87,10 @@ namespace Barotrauma.Items.Components
return;
}
holdable.Reattachable = false;
holdable.PickingTime = float.MaxValue;
if (requiredItems.Any())
{
holdable.PickingTime = float.MaxValue;
}
var body = item.body ?? holdable.Body;