Skip to content

Commit

Permalink
cigarette improvements (unitystation#10530)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxIsJoe authored Sep 16, 2024
1 parent 2188a3d commit 2e915ab
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions UnityProject/Assets/Scripts/Items/Food/Cigarette.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using Chemistry.Components;
using UnityEngine;
using Mirror;
using ScriptableObjects.Atmospherics;
using Systems.Atmospherics;
using Systems.Clothing;

namespace Items
{
/// <summary>
/// Base class for smokable cigarette
/// </summary>
[RequireComponent(typeof(ClothingV2))]
[RequireComponent(typeof(FireSource))]
[RequireComponent(typeof(Pickupable))]
public class Cigarette : NetworkBehaviour, IServerDespawn, ICheckedInteractable<HandApply>,
ICheckedInteractable<InventoryApply>, IServerInventoryMove
{
Expand All @@ -29,13 +34,16 @@ public class Cigarette : NetworkBehaviour, IServerDespawn, ICheckedInteractable<

[SyncVar] private bool isLit = false;
[SerializeField] private ReagentContainer reagentContainer = null;
[SerializeField] private List<GasSO> gasProduct = new List<GasSO>();
private RegisterPlayer smoker;
private ClothingV2 clothing;

private void Awake()
{
pickupable = GetComponent<Pickupable>();
fireSource = GetComponent<FireSource>();
reagentContainer ??= GetComponent<ReagentContainer>();
clothing = GetComponent<ClothingV2>();
}

public void OnDespawnServer(DespawnInfo info)
Expand Down Expand Up @@ -115,13 +123,13 @@ private void ServerChangeLit(bool isLitNow)
{
UpdateManager.Add(CigBurnLogic, smokeTimeSeconds);
}

isLit = isLitNow;
clothing.ChangeSprite(1);
}

private bool TryLightByObject(GameObject usedObject)
{
if (!isLit)
if (isLit == false)
{
// check if player tries to lit cigarette with something
if (usedObject != null)
Expand Down Expand Up @@ -170,6 +178,18 @@ private void CigBurnLogic()
smoker.PlayerScript.playerHealth.reagentPoolSystem.BloodPool.Add(burnReagent);
Chat.AddExamineMsg(smoker.PlayerScript.gameObject, $"You take a drag out of the {gameObject.ExpensiveName()}");
}
if (gasProduct.Count > 0)
{
var tile = gameObject.RegisterTile();
if (tile == null) return;
var gasNode = tile.Matrix.GetMetaDataNode(tile.LocalPositionServer, false);
if (gasNode == null) return;
var node = gasNode.GasMixLocal;
foreach (var gas in gasProduct)
{
node.AddGas(gas, burnReagent.Total, Kelvin.FromC(2f));
}
}
if (reagentContainer.ReagentMixTotal.Approx(0)) Burn();
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2e915ab

Please sign in to comment.