Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microwave #1531

Merged
merged 6 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Content.Server/Access/Systems/IdCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Popups;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Server.Kitchen.EntitySystems;

namespace Content.Server.Access.Systems;

Expand All @@ -18,6 +19,7 @@ public sealed class IdCardSystem : SharedIdCardSystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly MicrowaveSystem _microwave = default!;

public override void Initialize()
{
Expand All @@ -27,9 +29,13 @@ public override void Initialize()

private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowavedEvent args)
{
if (!component.CanMicrowave || !TryComp<MicrowaveComponent>(args.Microwave, out var micro) || micro.Broken)
return;

if (TryComp<AccessComponent>(uid, out var access))
{
float randomPick = _random.NextFloat();

// if really unlucky, burn card
if (randomPick <= 0.15f)
{
Expand All @@ -46,6 +52,14 @@ private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowa
EntityManager.QueueDeleteEntity(uid);
return;
}

//Explode if the microwave can't handle it
if (!micro.CanMicrowaveIdsSafely)
{
_microwave.Explode((args.Microwave, micro));
return;
}

// If they're unlucky, brick their ID
if (randomPick <= 0.25f)
{
Expand All @@ -70,6 +84,7 @@ private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowa

_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(args.Microwave)} added {random.ID} access to {ToPrettyString(uid):entity}");

}
}
}
6 changes: 6 additions & 0 deletions Content.Server/Kitchen/Components/MicrowaveComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public sealed partial class MicrowaveComponent : Component
/// Chance of lightning occurring when we microwave a metallic object
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float LightningChance = .75f;

/// <summary>
/// If this microwave can give ids accesses without exploding
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool CanMicrowaveIdsSafely = true;
}

public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
Expand Down
30 changes: 27 additions & 3 deletions Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Administration.Logs;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Construction;
Expand All @@ -15,6 +16,7 @@
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Construction.EntitySystems;
using Content.Shared.Database;
using Content.Shared.Destructible;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
Expand All @@ -35,7 +37,8 @@
using System.Linq;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.Access.Components;
using Content.Shared.Stacks;
using Content.Server.Construction.Components;

namespace Content.Server.Kitchen.EntitySystems
{
Expand All @@ -59,6 +62,9 @@ public sealed class MicrowaveSystem : EntitySystem
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!;
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedStackSystem _stack = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;

[ValidatePrototypeId<EntityPrototype>]
private const string MalfunctionSpark = "Spark";
Expand Down Expand Up @@ -394,6 +400,23 @@ public static bool HasContents(MicrowaveComponent component)
return component.Storage.ContainedEntities.Any();
}

