Files
OldThink/Content.Server/Light/EntitySystems/MatchstickSystem.cs

125 lines
4.4 KiB
C#
Raw Normal View History

using Content.Server.Atmos.EntitySystems;
using Content.Server.Light.Components;
using Content.Shared.Audio;
using Content.Shared.Interaction;
get that crap outta here (completely rewrites inventorysystem) (#5807) * some work * equip: done unequip: todo * unequipping done & refactored events * workin * movin * reee namespaces * stun * mobstate * fixes * some work on events * removes serverside itemcomp & misc fixes * work * smol merge fix * ports template to prototype & finishes ui * moves relay & adds containerenumerator * actions & cuffs * my god what is actioncode * more fixes * im loosing my grasp on reality * more fixes * more work * explosions * yes * more work * more fixes * merge master & misc fixed because i forgot to commit before merging master * more fixes * fixes * moar * more work * moar fixes * suffixmap * more work on client * motivation low * no. no containers * mirroring client to server * fixes * move serverinvcomp * serverinventorycomponent is dead * gaming * only strippable & ai left... * only ai and richtext left * fixes ai * fixes * fixes sprite layers * more fixes * resolves optional * yes * stable:tm: * fixes * moar fixes * moar * fix some tests * lmao * no comment * good to merge:tm: * fixes build but for real * adresses some reviews * adresses some more reviews * nullables, yo * fixes lobbyscreen * timid refactor to differentiate actor & target * adresses more reviews * more * my god what a mess * removed the rest of duplicates * removed duplicate slotflags and renamed shoes to feet * removes another unused one * yes * fixes lobby & makes tryunequip return unequipped item * fixes * some funny renames * fixes * misc improvements to attemptevents * fixes * merge fixes Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
2021-12-30 22:56:10 +01:00
using Content.Shared.Item;
using Content.Shared.Smoking;
using Content.Shared.Temperature;
2022-01-15 03:26:37 +01:00
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
namespace Content.Server.Light.EntitySystems
{
public sealed class MatchstickSystem : EntitySystem
{
Refactors the AtmosphereSystem public-facing API to allow for multiple atmos backends. (#8134) * Refactors the entirety of the AtmosphereSystem public-facing API to allow for multiple atmos backends. * actually compiles * Remove commented out code * funny bracket * Move archived moles, temperature from GasMixture to TileAtmosphere. * WIP customizable map default mixture still VERY buggy * broken mess aaaaaaaaaaaaa * Fix lattice, etc not being considered space * visualization for "IsSpace" * help * Update Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs Co-authored-by: Moony <moonheart08@users.noreply.github.com> * Holy SHIT it compiles AGAIN * Fix AtmosDeviceSystem crash at shutdown * Fix immutable tiles on map blueprints not being fixed by fixgridatmos/revalidate. * Use space instead of gasmixture immutable for heat capacity calculations * Remove all LINDA-specific code from GasMixture, move it to TileAtmosphere/AtmosphereSystem instead. * Fix roundstart tiles not processing * Update Content.Server/Atmos/Commands/SetTemperatureCommand.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs Changed Files tab is so large I can't commit both suggestions at once mfw Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Moony <moonheart08@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-07-04 16:51:34 +02:00
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
2023-09-11 19:18:06 +10:00
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedPointLightSystem _lights = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
private readonly HashSet<Entity<MatchstickComponent>> _litMatches = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MatchstickComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<MatchstickComponent, IsHotEvent>(OnIsHotEvent);
2021-12-13 15:22:08 +11:00
SubscribeLocalEvent<MatchstickComponent, ComponentShutdown>(OnShutdown);
}
private void OnShutdown(Entity<MatchstickComponent> ent, ref ComponentShutdown args)
2021-12-13 15:22:08 +11:00
{
_litMatches.Remove(ent);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var match in _litMatches)
{
if (match.Comp.CurrentState != SmokableState.Lit || Paused(match) || match.Comp.Deleted)
continue;
var xform = Transform(match);
Refactors the AtmosphereSystem public-facing API to allow for multiple atmos backends. (#8134) * Refactors the entirety of the AtmosphereSystem public-facing API to allow for multiple atmos backends. * actually compiles * Remove commented out code * funny bracket * Move archived moles, temperature from GasMixture to TileAtmosphere. * WIP customizable map default mixture still VERY buggy * broken mess aaaaaaaaaaaaa * Fix lattice, etc not being considered space * visualization for "IsSpace" * help * Update Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs Co-authored-by: Moony <moonheart08@users.noreply.github.com> * Holy SHIT it compiles AGAIN * Fix AtmosDeviceSystem crash at shutdown * Fix immutable tiles on map blueprints not being fixed by fixgridatmos/revalidate. * Use space instead of gasmixture immutable for heat capacity calculations * Remove all LINDA-specific code from GasMixture, move it to TileAtmosphere/AtmosphereSystem instead. * Fix roundstart tiles not processing * Update Content.Server/Atmos/Commands/SetTemperatureCommand.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs Changed Files tab is so large I can't commit both suggestions at once mfw Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Moony <moonheart08@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-07-04 16:51:34 +02:00
if (xform.GridUid is not {} gridUid)
return;
var position = _transformSystem.GetGridOrMapTilePosition(match, xform);
Refactors the AtmosphereSystem public-facing API to allow for multiple atmos backends. (#8134) * Refactors the entirety of the AtmosphereSystem public-facing API to allow for multiple atmos backends. * actually compiles * Remove commented out code * funny bracket * Move archived moles, temperature from GasMixture to TileAtmosphere. * WIP customizable map default mixture still VERY buggy * broken mess aaaaaaaaaaaaa * Fix lattice, etc not being considered space * visualization for "IsSpace" * help * Update Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs Co-authored-by: Moony <moonheart08@users.noreply.github.com> * Holy SHIT it compiles AGAIN * Fix AtmosDeviceSystem crash at shutdown * Fix immutable tiles on map blueprints not being fixed by fixgridatmos/revalidate. * Use space instead of gasmixture immutable for heat capacity calculations * Remove all LINDA-specific code from GasMixture, move it to TileAtmosphere/AtmosphereSystem instead. * Fix roundstart tiles not processing * Update Content.Server/Atmos/Commands/SetTemperatureCommand.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs Changed Files tab is so large I can't commit both suggestions at once mfw Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Moony <moonheart08@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2022-07-04 16:51:34 +02:00
_atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, match, true);
}
}
private void OnInteractUsing(Entity<MatchstickComponent> ent, ref InteractUsingEvent args)
{
if (args.Handled || ent.Comp.CurrentState != SmokableState.Unlit)
return;
var isHotEvent = new IsHotEvent();
RaiseLocalEvent(args.Used, isHotEvent);
if (!isHotEvent.IsHot)
return;
Ignite(ent, args.User);
args.Handled = true;
}
private void OnIsHotEvent(EntityUid uid, MatchstickComponent component, IsHotEvent args)
{
args.IsHot = component.CurrentState == SmokableState.Lit;
}
public void Ignite(Entity<MatchstickComponent> matchstick, EntityUid user)
{
var component = matchstick.Comp;
// Play Sound
_audio.PlayPvs(component.IgniteSound, matchstick, AudioParams.Default.WithVariation(0.125f).WithVolume(-0.125f));
// Change state
SetState(matchstick, component, SmokableState.Lit);
_litMatches.Add(matchstick);
matchstick.Owner.SpawnTimer(component.Duration * 1000, delegate
{
SetState(matchstick, component, SmokableState.Burnt);
_litMatches.Remove(matchstick);
});
}
private void SetState(EntityUid uid, MatchstickComponent component, SmokableState value)
{
component.CurrentState = value;
2023-09-11 19:18:06 +10:00
if (_lights.TryGetLight(uid, out var pointLightComponent))
{
2023-09-11 19:18:06 +10:00
_lights.SetEnabled(uid, component.CurrentState == SmokableState.Lit, pointLightComponent);
}
2023-09-11 19:18:06 +10:00
if (EntityManager.TryGetComponent(uid, out ItemComponent? item))
{
switch (component.CurrentState)
{
case SmokableState.Lit:
_item.SetHeldPrefix(uid, "lit", component: item);
break;
default:
_item.SetHeldPrefix(uid, "unlit", component: item);
break;
}
}
2023-09-11 19:18:06 +10:00
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, SmokingVisuals.Smoking, component.CurrentState, appearance);
}
}
}
}