diff --git a/Content.Shared/_NF/Foldable/FoldableFixtureComponent.cs b/Content.Shared/_NF/Foldable/FoldableFixtureComponent.cs new file mode 100644 index 00000000000..a35cf433cb6 --- /dev/null +++ b/Content.Shared/_NF/Foldable/FoldableFixtureComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Shared._NF.Foldable.Systems; + +[RegisterComponent] +public sealed partial class FoldableFixtureComponent : Component +{ + [DataField(required: true)] + public List FoldedFixtures; + [DataField(required: true)] + public List UnfoldedFixtures; +} diff --git a/Content.Shared/_NF/Foldable/FoldableFixtureSystem.cs b/Content.Shared/_NF/Foldable/FoldableFixtureSystem.cs new file mode 100644 index 00000000000..1ebbfcac260 --- /dev/null +++ b/Content.Shared/_NF/Foldable/FoldableFixtureSystem.cs @@ -0,0 +1,56 @@ +using Content.Shared.Foldable; +using Robust.Shared.Physics.Systems; + +namespace Content.Shared._NF.Foldable.Systems; + +public sealed class FoldableFixtureSystem : EntitySystem +{ + [Dependency] private readonly FixtureSystem _fixtures = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; + + public override void Initialize() + { + SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnFolded); + } + + private void OnMapInit(EntityUid uid, FoldableFixtureComponent component, MapInitEvent args) + { + if (TryComp(uid, out var foldable)) + SetFoldedFixtures(uid, foldable.IsFolded, component); + } + + private void OnFolded(EntityUid uid, FoldableFixtureComponent? component, ref FoldedEvent args) + { + SetFoldedFixtures(uid, args.IsFolded, component); + } + + // Sets all relevant fixtures for the entity to an appropriate hard/soft state. + private void SetFoldedFixtures(EntityUid uid, bool isFolded, FoldableFixtureComponent? component) + { + if (!Resolve(uid, ref component)) + return; + + if (isFolded) + { + SetAllFixtureHardness(uid, component.FoldedFixtures, true); + SetAllFixtureHardness(uid, component.UnfoldedFixtures, false); + } + else + { + SetAllFixtureHardness(uid, component.FoldedFixtures, false); + SetAllFixtureHardness(uid, component.UnfoldedFixtures, true); + } + } + + // Sets all fixtures on an entity in a list to either be hard or soft. + void SetAllFixtureHardness(EntityUid uid, List fixtures, bool hard) + { + foreach (var fixName in fixtures) + { + var fixture = _fixtures.GetFixtureOrNull(uid, fixName); + if (fixture != null) + _physics.SetHard(uid, fixture, hard); + } + } +} diff --git a/Resources/Prototypes/_NF/Entities/Structures/Furniture/tables.yml b/Resources/Prototypes/_NF/Entities/Structures/Furniture/tables.yml new file mode 100644 index 00000000000..895c91fad28 --- /dev/null +++ b/Resources/Prototypes/_NF/Entities/Structures/Furniture/tables.yml @@ -0,0 +1,123 @@ + +- type: entity + parent: BaseDeployFoldable + id: TableFolding + name: folding table + description: If you carry six of these you become the coolest kid at church. + components: + # Table bits + - type: SpriteFade + - type: Clickable + - type: InteractionOutline + - type: Climbable + - type: GlassTable + climberDamage: + types: + Blunt: 15 + tableDamage: + types: + Blunt: 25 + tableMassLimit: 60 + - type: PlaceableSurface + - type: Physics + bodyType: Dynamic + fixedRotation: true + - type: Pullable + - type: Fixtures + fixtures: + table: # For the unfolded table + shape: + !type:PhysShapeAabb + bounds: "-0.4,-0.4,0.4,0.4" + density: 55 + mask: + - TableMask + layer: + - TableLayer + hard: true + item: # For the folded, carriable table + shape: + !type:PhysShapeAabb + bounds: "-0.25,-0.25,0.25,0.25" + density: 20 + mask: + - ItemMask + restitution: 0.3 + friction: 0.2 + hard: false + - type: Bonkable + bonkDamage: + types: + Blunt: 4 + bonkSound: !type:SoundCollectionSpecifier + collection: TrayHit + - type: FootstepModifier + footstepSoundCollection: + collection: FootstepHull + # Item bits + - type: MovedByPressure + - type: Item + size: Huge + - type: Sprite + sprite: _NF/Structures/Furniture/folding_table.rsi + layers: + - state: folding + map: ["unfoldedLayer"] + - state: folding_folded + map: ["foldedLayer"] + visible: false + noRot: true + - type: Appearance + - type: MeleeWeapon + damage: + types: + Blunt: 8 + soundHit: + collection: MetalThud + - type: Damageable + damageContainer: StructuralInorganic + damageModifierSet: Metallic + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 15 + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] + - !type:PlaySoundBehavior + sound: + collection: MetalBreak + - trigger: + !type:DamageTrigger + damage: 5 + behaviors: + - !type:PlaySoundBehavior + sound: + collection: MetalBreak + - !type:SpawnEntitiesBehavior + spawn: + SheetPlastic1: + min: 1 + max: 1 + - !type:DoActsBehavior + acts: [ "Destruction" ] + - type: StaticPrice + price: 20 + - type: Construction + graph: TableFoldingGraph + node: TableFolding + - type: DamageExaminable + - type: FoldableFixture + foldedFixtures: + - item + unfoldedFixtures: + - table + +- type: entity + parent: TableFolding + id: TableFoldingSpawnFolded + suffix: folded + components: + - type: Foldable + folded: true diff --git a/Resources/Prototypes/_NF/Recipes/Construction/Graphs/furniture/folding_table.yml b/Resources/Prototypes/_NF/Recipes/Construction/Graphs/furniture/folding_table.yml new file mode 100644 index 00000000000..942dc82df93 --- /dev/null +++ b/Resources/Prototypes/_NF/Recipes/Construction/Graphs/furniture/folding_table.yml @@ -0,0 +1,31 @@ +- type: constructionGraph + id: TableFoldingGraph + start: start + graph: + - node: start + actions: + - !type:DestroyEntity {} + edges: + + - to: TableFolding + steps: + - material: Plastic + amount: 4 + doAfter: 1 + - material: MetalRod + amount: 4 + + - node: TableFolding + entity: TableFolding + edges: + - to: start + completed: + - !type:SpawnPrototype + prototype: SheetPlastic1 + amount: 4 + - !type:SpawnPrototype + prototype: PartRodMetal1 + amount: 4 + steps: + - tool: Screwing + doAfter: 2 diff --git a/Resources/Prototypes/_NF/Recipes/Construction/furniture.yml b/Resources/Prototypes/_NF/Recipes/Construction/furniture.yml index bd4dc5bce53..d4df40dd662 100644 --- a/Resources/Prototypes/_NF/Recipes/Construction/furniture.yml +++ b/Resources/Prototypes/_NF/Recipes/Construction/furniture.yml @@ -1126,3 +1126,21 @@ canBuildInImpassable: false conditions: - !type:TileNotBlocked + +# Folding table +- type: construction + id: TableFolding + name: folding table + description: A table, but foldable. + graph: TableFoldingGraph + startNode: start + targetNode: TableFolding + category: construction-category-furniture + icon: + sprite: _NF/Structures/Furniture/folding_table.rsi + state: folding + objectType: Structure + placementMode: SnapgridCenter + canBuildInImpassable: false + conditions: + - !type:TileNotBlocked diff --git a/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding.png b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding.png new file mode 100644 index 00000000000..8e13ff9a81b Binary files /dev/null and b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding.png differ diff --git a/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding_folded.png b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding_folded.png new file mode 100644 index 00000000000..c1b3745a793 Binary files /dev/null and b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding_folded.png differ diff --git a/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-left.png b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-left.png new file mode 100644 index 00000000000..0549aafb46c Binary files /dev/null and b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-left.png differ diff --git a/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-right.png b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-right.png new file mode 100644 index 00000000000..4755db1c7a2 Binary files /dev/null and b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-right.png differ diff --git a/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/meta.json b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/meta.json new file mode 100644 index 00000000000..077a74633aa --- /dev/null +++ b/Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/meta.json @@ -0,0 +1,25 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from Beestation at commit https://github.com/BeeStation/BeeStation-Hornet/commit/9a035f9365bcb74ac40fbe79c74c43c4c80cc1e4", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "folding" + }, + { + "name": "folding_folded" + }, + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + } + ] +}