/// <summary>
/// Explodes the microwave internally, turning it into a broken state, destroying its board, and spitting out its machine parts
/// </summary>
/// <param name="ent"></param>
public void Explode(Entity<MicrowaveComponent> ent)
{
ent.Comp.Broken = true; // Make broken so we stop processing stuff
_explosion.TriggerExplosive(ent);
if (TryComp<MachineComponent>(ent, out var machine))
{
_container.CleanContainer(machine.BoardContainer);
_container.EmptyContainer(machine.PartContainer);
}

_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(ent)} exploded from unsafe cooking!");
}
/// <summary>
/// Handles the attempted cooking of unsafe objects
/// </summary>
Expand All @@ -411,7 +434,7 @@ private void RollMalfunction(Entity<ActiveMicrowaveComponent, MicrowaveComponent
ent.Comp1.MalfunctionTime = _gameTiming.CurTime + TimeSpan.FromSeconds(ent.Comp2.MalfunctionInterval);
if (_random.Prob(ent.Comp2.ExplosionChance))
{
_explosion.TriggerExplosive(ent);
Explode((ent, ent.Comp2));
return; // microwave is fucked, stop the cooking.
}

Expand Down Expand Up @@ -500,7 +523,8 @@ public void Wzhzhzh(EntityUid uid, MicrowaveComponent component, EntityUid? user
activeComp.CookTimeRemaining = component.CurrentCookTimerTime * component.CookTimeMultiplier;
activeComp.TotalTime = component.CurrentCookTimerTime; //this doesn't scale so that we can have the "actual" time
activeComp.PortionedRecipe = portionedRecipe;
component.CurrentCookTimeEnd = _gameTiming.CurTime + TimeSpan.FromSeconds(component.CurrentCookTimerTime);
//Scale tiems with cook times
component.CurrentCookTimeEnd = _gameTiming.CurTime + TimeSpan.FromSeconds(component.CurrentCookTimerTime * component.CookTimeMultiplier);
if (malfunctioning)
activeComp.MalfunctionTime = _gameTiming.CurTime + TimeSpan.FromSeconds(component.MalfunctionInterval);
UpdateUserInterfaceState(uid, component);
Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/Access/Components/IdCardComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public sealed partial class IdCardComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool BypassLogging;

[DataField]
public LocId FullNameLocId = "access-id-card-component-owner-full-name-job-title-text";

[DataField]
public bool CanMicrowave = true;

// Frontier
[DataField("soundError")]
Expand All @@ -57,5 +62,4 @@ public sealed partial class IdCardComponent : Component
[DataField("soundInsert")]
public SoundSpecifier InsertSound =
new SoundPathSpecifier("/Audio/Machines/id_insert.ogg");

}
2 changes: 1 addition & 1 deletion Resources/Maps/Nonstations/nukieplanet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10994,7 +10994,7 @@ entities:
- type: Transform
pos: 18.918644,6.663283
parent: 104
- proto: KitchenMicrowave
- proto: SyndicateMicrowave
entities:
- uid: 10
components:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Maps/Shuttles/infiltrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3607,7 +3607,7 @@ entities:
- type: Transform
pos: 3.5,-3.5
parent: 1
- proto: KitchenMicrowave
- proto: SyndicateMicrowave
entities:
- uid: 497
components:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Maps/_NF/POI/cove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7873,7 +7873,7 @@ entities:
- type: Transform
pos: 1.4792413,5.5648255
parent: 1
- proto: KitchenMicrowave
- proto: SyndicateMicrowave
entities:
- uid: 149
components:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Maps/_NF/Shuttles/BlackMarket/falcon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2608,7 +2608,7 @@ entities:
- type: Transform
pos: 6.464443,-9.590082
parent: 3
- proto: KitchenMicrowave
- proto: SyndicateMicrowave
entities:
- uid: 109
components:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Maps/_NF/Shuttles/Syndicate/infiltrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3793,7 +3793,7 @@ entities:
- type: Transform
pos: 3.5,-3.5
parent: 1
- proto: KitchenMicrowave
- proto: SyndicateMicrowave
entities:
- uid: 497
components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,25 @@
tags:
- MicrowaveMachineBoard

- type: entity
id: SyndicateMicrowaveMachineCircuitboard
parent: BaseMachineCircuitboard
name: donk co. microwave machine board
components:
- type: Sprite
state: service
- type: MachineBoard
prototype: SyndicateMicrowave
requirements:
Capacitor: 1
materialRequirements:
Glass: 2
Cable: 2
# stackRequirements:
# Capacitor: 1
# Glass: 2
# Cable: 2

- type: entity
id: FatExtractorMachineCircuitboard
parent: BaseMachineCircuitboard
Expand Down
20 changes: 20 additions & 0 deletions Resources/Prototypes/Entities/Structures/Machines/microwave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
components:
- type: Microwave
capacity: 10
canMicrowaveIdsSafely: false # Frontier
explosionChance: 1 # Frontier
- type: Appearance
- type: GenericVisualizer
visuals:
Expand Down Expand Up @@ -105,3 +107,21 @@
- type: GuideHelp
guides:
- Chef

- type: entity
id: SyndicateMicrowave
parent: KitchenMicrowave
name: donk co. microwave
description: So advanced, it can cook donk-pockets in a mere 2.5 seconds!
components:
- type: Microwave
cookTimeMultiplier: 0.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a complaint, but this doesn't seem to actually get applied on spawns, might be conflicting with the machine parts being used - should test if it works upstream.

capacity: 10
canMicrowaveIdsSafely: false
explosionChance: 1 # Frontier 0.3<1
- type: Sprite
sprite: Structures/Machines/microwave_syndie.rsi
drawdepth: SmallObjects
snapCardinals: true
- type: Machine
board: SyndicateMicrowaveMachineCircuitboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Taken from /tg/station at commit 9065b811726ae52be5d1889f436c01a24efbf47a, edited by github user @Flareguy for Space Station 14, modified by Vermidia",
"states": [
{
"name": "mw"
},
{
"name": "mw_unlit"
},
{
"name": "mw0"
},
{
"name": "mw_running_unlit"
},
{
"name": "mwb"
},
{
"name": "mwbloody0"
},
{
"name": "mwbloody1"
},
{
"name": "mwo"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading