-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3c6153
commit c89850e
Showing
17 changed files
with
184 additions
and
2 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,40 @@ | ||
using Content.Shared.Actions; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
|
||
|
||
namespace Content.Shared.Movement.Components; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class JumpComponent : Component | ||
{ | ||
/// <summary> | ||
/// How powerful the jump will be when activated | ||
/// </summary> | ||
[DataField("jumpPower"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] | ||
public float JumpPower = 5f; | ||
|
||
|
||
// Logical variables | ||
[DataField] | ||
public EntProtoId Action = "ActionGravityJump"; | ||
|
||
[DataField] | ||
public EntityUid? ActionEntity; | ||
|
||
[DataField] | ||
public bool? IsClothing; | ||
|
||
[DataField, AutoNetworkedField] | ||
public EntityUid OnClothingEntity; | ||
|
||
|
||
// Sound | ||
[DataField("soundJump"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] | ||
public SoundSpecifier SoundJump = new SoundPathSpecifier("/Audio/Effects/gravity_jump.ogg"); | ||
} | ||
|
||
|
||
public sealed partial class GravityJumpEvent : InstantActionEvent; | ||
|
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,51 @@ | ||
using Content.Shared.Actions; | ||
using Content.Shared.Clothing; | ||
using Content.Shared.Throwing; | ||
using Content.Shared.Movement.Components; | ||
using Robust.Shared.Audio.Systems; | ||
|
||
|
||
namespace Content.Shared.Movement.Systems; | ||
|
||
public sealed partial class SharedJumpSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ThrowingSystem _throwing = default!; | ||
[Dependency] private readonly SharedTransformSystem _xform = default!; | ||
[Dependency] private readonly SharedActionsSystem _actions = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<JumpComponent, ClothingGotEquippedEvent>(OnEquip); | ||
SubscribeLocalEvent<JumpComponent, GravityJumpEvent>(JumpAbility); | ||
} | ||
|
||
|
||
public void OnEquip(Entity<JumpComponent> ent, ref ClothingGotEquippedEvent args) | ||
{ | ||
_actions.AddAction(args.Wearer, ref ent.Comp.ActionEntity, ent.Comp.Action, ent); | ||
|
||
ent.Comp.IsClothing = true; | ||
ent.Comp.OnClothingEntity = args.Wearer; | ||
} | ||
|
||
|
||
public void JumpAbility(Entity<JumpComponent> entity, ref GravityJumpEvent args) | ||
{ | ||
if (entity.Comp.IsClothing != null) // checking for wearing clothing with a jump component | ||
{ | ||
entity.Owner = entity.Comp.OnClothingEntity; | ||
} | ||
|
||
var xform = Transform(entity.Owner); | ||
var throwing = xform.LocalRotation.ToWorldVec() * entity.Comp.JumpPower; | ||
var direction = xform.Coordinates.Offset(throwing); // to make the character jump in the direction he's looking | ||
|
||
_throwing.TryThrow(entity.Owner, direction); | ||
|
||
_audio.PlayPredicted(entity.Comp.SoundJump, entity.Owner, entity); | ||
|
||
args.Handled = true; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/blob/master/icons/obj/clothing/shoes.dmi", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "icon" | ||
}, | ||
{ | ||
"name": "equipped-FEET", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "equipped-FEET-vox", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "inhand-left", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "inhand-right", | ||
"directions": 4 | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/blob/master/icons/hud/implants.dmi", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "icon" | ||
} | ||
] | ||
} |