Merge remote-tracking branch 'origin/feat/inport-props' into feat/craft-discovery
# Conflicts: # Assets/External/Animated PBR Chest Demo/Materials/WoodChest.mat # Packages/com.distantlands.cozy.core/Content/Integration/Import for BiRP.unitypackage.meta # Packages/com.distantlands.cozy.core/Content/Integration/Import for HDRP.unitypackage.meta # Packages/com.distantlands.cozy.core/Content/Integration/Import for URP.unitypackage.meta
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Ashwild.Inventory;
|
||||
using Ashwild.Network;
|
||||
using DG.Tweening;
|
||||
using FishNet.Connection;
|
||||
using FishNet.Object;
|
||||
@@ -250,13 +251,17 @@ namespace Ashwild.Building
|
||||
/// health: a full-health build refunds its whole cost, a half-health one refunds half, and so on
|
||||
/// (per line, floored — a partial unit is not returned). No-op for a free build, when the player's
|
||||
/// inventory cannot be resolved, or when the fraction rounds every line down to nothing.
|
||||
///
|
||||
/// The inventory comes from the shared lookup, which scans the connection's objects rather than
|
||||
/// trusting FirstObject — the demolisher may also own a build ghost, which FirstObject can resolve
|
||||
/// to instead of the player.
|
||||
/// </summary>
|
||||
private void RefundResources(NetworkConnection conn)
|
||||
{
|
||||
BuildableData data = Data;
|
||||
if (data == null || data.Cost == null || data.Cost.Length == 0) return;
|
||||
|
||||
PlayerInventory inventory = ResolveInventory(conn);
|
||||
PlayerInventory inventory = NetworkPlayerLookup.ResolveInventory(conn);
|
||||
if (inventory == null) return;
|
||||
|
||||
float max = data.MaxHealth;
|
||||
@@ -270,16 +275,6 @@ namespace Ashwild.Building
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the PlayerInventory on the player object owned by the given connection, mirroring
|
||||
/// CookingStation so refunds land in the requester's own inventory.
|
||||
/// </summary>
|
||||
private static PlayerInventory ResolveInventory(NetworkConnection conn)
|
||||
{
|
||||
NetworkObject playerObject = conn != null ? conn.FirstObject : null;
|
||||
return playerObject != null ? playerObject.GetComponent<PlayerInventory>() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes this structure for every player. Server-side only.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user