Adds construct / deconstruct crates (#5650)

This commit is contained in:
Peptide90
2021-12-06 22:10:03 +00:00
committed by GitHub
parent 38990d4f95
commit e2a7fd24d5
14 changed files with 319 additions and 32 deletions

View File

@@ -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<ConstructionGuideEntry> GenerateGuideEntry()
{
yield return new ConstructionGuideEntry()
{
Localization = IsLocked
? "construction-step-condition-wire-panel-lock"
: "construction-step-condition-wire-panel-unlock"
};
}
}
}

View File

@@ -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<ConstructionGuideEntry> GenerateGuideEntry()
{
yield return new ConstructionGuideEntry()
{
Localization = Welded
? "construction-guide-condition-door-weld"
: "construction-guide-condition-door-unweld",
};
}
}
}

View File

@@ -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.

View File

@@ -15783,7 +15783,7 @@ entities:
parent: 0 parent: 0
type: Transform type: Transform
- uid: 456 - uid: 456
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 5.5,19.5 - pos: 5.5,19.5
parent: 0 parent: 0
@@ -27003,7 +27003,7 @@ entities:
parent: 0 parent: 0
type: Transform type: Transform
- uid: 2090 - uid: 2090
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 6.5,32.5 - pos: 6.5,32.5
parent: 0 parent: 0
@@ -27017,7 +27017,7 @@ entities:
PaperLabel: !type:ContainerSlot {} PaperLabel: !type:ContainerSlot {}
type: ContainerContainer type: ContainerContainer
- uid: 2091 - uid: 2091
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 7.5,31.5 - pos: 7.5,31.5
parent: 0 parent: 0
@@ -38052,7 +38052,7 @@ entities:
parent: 0 parent: 0
type: Transform type: Transform
- uid: 3743 - uid: 3743
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 89.5,-7.5 - pos: 89.5,-7.5
parent: 0 parent: 0
@@ -38066,7 +38066,7 @@ entities:
PaperLabel: !type:ContainerSlot {} PaperLabel: !type:ContainerSlot {}
type: ContainerContainer type: ContainerContainer
- uid: 3744 - uid: 3744
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 90.5,-7.5 - pos: 90.5,-7.5
parent: 0 parent: 0
@@ -48331,7 +48331,7 @@ entities:
ents: [] ents: []
type: ContainerContainer type: ContainerContainer
- uid: 4940 - uid: 4940
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 17.5,41.5 - pos: 17.5,41.5
parent: 0 parent: 0
@@ -52932,7 +52932,7 @@ entities:
parent: 0 parent: 0
type: Transform type: Transform
- uid: 5459 - uid: 5459
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 9.5,-18.5 - pos: 9.5,-18.5
parent: 0 parent: 0
@@ -55420,7 +55420,7 @@ entities:
cellslot_cell_container: !type:ContainerSlot {} cellslot_cell_container: !type:ContainerSlot {}
type: ContainerContainer type: ContainerContainer
- uid: 5767 - uid: 5767
type: CrateGenericonimo type: CrateGenericSteel
components: components:
- pos: 12.5,16.5 - pos: 12.5,16.5
parent: 0 parent: 0

View File

@@ -21,7 +21,7 @@
- type: entity - type: entity
id: CrateEmergencyFire id: CrateEmergencyFire
name: firefighting crate name: firefighting crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:

View File

@@ -1,7 +1,7 @@
- type: entity - type: entity
id: CrateFunPlushie id: CrateFunPlushie
name: plushie crate name: plushie crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -26,7 +26,7 @@
id: CrateFunInstruments id: CrateFunInstruments
name: big band instrument collection name: big band instrument collection
description: Get your sad station movin' and groovin' with this fine collection! Contains thirteen different instruments. description: Get your sad station movin' and groovin' with this fine collection! Contains thirteen different instruments.
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -60,7 +60,7 @@
- type: entity - type: entity
id: CrateFunArtSupplies id: CrateFunArtSupplies
name: art supplies name: art supplies
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:

View File

