Skip to content

Commit

Permalink
sync fire
Browse files Browse the repository at this point in the history
  • Loading branch information
xzxADIxzx committed Nov 21, 2023
1 parent 88a4708 commit 9cc83ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions net/entity-types/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Item : Entity
private bool holding;
/// <summary> Whether the item is placed on an altar. </summary>
private bool placed;
/// <summary> Whether the item is a torch. </summary>
private bool torch;

/// <summary> Time of last transfer of the item from one client to another. </summary>
private float lastTransferTime;
Expand All @@ -46,6 +48,7 @@ private void Awake()
// other
rb = GetComponent<Rigidbody>();
itemId = GetComponent<ItemIdentifier>();
torch = GetComponent<Torch>() != null;

if (LobbyController.IsOwner)
{
Expand Down Expand Up @@ -86,16 +89,22 @@ private void Update()
itemId.ipz = null;
}

// put on the altar
if (placed && itemId.ipz == null)
// put on the altar or light the torches
if ((placed && itemId.ipz == null) || torch)
{
var colliders = Physics.OverlapSphere(transform.position, 0.01f, 20971776, QueryTriggerInteraction.Collide);
var colliders = Physics.OverlapSphere(transform.position, 0.5f, 20971776, QueryTriggerInteraction.Collide);
foreach (var col in colliders)
if (col.gameObject.layer == 22 && col.TryGetComponent<ItemPlaceZone>(out var zone))
{
if (col.gameObject.layer != 22) continue;

if (placed && itemId.ipz == null && col.TryGetComponent<ItemPlaceZone>(out var zone))
{
transform.SetParent(col.transform);
zone.CheckItem();
}

if (torch && col.TryGetComponent<Flammable>(out var flammable)) flammable.Burn(4f);
}
}
}

Expand Down

0 comments on commit 9cc83ae

Please sign in to comment.