Skip to content

Commit

Permalink
Modular Computers Part 2: Disk Burner (#1580)
Browse files Browse the repository at this point in the history
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

This is **Part 2** of the Modular Computers system, adding the
functional player facing stuff- the modular computer itself, a way to
make and burn disks via the Disk Burner and a related research.

Also comes with some cleanup changes to fix parts of the system that
broke in testing.

---

# TODO

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [x] Actually run through this thing when my laptop is out of battery
(everything worked except CONSTRUCTING the disk burner)
- [ ] Add disk burning delay, make it more intuitive? Maybe a guidebook
entry?

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>

NO.

</p>
</details>

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl:
- add: Added the Disk Burner, the Modular Computer as a board and a way
to make computer disks.

---------

Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>
Signed-off-by: Eris <erisfiregamer1@gmail.com>
Signed-off-by: Eris <eris@erisws.com>
Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
  • Loading branch information
3 people authored Jan 20, 2025
1 parent 44d6099 commit 7d59d26
Show file tree
Hide file tree
Showing 16 changed files with 398 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ public sealed partial class ComputerBoardComponent : Component
{
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? Prototype { get; private set; }

[DataField]

public EntProtoId? ModularComputerProgramPrototype;
}
}
9 changes: 6 additions & 3 deletions Content.Shared/_Arcadis/Computer/ComputerDiskComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ namespace Content.Shared._Arcadis.Computer;
/// <summary>
/// Main component for the ComputerDisk system
/// </summary>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
//[Access(typeof(ComputerDiskSystem))]
public sealed partial class ComputerDiskComponent : Component
{
/// <summary>
/// The prototype of the computer that will be used
/// </summary>
[DataField]
[DataField, AutoNetworkedField]
public EntProtoId ProgramPrototype;

[AutoNetworkedField]

public EntityUid? ProgramPrototypeEntity;

[DataField]
[DataField, AutoNetworkedField]
public bool PersistState;
}
47 changes: 47 additions & 0 deletions Content.Shared/_Arcadis/Computer/ComputerDiskSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Coordinates;
using Robust.Shared.Audio;
using Content.Shared.Audio;
using Robust.Shared.Network;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio.Systems;
using Content.Shared.Popups;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Robust.Shared.Timing;

namespace Content.Shared._Arcadis.Computer;

public sealed class ComputerDiskSystem : EntitySystem
{
public string BlankDiskPrototype = "UnburnedDiskPrototype";

[Dependency] private readonly IPrototypeManager _protoMan = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ComputerDiskComponent, ExaminedEvent>(OnExamined);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
}

private void OnExamined(EntityUid uid, ComputerDiskComponent component, ExaminedEvent args)
{
if (component.ProgramPrototype == BlankDiskPrototype)
args.PushMarkup(Loc.GetString("program-disk-no-program"));
else
{
if (!_protoMan.TryIndex(component.ProgramPrototype, out EntityPrototype? prototype))
args.PushMarkup(Loc.GetString("program-disk-error"));
else
args.PushMarkup(Loc.GetString("program-disk-has-program", ("program", prototype.Name)));
}
}
}
21 changes: 21 additions & 0 deletions Content.Shared/_Arcadis/Computer/DiskBurnerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Arcadis.Computer;

/// <summary>
/// Component responsible for handling DiskBurner behaviour
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class DiskBurnerComponent : Component {

[DataField]
public string DiskSlot = "diskSlot";

[DataField]
public string BoardSlot = "boardSlot";

[DataField]
public string VerbName = "Burn Disk";
}
117 changes: 117 additions & 0 deletions Content.Shared/_Arcadis/Computer/DiskBurnerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Coordinates;
using Robust.Shared.Audio;
using Content.Shared.Audio;
using Robust.Shared.Network;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio.Systems;
using Content.Shared.Popups;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Robust.Shared.Timing;
using Content.Shared.Construction.Components;
using Content.Shared.Verbs;
using Robust.Shared.Utility;

namespace Content.Shared._Arcadis.Computer;

public sealed class DiskBurnerSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;

[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;

[Dependency] private readonly SharedPopupSystem _popupSystem = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DiskBurnerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<DiskBurnerComponent, GetVerbsEvent<Verb>>(GetVerb);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
}

private void GetVerb(EntityUid uid, DiskBurnerComponent component, GetVerbsEvent<Verb> args)
{
args.Verbs.Add(new Verb
{
Act = () => BurnDisk(args.User, uid, component),
Text = Loc.GetString(component.VerbName),
// TODO VERB ICON find a better icon
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
});
}

private void BurnDisk(EntityUid user, EntityUid entity, DiskBurnerComponent component)
{
if (!TryComp(entity, out ItemSlotsComponent? slots)
|| !_itemSlots.TryGetSlot(entity, component.DiskSlot, out var diskSlot)
|| !_itemSlots.TryGetSlot(entity, component.BoardSlot, out var boardSlot)
|| diskSlot.Item is null
|| boardSlot.Item is null
|| !TryComp(boardSlot.Item.Value, out ComputerBoardComponent? boardComp)
|| boardComp.ModularComputerProgramPrototype is null
|| !TryComp(diskSlot.Item.Value, out ComputerDiskComponent? diskComp))
{
_popupSystem.PopupPredicted(Loc.GetString("disk-burner-activate-not-ready"), entity, user);
return;
}

diskComp.ProgramPrototype = boardComp.ModularComputerProgramPrototype.Value;
_popupSystem.PopupPredicted(Loc.GetString("disk-burner-activate-finished"), entity, user);

}

private void OnExamined(EntityUid uid, DiskBurnerComponent component, ExaminedEvent args)
{
if (!TryComp(uid, out ItemSlotsComponent? slots)
|| !_itemSlots.TryGetSlot(uid, component.DiskSlot, out var diskSlot)
|| !_itemSlots.TryGetSlot(uid, component.BoardSlot, out var boardSlot))
{
args.PushMarkup(Loc.GetString("disk-burner-admemes-fail"));
return;
}

if (diskSlot.Item is null || boardSlot.Item is null)
{
var missing = new List<string>();

if (diskSlot.Item is null)
missing.Add("disk");

if (boardSlot.Item is null)
missing.Add("or");

args.PushMarkup(Loc.GetString("disk-burner-missing", ("missing", string.Join(", or ", missing))));
return;
}

if (!TryComp(diskSlot.Item.Value, out ComputerDiskComponent? diskComp))
{
args.PushMarkup(Loc.GetString("disk-burner-bad-disk"));
return;
}

if (!TryComp(boardSlot.Item.Value, out ComputerBoardComponent? boardComp))
{
args.PushMarkup(Loc.GetString("disk-burner-incompatible-board"));
return;
}

if (boardComp.ModularComputerProgramPrototype is null)
{
args.PushMarkup(Loc.GetString("disk-burner-incompatible-board"));
return;
}

args.PushMarkup(Loc.GetString("disk-burner-ready"));

}
}
4 changes: 4 additions & 0 deletions Content.Shared/_Arcadis/Computer/ModularComputerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ public sealed partial class ModularComputerComponent : Component

[DataField]
public SoundSpecifier? DiskInsertSound = new SoundPathSpecifier("/Audio/_Arcadis/computer_startup.ogg");

[DataField]

public bool RequiresPower = true;
}
15 changes: 14 additions & 1 deletion Content.Shared/_Arcadis/Computer/ModularComputerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Robust.Shared.Timing;
using Content.Shared.Power.EntitySystems;

namespace Content.Shared._Arcadis.Computer;

Expand All @@ -28,6 +29,8 @@ public sealed class ModularComputerSystem : EntitySystem

[Dependency] private readonly IGameTiming _gameTiming = default!;

[Dependency] private readonly SharedPowerReceiverSystem _power = default!;

public string BlankDiskPrototype = "UnburnedDiskPrototype";
public override void Initialize()
{
Expand All @@ -49,6 +52,9 @@ private void OnExamined(EntityUid uid, ModularComputerComponent component, Exami
|| !_itemSlots.TryGetSlot(uid, component.DiskSlot, out var diskSlot, slots))
return;

if (component.RequiresPower && _power.IsPowered(uid) == false)
return;

if (diskSlot.Item == null || !TryComp(diskSlot.Item, out ComputerDiskComponent? diskComp))
{
args.PushMarkup(Loc.GetString("modular-computer-examine-no-disk"));
Expand All @@ -70,6 +76,12 @@ private void OnActivate(EntityUid uid, ModularComputerComponent component, Activ
|| !_itemSlots.TryGetSlot(uid, component.DiskSlot, out var diskSlot, slots))
return;

if (component.RequiresPower && _power.IsPowered(uid) == false)
{
_popupSystem.PopupPredicted(Loc.GetString("modular-computer-no-power"), uid, args.User);
return;
}

if (diskSlot.Item == null || !TryComp(diskSlot.Item, out ComputerDiskComponent? diskComp))
{
_popupSystem.PopupPredicted(Loc.GetString("modular-computer-no-program"), uid, args.User);
Expand All @@ -82,7 +94,8 @@ private void OnActivate(EntityUid uid, ModularComputerComponent component, Activ
return;
}

if (_gameTiming.IsFirstTimePredicted || _netMan.IsServer) {
if (_netMan.IsServer) // Has to run only on server or mispredict opens 2 seperate UIs. Very bad.
{
var activateMsg = new ActivateInWorldEvent(args.User, diskComp.ProgramPrototypeEntity.Value, true);
RaiseLocalEvent(diskComp.ProgramPrototypeEntity.Value, activateMsg);
}
Expand Down
18 changes: 18 additions & 0 deletions Resources/Locale/en-US/_Arcadis/modularComputer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,21 @@ modular-computer-no-program-on-disk = ERROR: No program on disk!
modular-computer-examine-no-disk = This computer doesn't have a program loaded.
modular-computer-examine-disk-error = This computer doesn't have a program loaded. An error on the display reports that the loaded disk has no program.
modular-computer-examine-has-program = This computer has the {$program} program loaded.
modular-computer-no-power = The computer is unpowered.
program-disk-no-program = This disk has no program burnt to it.
program-disk-error = This disk has a corrupted program burnt to it.
program-disk-has-program = This disk has the {$program} program burnt to it.
disk-burner-missing = The disk burner reports that there is no {$missing} inserted.
disk-burner-bad-disk = The disk burner reports that the disk is not suitable to be burned to.
disk-burner-incompatible-board = The disk burner reports that the inserted board is not compatible.
disk-burner-ready = The disk burner reports that it is ready.
disk-burner-admemes-fail = The disk burner reports that a required slot is not available.
disk-burner-activate-not-ready = The disk burner isn't ready yet!
disk-burner-activate-finished = The disk burner beeps successfully!
research-technology-modular-computing = Modular Computing
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
Glass: 230
chemicalComposition:
Silicon: 20
- type: Tag
tags:
- ComputerBoard


- type: entity
parent: BaseComputerCircuitboard
Expand Down Expand Up @@ -277,6 +281,7 @@
state: cpu_command
- type: ComputerBoard
prototype: ComputerComms
modularComputerProgramPrototype: CommunicationsConsoleDiskPrototype

- type: entity
parent: BaseComputerCircuitboard
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
- WeaponCapacitorRechargerCircuitboard
- HandheldStationMap
- ClothingHeadHatWelding
- ProgramDiskUnburnt # Arcadis - Modular Computer System
- FauxTileAstroGrass
- FauxTileMowedAstroGrass
- FauxTileJungleAstroGrass
Expand Down Expand Up @@ -574,6 +575,8 @@
- AutodocCircuitboard # Shitmed Change
- OperatingTableCircuitboard # Shitmed Change
- MaterialSiloCircuitboard
- BaseComputerModularCircuitBoard # Arcadis - Modular Computer System
- DiskBurnerMachineCircuitboard # Arcadis - Modular Computer System
- type: EmagLatheRecipes
emagDynamicRecipes:
- ShuttleGunDusterCircuitboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
name: modular computer
description: Part of a recent initiative to make computers less static. Comes with a disk slot for various "program disks".
components:
- type: Computer
board: BaseComputerModularCircuitBoard
- type: ModularComputer
# I plan to make modular itemslots a thing in the future for stuff like the fax machine. Coming Soon:tm:
- type: ItemSlots
slots:
modularComputerDiskSlot:
name: Disk
name: Program disk
insertSound:
path: /Audio/Machines/terminal_insert_disc.ogg
ejectSound:
path: /Audio/Machines/terminal_insert_disc.ogg
whitelist:
tags:
- ComputerDisk
- type: ContainerContainer
containers:
board: !type:Container
Expand All @@ -25,5 +29,21 @@
occludes: True
ent: null

- type: entity
parent: BaseComputerCircuitboard
id: BaseComputerModularCircuitBoard
name: modular computer board
description: A computer printed circuit board for a modular computer.
components:
- type: ComputerBoard
prototype: BaseComputerModular


- type: latheRecipe
id: BaseComputerModularCircuitBoard
result: BaseComputerModularCircuitBoard
category: Circuitry
completetime: 4
materials:
Steel: 100
Glass: 500
Gold: 100
Loading

0 comments on commit 7d59d26

Please sign in to comment.