@@ -1,7 +1,7 @@
- type: entity - type: entity
id: CrateMaterialGlass id: CrateMaterialGlass
name: glass sheet crate name: glass sheet crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -11,7 +11,7 @@
- type: entity - type: entity
id: CrateMaterialSteel id: CrateMaterialSteel
name: steel sheet crate name: steel sheet crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -21,7 +21,7 @@
- type: entity - type: entity
id: CrateMaterialPlastic id: CrateMaterialPlastic
name: plastic sheet crate name: plastic sheet crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -31,7 +31,7 @@
- type: entity - type: entity
id: CrateMaterialWood id: CrateMaterialWood
name: wood crate name: wood crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -41,7 +41,7 @@
- type: entity - type: entity
id: CrateMaterialFuelTank id: CrateMaterialFuelTank
name: fueltank crate name: fueltank crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -51,7 +51,7 @@
#- type: entity #- type: entity
# id: CrateMaterialHFuelTank # id: CrateMaterialHFuelTank
# name: fueltank crate # name: fueltank crate
# parent: CrateGenericonimo # parent: CrateGenericSteel
# components: # components:
# - type: StorageFill # - type: StorageFill
# contents: # contents:
@@ -61,7 +61,7 @@
- type: entity - type: entity
id: CrateMaterialWaterTank id: CrateMaterialWaterTank
name: watertank crate name: watertank crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -71,7 +71,7 @@
#- type: entity #- type: entity
# id: CrateMaterialHWaterTank # id: CrateMaterialHWaterTank
# name: watertank crate # name: watertank crate
# parent: CrateGenericonimo # parent: CrateGenericSteel
# components: # components:
# - type: StorageFill # - type: StorageFill
# contents: # contents:
@@ -81,7 +81,7 @@
- type: entity - type: entity
id: CrateMaterialPlasteel id: CrateMaterialPlasteel
name: plasteel crate name: plasteel crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -91,7 +91,7 @@
- type: entity - type: entity
id: CrateMaterialPlasma id: CrateMaterialPlasma
name: solid plasma crate name: solid plasma crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:

View File

@@ -99,7 +99,7 @@
- type: entity - type: entity
id: CrateNPCMonkeyCube id: CrateNPCMonkeyCube
name: monkey cube crate name: monkey cube crate
parent: CrateGenericonimo parent: CrateGenericSteel
components: components:
- type: StorageFill - type: StorageFill
contents: contents:

View File

@@ -25,7 +25,7 @@
id: CrateServiceReplacementLights id: CrateServiceReplacementLights
name: replacement lights crate 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. 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: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -38,7 +38,7 @@
id: CrateServiceSmokeables id: CrateServiceSmokeables
name: smokeables crate name: smokeables crate
description: "Tired of a quick death on the station? Order this crate and chain-smoke your way to a coughy demise!" 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: components:
- type: StorageFill - type: StorageFill
contents: contents:
@@ -64,7 +64,7 @@
id: CrateServiceCustomSmokable id: CrateServiceCustomSmokable
name: DIY smokeables crate 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. 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: components:
- type: StorageFill - type: StorageFill
contents: contents:

View File

