-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Port] BlinkSystem / Система Телепортации (#19)
add: betrayal dagger
- Loading branch information
Showing
10 changed files
with
188 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
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,65 @@ | ||
using System.Linq; | ||
using System.Numerics; | ||
using Content.Shared._White.Blink; | ||
using Content.Shared._White.Standing; | ||
using Content.Shared.Physics; | ||
using Robust.Server.Audio; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server._White.Blink; | ||
|
||
public sealed class BlinkSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
[Dependency] private readonly AudioSystem _audio = default!; | ||
[Dependency] private readonly TransformSystem _transform = default!; | ||
[Dependency] private readonly PhysicsSystem _physics = default!; | ||
[Dependency] private readonly SharedLayingDownSystem _layingDown = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeAllEvent<BlinkEvent>(OnBlink); | ||
} | ||
|
||
private void OnBlink(BlinkEvent msg, EntitySessionEventArgs args) | ||
{ | ||
if (args.SenderSession.AttachedEntity == null) | ||
return; | ||
|
||
var user = args.SenderSession.AttachedEntity.Value; | ||
|
||
if (!TryComp(user, out TransformComponent? xform)) | ||
return; | ||
|
||
if (!TryComp(GetEntity(msg.Weapon), out BlinkComponent? blink)) | ||
return; | ||
|
||
if (blink.NextBlink > _timing.CurTime) | ||
return; | ||
|
||
var blinkRate = TimeSpan.FromSeconds(1f / blink.BlinkRate); | ||
|
||
blink.NextBlink = _timing.CurTime + blinkRate; | ||
|
||
var coords = _transform.GetWorldPosition(xform); | ||
var dir = msg.Direction.Normalized(); | ||
var range = MathF.Min(blink.Distance, msg.Direction.Length()); | ||
|
||
var ray = new CollisionRay(coords, dir, (int) (CollisionGroup.Impassable | CollisionGroup.InteractImpassable)); | ||
var rayResults = _physics.IntersectRayWithPredicate(xform.MapID, ray, range, x => x == user, false).ToList(); | ||
|
||
Vector2 targetPos; | ||
if (rayResults.Count > 0) | ||
targetPos = rayResults.MinBy(x => (x.HitPos - coords).Length()).HitPos - dir; | ||
else | ||
targetPos = coords + (msg.Direction.Length() > blink.Distance ? dir * blink.Distance : msg.Direction); | ||
|
||
_transform.SetWorldPosition(user, targetPos); | ||
_layingDown.LieDownInRange(user, xform.Coordinates); | ||
_audio.PlayPvs(blink.BlinkSound, user); | ||
} | ||
} |
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 @@ | ||
using System.Numerics; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared._White.Blink; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class BlinkComponent : Component | ||
{ | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float Distance = 5f; | ||
|
||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float BlinkRate = 1f; | ||
|
||
public TimeSpan NextBlink; | ||
|
||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public SoundSpecifier BlinkSound = new SoundPathSpecifier("/Audio/Magic/blink.ogg") | ||
{ | ||
Params = AudioParams.Default.WithVolume(5f) | ||
}; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public sealed class BlinkEvent(NetEntity weapon, Vector2 direction) : EntityEventArgs | ||
{ | ||
public readonly NetEntity Weapon = weapon; | ||
public readonly Vector2 Direction = direction; | ||
} |
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
2 changes: 2 additions & 0 deletions
2
Resources/Locale/ru-RU/_white/prototypes/entities/objects/weapons/melee/daggers.ftl
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,2 @@ | ||
ent-BetrayalKnife = предательский кинжал | ||
.desc = Береги спину. |
32 changes: 32 additions & 0 deletions
32
Resources/Prototypes/_White/Entities/Objects/Weapons/Melee/daggers.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,32 @@ | ||
- type: entity | ||
name: betrayal dagger | ||
description: Watch your back. | ||
parent: BaseKnife | ||
id: BetrayalKnife | ||
components: | ||
- type: Sprite | ||
sprite: _White/Objects/Weapons/Melee/Daggers/betrayal_knife.rsi | ||
state: icon | ||
- type: Item | ||
size: Small | ||
- type: MeleeWeapon | ||
wideAnimationRotation: 180 | ||
attackRate: 1.5 | ||
damage: | ||
types: | ||
Slash: 17.5 | ||
soundHit: | ||
path: /Audio/Weapons/bladeslice.ogg | ||
- type: Sharp | ||
- type: EmbeddableProjectile | ||
sound: /Audio/Weapons/star_hit.ogg | ||
- type: ThrowingAngle | ||
angle: 180 | ||
- type: DamageOtherOnHit | ||
damage: | ||
types: | ||
Slash: 20 | ||
- type: DisarmMalus | ||
malus: 0.225 | ||
- type: Blink | ||
blinkRate: 0.33 |
Binary file added
BIN
+388 Bytes
...urces/Textures/_White/Objects/Weapons/Melee/Daggers/betrayal_knife.rsi/icon.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
+334 Bytes
...extures/_White/Objects/Weapons/Melee/Daggers/betrayal_knife.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
+339 Bytes
...xtures/_White/Objects/Weapons/Melee/Daggers/betrayal_knife.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.
22 changes: 22 additions & 0 deletions
22
Resources/Textures/_White/Objects/Weapons/Melee/Daggers/betrayal_knife.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,22 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/pull/49264/commits/d0dffe7ca643db2624424fdcebf45863f85c0448", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "icon" | ||
}, | ||
{ | ||
"name": "inhand-left", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "inhand-right", | ||
"directions": 4 | ||
} | ||
] | ||
} |