Skip to content

Commit

Permalink
Okay, finally, can do stuff now, cool!
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisfiregamer1 committed Jan 31, 2025
1 parent 26143be commit 75020e7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 49 deletions.
3 changes: 0 additions & 3 deletions Content.Shared/_Arcadis/Scrap/ScrapReprocessorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ public sealed partial class ScrapReprocessorComponent : Component

[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Effects/metal_scrape1.ogg");

[DataField]
public EntityUid? MatSilo;
}
35 changes: 7 additions & 28 deletions Content.Shared/_Arcadis/Scrap/ScrapReprocessorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ public sealed class ScrapReprocessorSystem : EntitySystem
[Dependency] private readonly SharedDeviceLinkSystem _deviceLinkSystem = default!;
[Dependency] private readonly SharedMaterialStorageSystem _matStorSys = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;

[Dependency] private readonly ILogManager _logManager = default!;
private ISawmill _sawmill = default!;
public override void Initialize()
{
_sawmill = _logManager.GetSawmill("factorio");

base.Initialize();
SubscribeLocalEvent<ScrapReprocessorComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<ScrapReprocessorComponent, NewLinkEvent>(OnNewLink);
SubscribeLocalEvent<ScrapReprocessorComponent, PortDisconnectedEvent>(OnPortDisconnected);
}

private void OnInteractUsing(EntityUid uid, ScrapReprocessorComponent component, InteractUsingEvent args)
{
// Check if inhand item is scrap
if (!TryComp<ScrapComponent>(args.Used, out var scrapComponent))
{
_popupSystem.PopupPredicted(Loc.GetString("reprocessor-not-scrap"), args.Target, args.User);
_popupSystem.PopupPredicted(Loc.GetString("reprocessor-not-scrap"), uid, args.User);
return;
}

// Check if reprocessor has a matsilo connected
if (!component.MatSilo.HasValue)
if (!TryComp<MaterialSiloUtilizerComponent>(uid, out var siloUtilizerComponent) || siloUtilizerComponent.Silo == null)
{
_popupSystem.PopupPredicted(Loc.GetString("reprocessor-no-silo"), args.Target, args.User);
return;
Expand All @@ -41,31 +44,7 @@ private void OnInteractUsing(EntityUid uid, ScrapReprocessorComponent component,
// Play sound
_audioSystem.PlayPvs(component.Sound, args.Target);

_popupSystem.PopupPredicted(Loc.GetString("debug"), args.Target, args.User);


}

private void OnNewLink(EntityUid uid, ScrapReprocessorComponent component, NewLinkEvent args)
{
if (args.Source != uid)
return;

if (TryComp<MaterialSiloComponent>(args.Sink, out var siloComponent))
{
component.MatSilo = args.Sink;
}
else
{
_popupSystem.PopupPredicted(Loc.GetString("debug"), args.Source, args.User);
}
}

private void OnPortDisconnected(EntityUid uid, ScrapReprocessorComponent component, PortDisconnectedEvent args)
{
if (args.Port == "MaterialSilo")
{
component.MatSilo = null;
}
}
}
43 changes: 25 additions & 18 deletions Resources/Prototypes/_Arcadis/Entities/Objects/Materials/scrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,34 @@
description: A collection of scrap from whatever wrecks you come across.
components:
- type: Sprite
sprite: Objects/Materials/Sheets/metal.rsi
sprite: Objects/Materials/materials.rsi
state: cloth_3
layers:
- state: cloth_3
map: ["base"]
- type: Item
sprite: Objects/Materials/Sheets/metal.rsi
sprite: Objects/Materials/materials.rsi
size: Normal
- type: Appearance
- type: StaticPrice
price: 0
- type: Tag
tags:
- NoPaint
- type: Stack
stackType: Scrap
baseLayer: base
layerStates:
- cloth
- cloth_2
- cloth_3

- type: entity
parent: SheetScrapBase
id: SheetScrap
name: scrap
suffix: Full
components:
- type: Sprite
state: steel_3
layers:
- state: steel_3
map: ["base"]
- type: Item
- type: Appearance
- type: Scrap
outputItems: ScrapItemOutputs
outputMaterials: ScrapMaterialOutputs
Expand All @@ -39,16 +44,9 @@
suffix: Full
description: Scrap salvaged from alien wrecks. Reprocessing this may hold some value.
components:
- type: Sprite
state: steel_3
layers:
- state: steel_3
map: ["base"]
- type: Item
- type: Appearance
- type: Scrap
outputItems: AlienScrapItemOutputs
outputMaterials: AlientScrapMaterialOutputs
outputMaterials: AlienScrapMaterialOutputs
itemChance: 0.05

- type: weightedRandomEntity
Expand Down Expand Up @@ -79,8 +77,17 @@
ResearchDisk20000: 1

- type: weightedRandomEntity
id: AlientScrapMaterialOutputs
id: AlienScrapMaterialOutputs
weights:
Steel: 10
Glass: 3
Holmium: 1

- type: stack
id: Scrap
name: scrap
icon: { sprite: Objects/Materials/materials.rsi, state: cloth }
spawn: SheetScrap
maxCount: 30
itemSize: 1

0 comments on commit 75020e7

Please sign in to comment.