From e2a7fd24d520664bc1e394d59fb980bae13cd6b5 Mon Sep 17 00:00:00 2001 From: Peptide90 <78795277+Peptide90@users.noreply.github.com> Date: Mon, 6 Dec 2021 22:10:03 +0000 Subject: [PATCH] Adds construct / deconstruct crates (#5650) --- .../Construction/Conditions/Locked.cs | 58 +++++++++++++++ .../Construction/Conditions/StorageWelded.cs | 55 +++++++++++++++ .../en-US/construction/conditions/locked.ftl | 5 ++ Resources/Maps/packedstation.yml | 16 ++--- .../Catalog/Fills/Crates/emergency.yml | 2 +- .../Prototypes/Catalog/Fills/Crates/fun.yml | 6 +- .../Catalog/Fills/Crates/materials.yml | 20 +++--- .../Prototypes/Catalog/Fills/Crates/npc.yml | 2 +- .../Catalog/Fills/Crates/service.yml | 6 +- .../Structures/Storage/Crates/crates.yml | 70 +++++++++++++++++-- .../Crafting/Graphs/crategenericsteel.yml | 28 ++++++++ .../Recipes/Crafting/Graphs/crateplastic.yml | 28 ++++++++ .../Recipes/Crafting/Graphs/cratesecure.yml | 30 ++++++++ .../Prototypes/Recipes/Crafting/crates.yml | 25 ++++++- 14 files changed, 319 insertions(+), 32 deletions(-) create mode 100644 Content.Server/Construction/Conditions/Locked.cs create mode 100644 Content.Server/Construction/Conditions/StorageWelded.cs create mode 100644 Resources/Locale/en-US/construction/conditions/locked.ftl create mode 100644 Resources/Prototypes/Recipes/Crafting/Graphs/crategenericsteel.yml create mode 100644 Resources/Prototypes/Recipes/Crafting/Graphs/crateplastic.yml create mode 100644 Resources/Prototypes/Recipes/Crafting/Graphs/cratesecure.yml diff --git a/Content.Server/Construction/Conditions/Locked.cs b/Content.Server/Construction/Conditions/Locked.cs new file mode 100644 index 0000000000..6204b42067 --- /dev/null +++ b/Content.Server/Construction/Conditions/Locked.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Content.Server.Storage.Components; +using Content.Shared.Construction; +using Content.Shared.Examine; +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Localization; +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Utility; + +namespace Content.Server.Construction.Conditions +{ + [UsedImplicitly] + [DataDefinition] + public class Locked : IGraphCondition + { + [DataField("locked")] + public bool IsLocked { get; private set; } = true; + + public bool Condition(EntityUid uid, IEntityManager entityManager) + { + if (!entityManager.TryGetComponent(uid, out LockComponent? lockcomp)) + return false; + + return lockcomp.Locked == IsLocked; + } + + public bool DoExamine(ExaminedEvent args) + { + var entity = args.Examined; + + if (!entity.TryGetComponent(out LockComponent? lockcomp)) return false; + + switch (IsLocked) + { + case true when !lockcomp.Locked: + args.PushMarkup(Loc.GetString("construction-examine-condition-lock")); + return true; + case false when lockcomp.Locked: + args.PushMarkup(Loc.GetString("construction-examine-condition-unlock")); + return true; + } + + return false; + } + + public IEnumerable GenerateGuideEntry() + { + yield return new ConstructionGuideEntry() + { + Localization = IsLocked + ? "construction-step-condition-wire-panel-lock" + : "construction-step-condition-wire-panel-unlock" + }; + } + } +} diff --git a/Content.Server/Construction/Conditions/StorageWelded.cs b/Content.Server/Construction/Conditions/StorageWelded.cs new file mode 100644 index 0000000000..435b16dcf9 --- /dev/null +++ b/Content.Server/Construction/Conditions/StorageWelded.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; +using Content.Server.Storage.Components; +using Content.Shared.Construction; +using Content.Shared.Examine; +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Localization; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Construction.Conditions +{ + [UsedImplicitly] + [DataDefinition] + public class StorageWelded : IGraphCondition + { + [DataField("welded")] + public bool Welded { get; private set; } = true; + + public bool Condition(EntityUid uid, IEntityManager entityManager) + { + if (!entityManager.TryGetComponent(uid, out EntityStorageComponent? entityStorageComponent)) + return false; + + return entityStorageComponent.IsWeldedShut == Welded; + } + + public bool DoExamine(ExaminedEvent args) + { + var entity = args.Examined; + + if (!entity.TryGetComponent(out EntityStorageComponent? entityStorage)) return false; + + if (entityStorage.IsWeldedShut != Welded) + { + if (Welded == true) + args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", entity.Name)) + "\n"); + else + args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", entity.Name)) + "\n"); + return true; + } + + return false; + } + + public IEnumerable GenerateGuideEntry() + { + yield return new ConstructionGuideEntry() + { + Localization = Welded + ? "construction-guide-condition-door-weld" + : "construction-guide-condition-door-unweld", + }; + } + } +} diff --git a/Resources/Locale/en-US/construction/conditions/locked.ftl b/Resources/Locale/en-US/construction/conditions/locked.ftl new file mode 100644 index 0000000000..8093ee27a1 --- /dev/null +++ b/Resources/Locale/en-US/construction/conditions/locked.ftl @@ -0,0 +1,5 @@ +# Locked +construction-examine-condition-unlock = First, [color=limegreen]unlock[/color] it. +construction-examine-condition-lock = First, [color=red]lock[/color] it. +construction-step-condition-unlock = It must be unlocked. +construction-step-condition-lock = It must be locked. \ No newline at end of file diff --git a/Resources/Maps/packedstation.yml b/Resources/Maps/packedstation.yml index 54dc8a325e..1c9fac5660 100644 --- a/Resources/Maps/packedstation.yml +++ b/Resources/Maps/packedstation.yml @@ -15783,7 +15783,7 @@ entities: parent: 0 type: Transform - uid: 456 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 5.5,19.5 parent: 0 @@ -27003,7 +27003,7 @@ entities: parent: 0 type: Transform - uid: 2090 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 6.5,32.5 parent: 0 @@ -27017,7 +27017,7 @@ entities: PaperLabel: !type:ContainerSlot {} type: ContainerContainer - uid: 2091 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 7.5,31.5 parent: 0 @@ -38052,7 +38052,7 @@ entities: parent: 0 type: Transform - uid: 3743 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 89.5,-7.5 parent: 0 @@ -38066,7 +38066,7 @@ entities: PaperLabel: !type:ContainerSlot {} type: ContainerContainer - uid: 3744 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 90.5,-7.5 parent: 0 @@ -48331,7 +48331,7 @@ entities: ents: [] type: ContainerContainer - uid: 4940 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 17.5,41.5 parent: 0 @@ -52932,7 +52932,7 @@ entities: parent: 0 type: Transform - uid: 5459 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 9.5,-18.5 parent: 0 @@ -55420,7 +55420,7 @@ entities: cellslot_cell_container: !type:ContainerSlot {} type: ContainerContainer - uid: 5767 - type: CrateGenericonimo + type: CrateGenericSteel components: - pos: 12.5,16.5 parent: 0 diff --git a/Resources/Prototypes/Catalog/Fills/Crates/emergency.yml b/Resources/Prototypes/Catalog/Fills/Crates/emergency.yml index 23680b8a99..3e9a83b8be 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/emergency.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/emergency.yml @@ -21,7 +21,7 @@ - type: entity id: CrateEmergencyFire name: firefighting crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: diff --git a/Resources/Prototypes/Catalog/Fills/Crates/fun.yml b/Resources/Prototypes/Catalog/Fills/Crates/fun.yml index 524bb64cde..3b77597215 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/fun.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/fun.yml @@ -1,7 +1,7 @@ - type: entity id: CrateFunPlushie name: plushie crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -26,7 +26,7 @@ id: CrateFunInstruments name: big band instrument collection description: Get your sad station movin' and groovin' with this fine collection! Contains thirteen different instruments. - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -60,7 +60,7 @@ - type: entity id: CrateFunArtSupplies name: art supplies - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: diff --git a/Resources/Prototypes/Catalog/Fills/Crates/materials.yml b/Resources/Prototypes/Catalog/Fills/Crates/materials.yml index c9962f9073..49fd9b5418 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/materials.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/materials.yml @@ -1,7 +1,7 @@ - type: entity id: CrateMaterialGlass name: glass sheet crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -11,7 +11,7 @@ - type: entity id: CrateMaterialSteel name: steel sheet crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -21,7 +21,7 @@ - type: entity id: CrateMaterialPlastic name: plastic sheet crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -31,7 +31,7 @@ - type: entity id: CrateMaterialWood name: wood crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -41,7 +41,7 @@ - type: entity id: CrateMaterialFuelTank name: fueltank crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -51,7 +51,7 @@ #- type: entity # id: CrateMaterialHFuelTank # name: fueltank crate -# parent: CrateGenericonimo +# parent: CrateGenericSteel # components: # - type: StorageFill # contents: @@ -61,7 +61,7 @@ - type: entity id: CrateMaterialWaterTank name: watertank crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -71,7 +71,7 @@ #- type: entity # id: CrateMaterialHWaterTank # name: watertank crate -# parent: CrateGenericonimo +# parent: CrateGenericSteel # components: # - type: StorageFill # contents: @@ -81,7 +81,7 @@ - type: entity id: CrateMaterialPlasteel name: plasteel crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -91,7 +91,7 @@ - type: entity id: CrateMaterialPlasma name: solid plasma crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: diff --git a/Resources/Prototypes/Catalog/Fills/Crates/npc.yml b/Resources/Prototypes/Catalog/Fills/Crates/npc.yml index 65063bcc49..26c7bcb3ca 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/npc.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/npc.yml @@ -99,7 +99,7 @@ - type: entity id: CrateNPCMonkeyCube name: monkey cube crate - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: diff --git a/Resources/Prototypes/Catalog/Fills/Crates/service.yml b/Resources/Prototypes/Catalog/Fills/Crates/service.yml index 00e85f84fa..2e5a757526 100644 --- a/Resources/Prototypes/Catalog/Fills/Crates/service.yml +++ b/Resources/Prototypes/Catalog/Fills/Crates/service.yml @@ -25,7 +25,7 @@ id: CrateServiceReplacementLights name: replacement lights crate description: May the light of Aether shine upon this station! Or at least, the light of forty two light tubes and twenty one light bulbs. - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -38,7 +38,7 @@ id: CrateServiceSmokeables name: smokeables crate description: "Tired of a quick death on the station? Order this crate and chain-smoke your way to a coughy demise!" - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: @@ -64,7 +64,7 @@ id: CrateServiceCustomSmokable name: DIY smokeables crate description: Want to get a little creative with what you use to destroy your lungs? Then this crate is for you! Has everything you need to roll your own Cigarettes. - parent: CrateGenericonimo + parent: CrateGenericSteel components: - type: StorageFill contents: diff --git a/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml b/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml index 1bcd889158..bd40a16d06 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml @@ -1,5 +1,5 @@ - type: entity - id: CrateGenericonimo + id: CrateGenericSteel name: crate parent: CrateGeneric components: @@ -20,6 +20,10 @@ - type: StorageVisualizer state_open: crate_open state_closed: crate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel + - type: entity id: CratePlastic @@ -43,6 +47,9 @@ - type: StorageVisualizer state_open: plasticcrate_open state_closed: plasticcrate_door + - type: Construction + graph: CratePlastic + node: crateplastic - type: entity id: CrateFreezer @@ -66,6 +73,9 @@ - type: StorageVisualizer state_open: freezer_open state_closed: freezer_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateHydroponics @@ -89,6 +99,9 @@ - type: StorageVisualizer state_open: hydrocrate_open state_closed: hydrocrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateMedical @@ -112,6 +125,9 @@ - type: StorageVisualizer state_open: medicalcrate_open state_closed: medicalcrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateRadiation @@ -136,6 +152,9 @@ - type: StorageVisualizer state_open: radiationcrate_open state_closed: radiationcrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateInternals @@ -159,6 +178,9 @@ - type: StorageVisualizer state_open: o2crate_open state_closed: o2crate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateElectrical @@ -182,6 +204,9 @@ - type: StorageVisualizer state_open: electricalcrate_open state_closed: electricalcrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateEngineering @@ -205,6 +230,9 @@ - type: StorageVisualizer state_open: engicrate_open state_closed: engicrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateScience @@ -228,6 +256,9 @@ - type: StorageVisualizer state_open: scicrate_open state_closed: scicrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel - type: entity id: CrateSurgery @@ -251,6 +282,9 @@ - type: StorageVisualizer state_open: surgerycrate_open state_closed: surgerycrate_door + - type: Construction + graph: CrateGenericSteel + node: crategenericsteel # Secure Crates @@ -282,6 +316,9 @@ - type: StorageVisualizer state_open: secgearcrate_open state_closed: secgearcrate_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CrateEngineeringSecure @@ -311,6 +348,9 @@ - type: StorageVisualizer state_open: engicratesecure_open state_closed: engicratesecure_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CrateMedicalSecure @@ -340,6 +380,9 @@ - type: StorageVisualizer state_open: medicalcratesecure_open state_closed: medicalcratesecure_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CratePrivateSecure @@ -368,6 +411,9 @@ - type: StorageVisualizer state_open: privatecrate_open state_closed: privatecrate_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CrateScienceSecure @@ -397,7 +443,10 @@ - type: StorageVisualizer state_open: scicratesecure_open state_closed: scicratesecure_door - + - type: Construction + graph: CrateSecure + node: cratesecure + - type: entity id: CratePlasma name: plasma crate @@ -426,6 +475,9 @@ - type: StorageVisualizer state_open: plasmacrate_open state_closed: plasmacrate_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CrateSecure @@ -454,6 +506,9 @@ - type: StorageVisualizer state_open: securecrate_open state_closed: securecrate_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CrateHydroSecure @@ -483,7 +538,10 @@ - type: StorageVisualizer state_open: hydrocratesecure_open state_closed: hydrocratesecure_door - + - type: Construction + graph: CrateSecure + node: cratesecure + - type: entity id: CrateWeaponSecure name: secure weapon crate @@ -509,6 +567,9 @@ - type: StorageVisualizer state_open: weaponcrate_open state_closed: weaponcrate_door + - type: Construction + graph: CrateSecure + node: cratesecure - type: entity id: CrateLivestock @@ -569,4 +630,5 @@ - SmallImpassable - type: Construction graph: CrateLivestock - node: start + node: cratelivestock + diff --git a/Resources/Prototypes/Recipes/Crafting/Graphs/crategenericsteel.yml b/Resources/Prototypes/Recipes/Crafting/Graphs/crategenericsteel.yml new file mode 100644 index 0000000000..d3b6f82446 --- /dev/null +++ b/Resources/Prototypes/Recipes/Crafting/Graphs/crategenericsteel.yml @@ -0,0 +1,28 @@ +- type: constructionGraph + id: CrateGenericSteel + start: start + graph: + - node: start + edges: + - to: crategenericsteel + steps: + - material: Steel + amount: 5 + doAfter: 5 + + + - node: crategenericsteel + entity: CrateGenericSteel + edges: + - to: start + steps: + - tool: Screwing + doAfter: 5 + conditions: + - !type:StorageWelded + welded: false + completed: + - !type:SpawnPrototype + prototype: SheetSteel1 + amount: 5 + - !type:DeleteEntity {} \ No newline at end of file diff --git a/Resources/Prototypes/Recipes/Crafting/Graphs/crateplastic.yml b/Resources/Prototypes/Recipes/Crafting/Graphs/crateplastic.yml new file mode 100644 index 0000000000..ae5167afe1 --- /dev/null +++ b/Resources/Prototypes/Recipes/Crafting/Graphs/crateplastic.yml @@ -0,0 +1,28 @@ +- type: constructionGraph + id: CratePlastic + start: start + graph: + - node: start + edges: + - to: crateplastic + steps: + - material: Plastic + amount: 5 + doAfter: 5 + + + - node: crateplastic + entity: CratePlastic + edges: + - to: start + steps: + - tool: Screwing + doAfter: 5 + conditions: + - !type:StorageWelded + welded: false + completed: + - !type:SpawnPrototype + prototype: SheetPlastic1 + amount: 5 + - !type:DeleteEntity {} \ No newline at end of file diff --git a/Resources/Prototypes/Recipes/Crafting/Graphs/cratesecure.yml b/Resources/Prototypes/Recipes/Crafting/Graphs/cratesecure.yml new file mode 100644 index 0000000000..bc4aa4bd43 --- /dev/null +++ b/Resources/Prototypes/Recipes/Crafting/Graphs/cratesecure.yml @@ -0,0 +1,30 @@ +- type: constructionGraph + id: CrateSecure + start: start + graph: + - node: start + edges: + - to: cratesecure + steps: + - material: Steel + amount: 5 + doAfter: 5 + + + - node: cratesecure + entity: CrateSecure + edges: + - to: start + steps: + - tool: Screwing + doAfter: 5 + conditions: + - !type:StorageWelded + welded: false + - !type:Locked + locked: false + completed: + - !type:SpawnPrototype + prototype: SheetSteel1 + amount: 5 + - !type:DeleteEntity {} \ No newline at end of file diff --git a/Resources/Prototypes/Recipes/Crafting/crates.yml b/Resources/Prototypes/Recipes/Crafting/crates.yml index 51ca15e03c..767ff0e391 100644 --- a/Resources/Prototypes/Recipes/Crafting/crates.yml +++ b/Resources/Prototypes/Recipes/Crafting/crates.yml @@ -7,5 +7,26 @@ category: Storage description: "A wooden crate for holding livestock" icon: Structures/Storage/Crates/livestock.rsi/livestockcrate.png - objectType: Item - \ No newline at end of file + objectType: Structure + +- type: construction + name: steel crate + id: CrateGenericSteel + graph: CrateGenericSteel + startNode: start + targetNode: crategenericsteel + category: Storage + description: "A metal crate for storing things" + icon: Structures/Storage/Crates/generic.rsi/crate_icon.png + objectType: Structure + +- type: construction + name: plastic crate + id: CratePlastic + graph: CratePlastic + startNode: start + targetNode: crateplastic + category: Storage + description: "A plastic crate for storing things" + icon: Structures/Storage/Crates/plastic.rsi/plasticcrate_icon.png + objectType: Structure \ No newline at end of file