-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Folding Table * non climable * don't tread on me (folding table) * Add foldable fixture system * Unfolded/folded fixtures * Make item fixture soft by default for folding tbl * Remove comments, unneeded folded component --------- Co-authored-by: Whatstone <[email protected]>
- Loading branch information
1 parent
ba7e2d1
commit 5e1fe8a
Showing
10 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Content.Shared._NF.Foldable.Systems; | ||
|
||
[RegisterComponent] | ||
public sealed partial class FoldableFixtureComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public List<string> FoldedFixtures; | ||
[DataField(required: true)] | ||
public List<string> UnfoldedFixtures; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<FoldableFixtureComponent, MapInitEvent>(OnMapInit); | ||
SubscribeLocalEvent<FoldableFixtureComponent, FoldedEvent>(OnFolded); | ||
} | ||
|
||
private void OnMapInit(EntityUid uid, FoldableFixtureComponent component, MapInitEvent args) | ||
{ | ||
if (TryComp<FoldableComponent>(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<string> fixtures, bool hard) | ||
{ | ||
foreach (var fixName in fixtures) | ||
{ | ||
var fixture = _fixtures.GetFixtureOrNull(uid, fixName); | ||
if (fixture != null) | ||
_physics.SetHard(uid, fixture, hard); | ||
} | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
Resources/Prototypes/_NF/Entities/Structures/Furniture/tables.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
31 changes: 31 additions & 0 deletions
31
Resources/Prototypes/_NF/Recipes/Construction/Graphs/furniture/folding_table.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+553 Bytes
Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+459 Bytes
Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/folding_folded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+760 Bytes
Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+746 Bytes
Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/inhand-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
Resources/Textures/_NF/Structures/Furniture/folding_table.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
] | ||
} |