-
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] Experimental Teleporter / Экспериментальный Телепортатор (#63)
* add: experimentel teleport * fix
- Loading branch information
Showing
16 changed files
with
343 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Content.Server/_White/Teleporter/ExperimentalTeleporterComponent.cs
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,28 @@ | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Server._White.Teleporter; | ||
|
||
[RegisterComponent] | ||
public sealed partial class ExperimentalTeleporterComponent : Component | ||
{ | ||
[DataField] | ||
public int MinTeleportRange = 3; | ||
|
||
[DataField] | ||
public int MaxTeleportRange = 8; | ||
|
||
[DataField] | ||
public int EmergencyLength = 4; | ||
|
||
[DataField] | ||
public List<int> RandomRotations = new() {90, -90}; | ||
|
||
[DataField] | ||
public string? TeleportInEffect = "ExperimentalTeleporterInEffect"; | ||
|
||
[DataField] | ||
public string? TeleportOutEffect = "ExperimentalTeleporterOutEffect"; | ||
|
||
[DataField] | ||
public SoundSpecifier TeleportSound = new SoundPathSpecifier("/Audio/_White/Object/Devices/experimentalsyndicateteleport.ogg"); | ||
} |
114 changes: 114 additions & 0 deletions
114
Content.Server/_White/Teleporter/ExperimentalTeleporterSystem.cs
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,114 @@ | ||
using System.Linq; | ||
using System.Numerics; | ||
using Content.Server.Body.Systems; | ||
using Content.Server.Standing; | ||
using Content.Shared.Charges.Systems; | ||
using Content.Shared.Coordinates.Helpers; | ||
using Content.Shared.Interaction.Events; | ||
using Content.Shared.Maps; | ||
using Content.Shared.Tag; | ||
using Robust.Server.Audio; | ||
using Robust.Server.Containers; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server._White.Teleporter; | ||
|
||
public sealed class ExperimentalTeleporterSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly TransformSystem _transform = default!; | ||
[Dependency] private readonly BodySystem _bodySystem = default!; | ||
[Dependency] private readonly MapSystem _mapSystem = default!; | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly AudioSystem _audio = default!; | ||
[Dependency] private readonly ContainerSystem _containerSystem = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly LayingDownSystem _layingDown = default!; | ||
[Dependency] private readonly SharedChargesSystem _charges = default!; | ||
[Dependency] private readonly TagSystem _tag = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ExperimentalTeleporterComponent, UseInHandEvent>(OnUse); | ||
} | ||
|
||
private void OnUse(EntityUid uid, ExperimentalTeleporterComponent component, UseInHandEvent args) | ||
{ | ||
if (_charges.IsEmpty(uid) | ||
|| !TryComp<TransformComponent>(args.User, out var xform) | ||
|| (_containerSystem.IsEntityInContainer(args.User) | ||
&& !_containerSystem.TryRemoveFromContainer(args.User))) | ||
return; | ||
|
||
var oldCoords = xform.Coordinates; | ||
var range = _random.Next(component.MinTeleportRange, component.MaxTeleportRange); | ||
var offset = xform.LocalRotation.ToWorldVec().Normalized(); | ||
var direction = xform.LocalRotation.GetDir().ToVec(); | ||
var newOffset = offset + direction * range; | ||
|
||
var coords = xform.Coordinates.Offset(newOffset).SnapToGrid(EntityManager); | ||
|
||
Teleport(args.User, uid, component, coords, oldCoords); | ||
|
||
if (!TryCheckWall(coords) | ||
|| EmergencyTeleportation(args.User, uid, component, xform, oldCoords, newOffset)) | ||
return; | ||
|
||
_bodySystem.GibBody(args.User, true, splatModifier: 3F); | ||
} | ||
|
||
private bool EmergencyTeleportation(EntityUid uid, EntityUid teleporterUid, ExperimentalTeleporterComponent component, TransformComponent xform, EntityCoordinates oldCoords, Vector2 offset) | ||
{ | ||
var newOffset = offset + VectorRandomDirection(component, offset, component.EmergencyLength); | ||
var coords = xform.Coordinates.Offset(newOffset).SnapToGrid(EntityManager); | ||
|
||
if (_charges.IsEmpty(teleporterUid)) | ||
return false; | ||
|
||
Teleport(uid, teleporterUid, component, coords, oldCoords); | ||
|
||
return !TryCheckWall(coords); | ||
} | ||
|
||
private void Teleport(EntityUid uid, EntityUid teleporterUid, ExperimentalTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords) | ||
{ | ||
PlaySoundAndEffects(component, coords, oldCoords); | ||
|
||
_layingDown.LieDownInRange(uid, coords); | ||
_transform.SetCoordinates(uid, coords); | ||
|
||
_charges.UseCharge(teleporterUid); | ||
} | ||
|
||
private void PlaySoundAndEffects(ExperimentalTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords) | ||
{ | ||
_audio.PlayPvs(component.TeleportSound, coords); | ||
_audio.PlayPvs(component.TeleportSound, oldCoords); | ||
|
||
_entManager.SpawnEntity(component.TeleportInEffect, coords); | ||
_entManager.SpawnEntity(component.TeleportOutEffect, oldCoords); | ||
} | ||
|
||
private bool TryCheckWall(EntityCoordinates coords) | ||
{ | ||
if (!coords.TryGetTileRef(out var tile) | ||
|| !TryComp<MapGridComponent>(tile.Value.GridUid, out var mapGridComponent)) | ||
return false; | ||
|
||
var anchoredEntities = _mapSystem.GetAnchoredEntities(tile.Value.GridUid, mapGridComponent, coords); | ||
|
||
return anchoredEntities.Any(x => _tag.HasTag(x, "Wall")); | ||
} | ||
|
||
private Vector2 VectorRandomDirection(ExperimentalTeleporterComponent component, Vector2 offset, int length) | ||
{ | ||
if (component.RandomRotations.Count == 0) | ||
return Vector2.Zero; | ||
|
||
var randomRotation = _random.Next(0, component.RandomRotations.Count); | ||
return Angle.FromDegrees(component.RandomRotations[randomRotation]).RotateVec(offset.Normalized() * length); | ||
} | ||
} |
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,4 @@ | ||
- files: ["experimentalsyndicateteleport.ogg"] | ||
license: "CC-BY-NC-SA-4.0" | ||
copyright: "Taken from White Dream" | ||
source: "https://github.com/frosty-dev/ss14-core/blob/master/Resources/Audio/White/Devices/expsyndicateteleport.ogg" |
Binary file added
BIN
+11.5 KB
Resources/Audio/_White/Object/Devices/experimentalsyndicateteleport.ogg
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
2 changes: 2 additions & 0 deletions
2
...U/_white/prototypes/entities/objects/device/syndicate_gadgets/experimental-teleporter.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-ExperimentalSyndicateTeleporter = экспериментальный телепортер синдиката | ||
.desc = Телепортер синдиката, при использовании перемещает на 3-8 метров вперед. В случае телепортации в стену, использует экстренную телепортацию. Имеет 4 заряда и автоматически заряжается. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
- type: entity | ||
id: ExperimentalTeleporterInEffect | ||
name: experimental syndicate teleporter in effect | ||
components: | ||
- type: TimedDespawn | ||
lifetime: 0.6 | ||
- type: EvaporationSparkle | ||
- type: Transform | ||
noRot: true | ||
anchored: true | ||
- type: Sprite | ||
layers: | ||
- sprite: /Textures/_White/Objects/Devices/experimentalsyndicateteleporter.rsi | ||
state: in | ||
shader: unshaded | ||
netsync: false | ||
drawdepth: Effects | ||
- type: PointLight | ||
color: "#008DFE" | ||
|
||
- type: entity | ||
id: ExperimentalTeleporterOutEffect | ||
name: experimental syndicate teleporter out effect | ||
components: | ||
- type: TimedDespawn | ||
lifetime: 0.6 | ||
- type: EvaporationSparkle | ||
- type: Transform | ||
noRot: true | ||
anchored: true | ||
- type: Sprite | ||
layers: | ||
- sprite: /Textures/_White/Objects/Devices/experimentalsyndicateteleporter.rsi | ||
state: out | ||
shader: unshaded | ||
netsync: false | ||
drawdepth: Effects | ||
- type: PointLight | ||
color: "#008DFE" |
16 changes: 16 additions & 0 deletions
16
.../Prototypes/_White/Entities/Objects/Devices/Syndicate_Gadgets/experimental_teleporter.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,16 @@ | ||
- type: entity | ||
id: ExperimentalSyndicateTeleporter | ||
parent: BaseItem | ||
name: experimental syndicate teleporter | ||
description: Syndicate teleporter, when used, moves 3-8 meters forward. In case of teleportation into a wall, uses emergency teleportation. Has 4 charge. | ||
components: | ||
- type: Sprite | ||
sprite: /Textures/_White/Objects/Devices/experimentalsyndicateteleporter.rsi | ||
layers: | ||
- state: icon | ||
- type: ExperimentalTeleporter | ||
- type: LimitedCharges | ||
maxCharges: 4 | ||
charges: 4 | ||
- type: AutoRecharge | ||
rechargeDuration: 10 |
Binary file added
BIN
+409 Bytes
...es/Textures/_White/Objects/Devices/experimentalsyndicateteleporter.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
+5.35 KB
...rces/Textures/_White/Objects/Devices/experimentalsyndicateteleporter.rsi/in.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
+248 Bytes
...ures/_White/Objects/Devices/experimentalsyndicateteleporter.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
+247 Bytes
...res/_White/Objects/Devices/experimentalsyndicateteleporter.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.
122 changes: 122 additions & 0 deletions
122
Resources/Textures/_White/Objects/Devices/experimentalsyndicateteleporter.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,122 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Taken from tgstation, remade by CaypenNow", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "icon", | ||
"delays": [ | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
] | ||
] | ||
}, | ||
{ | ||
"name": "inhand-left", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "inhand-right", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "in", | ||
"directions": 4, | ||
"delays": [ | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
], | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
], | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
], | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
] | ||
] | ||
}, | ||
{ | ||
"name": "out", | ||
"directions": 4, | ||
"delays": [ | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
], | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
], | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
], | ||
[ | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1, | ||
0.1 | ||
] | ||
] | ||
} | ||
] | ||
} |
Binary file added
BIN
+4.27 KB
...ces/Textures/_White/Objects/Devices/experimentalsyndicateteleporter.rsi/out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.