(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:
@@ -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;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Barotrauma.Items.Components
|
||||
private readonly List<string> fixableEntities;
|
||||
private Vector2 pickedPosition;
|
||||
private float activeTimer;
|
||||
|
||||
private Vector2 debugRayStartPos, debugRayEndPos;
|
||||
|
||||
[Serialize(0.0f, false)]
|
||||
public float Range { get; set; }
|
||||
@@ -121,10 +123,19 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 rayStart = ConvertUnits.ToSimUnits(item.WorldPosition);
|
||||
Vector2 rayEnd = ConvertUnits.ToSimUnits(targetPosition);
|
||||
|
||||
debugRayStartPos = item.WorldPosition;
|
||||
debugRayEndPos = ConvertUnits.ToDisplayUnits(rayEnd);
|
||||
|
||||
if (character.Submarine == null)
|
||||
{
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
Rectangle subBorders = sub.Borders;
|
||||
subBorders.Location += new Point((int)sub.WorldPosition.X, (int)sub.WorldPosition.Y - sub.Borders.Height);
|
||||
if (!MathUtils.CircleIntersectsRectangle(item.WorldPosition, Range * 5.0f, subBorders))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Repair(rayStart - sub.SimPosition, rayEnd - sub.SimPosition, deltaTime, character, degreeOfSuccess, ignoredBodies);
|
||||
}
|
||||
Repair(rayStart, rayEnd, deltaTime, character, degreeOfSuccess, ignoredBodies);
|
||||
@@ -238,6 +249,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
var levelResource = targetItem.GetComponent<LevelResource>();
|
||||
if (levelResource != null && levelResource.IsActive &&
|
||||
levelResource.requiredItems.Any() &&
|
||||
levelResource.HasRequiredItems(user, addMessage: false))
|
||||
{
|
||||
levelResource.DeattachTimer += deltaTime;
|
||||
|
||||
Reference in New Issue
Block a user