-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
teleporter-WWDP #969
teleporter-WWDP #969
Changes from 2 commits
19fada8
6e8b8fc
72fd83f
432364e
7bbac7c
568d764
0c60100
e522499
4741148
aee31f5
52416da
862f596
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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/Backman/Object/Devices/experimentalsyndicateteleport.ogg"); | ||
} |
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.Backmen.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); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Добавьте дополнительные проверки безопасности
Предлагаю следующие изменения: private void OnUse(EntityUid uid, ExperimentalTeleporterComponent component, UseInHandEvent args)
{
+ if (!Resolve(args.User, ref xform))
+ return;
+
if (_charges.IsEmpty(uid)
- || !TryComp<TransformComponent>(args.User, out var xform)
|| (_containerSystem.IsEntityInContainer(args.User)
&& !_containerSystem.TryRemoveFromContainer(args.User)))
return;
+ const float GibSplatModifier = 3f;
// ... rest of the method ...
- _bodySystem.GibBody(args.User, true, splatModifier: 3F);
+ _bodySystem.GibBody(args.User, true, splatModifier: GibSplatModifier);
}
|
||
|
||
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); | ||
} | ||
Comment on lines
+66
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Предотвратите возможность бесконечной рекурсии Метод
Предлагаемые изменения: + private const int MaxEmergencyAttempts = 3;
- private bool EmergencyTeleportation(EntityUid uid, EntityUid teleporterUid, ExperimentalTeleporterComponent component, TransformComponent xform, EntityCoordinates oldCoords, Vector2 offset)
+ private bool EmergencyTeleportation(EntityUid uid, EntityUid teleporterUid, ExperimentalTeleporterComponent component, TransformComponent xform, EntityCoordinates oldCoords, Vector2 offset, int attempts = 0)
{
+ if (attempts >= MaxEmergencyAttempts)
+ return false;
+
var newOffset = offset + VectorRandomDirection(component, offset, component.EmergencyLength);
// ... rest of the method
}
|
||
|
||
private void Teleport(EntityUid uid, EntityUid teleporterUid, ExperimentalTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords) | ||
{ | ||
PlaySoundAndEffects(component, coords, oldCoords); | ||
|
||
_layingDown.LieDownInRange(uid, coords); | ||
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / Test Packaging
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / Test Packaging
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / YAML Linter
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / YAML Linter
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 80 in Content.Server/Backmen/Teleporter/ExperimentalTeleporterSystem.cs GitHub Actions / build (ubuntu-latest)
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправьте ошибку: метод 'LieDownInRange' отсутствует в 'LayingDownSystem' Статический анализ выявил, что метод 🧰 Tools🪛 GitHub Check: YAML Linter[failure] 80-80: [failure] 80-80: 🪛 GitHub Check: build (ubuntu-latest)[failure] 80-80: [failure] 80-80: 🪛 GitHub Check: Test Packaging[failure] 80-80: [failure] 80-80: |
||
_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); | ||
} | ||
} |
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" | ||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Источник звукового файла недоступен! Ссылка на исходный файл возвращает ошибку 404, что указывает на его отсутствие в указанном репозитории. Необходимо:
🔗 Analysis chainПроверить доступность источника звукового файла! Атрибуция корректно указана, но необходимо убедиться в актуальности ссылки на исходный файл и соответствии условиям лицензии CC-BY-NC-SA-4.0. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify source file availability and license compliance
# Check if source URL is accessible
curl -I "https://github.com/frosty-dev/ss14-core/blob/master/Resources/Audio/White/Devices/expsyndicateteleport.ogg"
# Verify local file exists
fd "experimentalsyndicateteleport.ogg" Resources/Audio/Backmen/Object/Devices/
Length of output: 5069 🧰 Tools🪛 yamllint (1.35.1)[error] 4-4: no new line character at the end of file (new-line-at-end-of-file) |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||||||
uplink-emp-flashlight-name = Emp Flashlight | ||||||||||
uplink-emp-flashlight-desc = A rechargeable device disguised as a flashlight designed to disrupt electronic systems. Useful for disrupting communications, security's energy weapons, and APCs when you're in a tight spot. | ||||||||||
|
||||||||||
uplink-betrayal-knife-name = Betrayal dagger | ||||||||||
uplink-betrayal-knife-desc = The betrayal dagger allows the user to teleport a short distance, and also causes significant damage when stabbed in the back. | ||||||||||
|
||||||||||
uplink-betrayal-knife-name = Experimental syndicate teleporter | ||||||||||
uplink-betrayal-knife-desc = Syndicate teleporter, when used, moves 3-8 meters forward. In case of teleportation into a wall, uses emergency teleportation. Has 4 charge. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправьте дублирующиеся ключи для локализации Ключи Предлагаю изменить ключи на уникальные для экспериментального телепортера: - uplink-betrayal-knife-name = Experimental syndicate teleporter
- uplink-betrayal-knife-desc = Syndicate teleporter, when used, moves 3-8 meters forward. In case of teleportation into a wall, uses emergency teleportation. Has 4 charge.
+ uplink-experimental-syndicate-teleporter-name = Experimental syndicate teleporter
+ uplink-experimental-syndicate-teleporter-desc = Syndicate teleporter, when used, moves 3-8 meters forward. In case of teleportation into a wall, uses emergency teleportation. Has 4 charges. 📝 Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
uplink-ebow-name = Small energy crossbow | ||||||||||
uplink-ebow-desc = A fairly quiet weapon that automatically reloads and stuns. It goes well with other types of weapons. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ent-ExperimentalSyndicateTeleporter = экспериментальный телепортер синдиката | ||
.desc = Телепортер синдиката, при использовании перемещает на 3-8 метров вперед. В случае телепортации в стену, использует экстренную телепортацию. Имеет 4 заряда и автоматически заряжается. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
uplink-experimental-syndicate-teleporter-name = Экспериментальный телепортер синдиката | ||
uplink-experimental-syndicate-teleporter-desc = Телепортер синдиката, при использовании перемещает на 3-8 метров вперед. В случае телепортации в стену, использует экстренную телепортацию. Имеет 4 заряда и автоматически заряжается. | ||
|
||
uplink-ebow-name = Маленький энергетический арбалет | ||
uplink-ebow-desc = Довольно тихое оружие, которое автоматически перезаряжается и оглушает. Хорошо сочетается с другими видами оружия. |
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/Backmen/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/Backmen/Objects/Devices/experimentalsyndicateteleporter.rsi | ||
state: out | ||
shader: unshaded | ||
netsync: false | ||
drawdepth: Effects | ||
- type: PointLight | ||
color: "#008DFE" |
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/Backmen/Objects/Devices/experimentalsyndicateteleporter.rsi | ||
layers: | ||
- state: icon | ||
- type: ExperimentalTeleporter | ||
- type: LimitedCharges | ||
maxCharges: 4 | ||
charges: 4 | ||
- type: AutoRecharge | ||
rechargeDuration: 10 |
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 | ||
] | ||
] | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ошибка: не найден тип или пространство имён 'LayingDownSystem'
На строке 28 используется тип
LayingDownSystem
, но компилятор не может его найти. Вероятно, отсутствует соответствующая директиваusing
или ссылка на сборку.Предлагаю добавить следующую директиву:
+ using Content.Server.Movement.Systems;
📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: build (ubuntu-latest)
[failure] 28-28:
The type or namespace name 'LayingDownSystem' could not be found (are you missing a using directive or an assembly reference?)
[failure] 28-28:
The type or namespace name 'LayingDownSystem' could not be found (are you missing a using directive or an assembly reference?)
🪛 GitHub Check: YAML Linter
[failure] 28-28:
The type or namespace name 'LayingDownSystem' could not be found (are you missing a using directive or an assembly reference?)
[failure] 28-28:
The type or namespace name 'LayingDownSystem' could not be found (are you missing a using directive or an assembly reference?)
🪛 GitHub Check: Test Packaging
[failure] 28-28:
The type or namespace name 'LayingDownSystem' could not be found (are you missing a using directive or an assembly reference?)
[failure] 28-28:
The type or namespace name 'LayingDownSystem' could not be found (are you missing a using directive or an assembly reference?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Content.Server.Backmen.Standing; ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PvrG, да, вы правы. Если
LayingDownSystem
находится в пространстве имёнContent.Server.Backmen.Standing
, то добавлениеusing Content.Server.Backmen.Standing;
должно решить проблему. Спасибо за уточнение!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PvrG: Да, вы правы. Необходимо добавить директиву:
Это подключит пространство имён, в котором определён
LayingDownSystem
, и устранит ошибку компиляции.🔗 Analysis chain
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2072