forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Showing
2 changed files
with
73 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,17 @@ | ||
using Content.Shared.Alert; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
||
namespace Content.Server.Abilities.Resomi | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class ResomiSkillComponent : Component | ||
{ | ||
[DataField("actionJumpId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
public string ActionJumpId = "Jump"; | ||
|
||
[DataField] | ||
public float MaxThrow = 10f; | ||
} | ||
} |
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.Server.Actions; | ||
using Content.Shared.Abilities.Resomi; | ||
using Content.Shared.Throwing; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Map; | ||
|
||
namespace Content.Server.Abilities.Resomi; | ||
|
||
public sealed class ResomiSkillSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ActionsSystem _action = default!; | ||
[Dependency] private readonly ThrowingSystem _throwing = default!; | ||
[Dependency] private readonly SharedTransformSystem _transform = default!; | ||
[Dependency] private readonly IMapManager _mapMan = default!; | ||
[Dependency] private readonly SharedMapSystem _mapSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ResomiSkillComponent, ComponentStartup>(OnStartup); | ||
SubscribeLocalEvent<ResomiSkillComponent, ResomiJumpActionEvent>(OnResomiJump); | ||
} | ||
|
||
private void OnStartup(EntityUid uid, ResomiSkillComponent component, ComponentStartup args) => _action.AddAction(uid, component.ActionJumpId); | ||
|
||
private void OnResomiJump(EntityUid uid, ResomiSkillComponent component, ResomiJumpActionEvent args) | ||
{ | ||
//idea taked from VigersRay | ||
|
||
if (args.Handled) | ||
return; | ||
|
||
var userTransform = Transform(uid); | ||
|
||
if (!_mapMan.TryFindGridAt(vampirePosition, out _, out var grid)) | ||
return; | ||
|
||
if (!_mapSystem.TryGetTileRef(uid, grid, userTransform.Coordinates, out var tileRef)) | ||
return; | ||
|
||
if (tileRef.Tile.IsEmpty || tileRef.IsSpace() || tileRef.Tile.GetContentTileDefinition().ID == "Lattice") | ||
return; | ||
|
||
args.Handled = true; | ||
|
||
var targetPlace = args.Target.ToMap(EntityManager, _transform); | ||
|
||
var targetDirection = targetPlace.Position - userTransform.MapPosition.Position; | ||
|
||
if (targetDirection.Length() > component.MaxThrow) | ||
targetDirection = targetDirection.Normalized() * component.MaxThrow; | ||
|
||
_throwing.TryThrow(uid, targetDirection, 7F, uid, 10F); | ||
} | ||
} |