@@ -1,5 +1,5 @@
- type: entity - type: entity
id: CrateGenericonimo id: CrateGenericSteel
name: crate name: crate
parent: CrateGeneric parent: CrateGeneric
components: components:
@@ -20,6 +20,10 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: crate_open state_open: crate_open
state_closed: crate_door state_closed: crate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CratePlastic id: CratePlastic
@@ -43,6 +47,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: plasticcrate_open state_open: plasticcrate_open
state_closed: plasticcrate_door state_closed: plasticcrate_door
- type: Construction
graph: CratePlastic
node: crateplastic
- type: entity - type: entity
id: CrateFreezer id: CrateFreezer
@@ -66,6 +73,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: freezer_open state_open: freezer_open
state_closed: freezer_door state_closed: freezer_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateHydroponics id: CrateHydroponics
@@ -89,6 +99,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: hydrocrate_open state_open: hydrocrate_open
state_closed: hydrocrate_door state_closed: hydrocrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateMedical id: CrateMedical
@@ -112,6 +125,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: medicalcrate_open state_open: medicalcrate_open
state_closed: medicalcrate_door state_closed: medicalcrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateRadiation id: CrateRadiation
@@ -136,6 +152,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: radiationcrate_open state_open: radiationcrate_open
state_closed: radiationcrate_door state_closed: radiationcrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateInternals id: CrateInternals
@@ -159,6 +178,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: o2crate_open state_open: o2crate_open
state_closed: o2crate_door state_closed: o2crate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateElectrical id: CrateElectrical
@@ -182,6 +204,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: electricalcrate_open state_open: electricalcrate_open
state_closed: electricalcrate_door state_closed: electricalcrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateEngineering id: CrateEngineering
@@ -205,6 +230,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: engicrate_open state_open: engicrate_open
state_closed: engicrate_door state_closed: engicrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateScience id: CrateScience
@@ -228,6 +256,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: scicrate_open state_open: scicrate_open
state_closed: scicrate_door state_closed: scicrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
- type: entity - type: entity
id: CrateSurgery id: CrateSurgery
@@ -251,6 +282,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: surgerycrate_open state_open: surgerycrate_open
state_closed: surgerycrate_door state_closed: surgerycrate_door
- type: Construction
graph: CrateGenericSteel
node: crategenericsteel
# Secure Crates # Secure Crates
@@ -282,6 +316,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: secgearcrate_open state_open: secgearcrate_open
state_closed: secgearcrate_door state_closed: secgearcrate_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateEngineeringSecure id: CrateEngineeringSecure
@@ -311,6 +348,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: engicratesecure_open state_open: engicratesecure_open
state_closed: engicratesecure_door state_closed: engicratesecure_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateMedicalSecure id: CrateMedicalSecure
@@ -340,6 +380,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: medicalcratesecure_open state_open: medicalcratesecure_open
state_closed: medicalcratesecure_door state_closed: medicalcratesecure_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CratePrivateSecure id: CratePrivateSecure
@@ -368,6 +411,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: privatecrate_open state_open: privatecrate_open
state_closed: privatecrate_door state_closed: privatecrate_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateScienceSecure id: CrateScienceSecure
@@ -397,7 +443,10 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: scicratesecure_open state_open: scicratesecure_open
state_closed: scicratesecure_door state_closed: scicratesecure_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CratePlasma id: CratePlasma
name: plasma crate name: plasma crate
@@ -426,6 +475,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: plasmacrate_open state_open: plasmacrate_open
state_closed: plasmacrate_door state_closed: plasmacrate_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateSecure id: CrateSecure
@@ -454,6 +506,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: securecrate_open state_open: securecrate_open
state_closed: securecrate_door state_closed: securecrate_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateHydroSecure id: CrateHydroSecure
@@ -483,7 +538,10 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: hydrocratesecure_open state_open: hydrocratesecure_open
state_closed: hydrocratesecure_door state_closed: hydrocratesecure_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateWeaponSecure id: CrateWeaponSecure
name: secure weapon crate name: secure weapon crate
@@ -509,6 +567,9 @@
- type: StorageVisualizer - type: StorageVisualizer
state_open: weaponcrate_open state_open: weaponcrate_open
state_closed: weaponcrate_door state_closed: weaponcrate_door
- type: Construction
graph: CrateSecure
node: cratesecure
- type: entity - type: entity
id: CrateLivestock id: CrateLivestock
@@ -569,4 +630,5 @@
- SmallImpassable - SmallImpassable
- type: Construction - type: Construction
graph: CrateLivestock graph: CrateLivestock
node: start node: cratelivestock

View File

@@ -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 {}

View File

@@ -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 {}

View File

@@ -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 {}

View File

@@ -7,5 +7,26 @@
category: Storage category: Storage
description: "A wooden crate for holding livestock" description: "A wooden crate for holding livestock"
icon: Structures/Storage/Crates/livestock.rsi/livestockcrate.png icon: Structures/Storage/Crates/livestock.rsi/livestockcrate.png
objectType: Item 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