Skip to content
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

Добавить телепортер Синдиката #35

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Physics;

namespace Content.Server._CorvaxNext.Teleporter;

[RegisterComponent]
public sealed partial class SyndicateTeleporterComponent : Component
{
[DataField]
public float TeleportationRangeStart = 4;

[DataField]
public int TeleportationRangeLength = 4;

[DataField]
public CollisionGroup CollisionGroup = CollisionGroup.MobMask;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Content.Shared.Body.Systems;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.Interaction.Events;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Random.Helpers;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Server._CorvaxNext.Teleporter;

public sealed class SyndicateTeleporterSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly TurfSystem _turf = default!;
[Dependency] private readonly SharedBodySystem _body = default!;
[Dependency] private readonly IRobustRandom _random = default!;

private static readonly EntProtoId TeleportEffectPrototype = "TeleportEffect";

public override void Initialize()
{
SubscribeLocalEvent<SyndicateTeleporterComponent, UseInHandEvent>(OnUseInHand);
}

private void OnUseInHand(Entity<SyndicateTeleporterComponent> teleproter, ref UseInHandEvent e)
{
if (e.Handled)
return;

var transform = Transform(e.User);

var direction = transform.LocalRotation.ToWorldVec().Normalized();

List<EntityCoordinates> safeCoordinates = [];

for (var i = 0; i <= teleproter.Comp.TeleportationRangeLength; i++)
{
var offset = (teleproter.Comp.TeleportationRangeStart + i) * direction;

var coordinates = transform.Coordinates.Offset(offset).SnapToGrid(EntityManager, _map);

var tile = coordinates.GetTileRef(EntityManager, _map);

if (tile is not null && _turf.IsTileBlocked(tile.Value, teleproter.Comp.CollisionGroup))
continue;

safeCoordinates.Add(coordinates);
}

EntityCoordinates resultCoordinates;

if (safeCoordinates.Count < 1)
{
var offset = (teleproter.Comp.TeleportationRangeStart + _random.NextFloat(teleproter.Comp.TeleportationRangeLength)) * direction;

resultCoordinates = transform.Coordinates.Offset(offset);
}
else
resultCoordinates = _random.Pick(safeCoordinates);

Spawn(TeleportEffectPrototype, transform.Coordinates);
Spawn(TeleportEffectPrototype, resultCoordinates);

_transform.SetCoordinates(e.User, resultCoordinates);

if (safeCoordinates.Count < 1)
_body.GibBody(e.User, true);
}
}
4 changes: 4 additions & 0 deletions Resources/Audio/_CorvaxNext/Effects/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["electrical_short_circuit.ogg", "electrical_short_circuit2.ogg"]
license: "CC-BY-NC-3.0"
copyright: "Taken from zvukipro.com"
source: "https://zvukipro.com/predmet/158-zvuk-elektrichestva.html"
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,8 @@ uplink-combat-bakery-desc = A kit of clandestine baked weapons. Contains a bague

uplink-business-card-name = Syndicate Business Card
uplink-business-card-desc = A business card that you can give to someone to demonstrate your involvement in the syndicate or leave at the crime scene in order to make fun of the detective. You can buy no more than three of them.

# Corvax-Next-Teleporter-Start
uplink-syndicate-teleporter-name = Hand syndicate teleporter
uplink-syndicate-teleporter-desc = An experimental hand teleporting device. Teleports its owner forward in a small area. Be careful not to end up in the wall.
# Corvax-Next-Teleporter-End
4 changes: 4 additions & 0 deletions Resources/Locale/ru-RU/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,7 @@ uplink-combat-bakery-name = Набор боевой выпечки
uplink-combat-bakery-desc = Набор подпольного печёного оружия. Содержит меч-багет, пару метательных круассанов и микроволновую плату Синдиката для изготовления новых. Когда дело будет сделано, съешьте все улики.
uplink-business-card-name = Визитная карточка Синдиката
uplink-business-card-desc = Визитная карточка, которую можно передать кому-нибудь, чтобы продемонстрировать свою принадлежность к Синдикату, или оставить на месте преступления, чтобы подшутить над детективом. Вы можете приобрести не более трёх таких визиток.
# Corvax-Next-Teleporter-Start
uplink-syndicate-teleporter-name = Ручной телепортер Синдиката
uplink-syndicate-teleporter-desc = Экспериментальное ручное телепортирующее устройство. Телепортирует владельца вперёд на некоторое расстояние. Будьте осторожны не умереть в стене.
# Corvax-Next-Teleporter-End
10 changes: 10 additions & 0 deletions Resources/Prototypes/_CorvaxNext/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- type: listing
id: UplinkTeleporter
name: uplink-syndicate-teleporter-name
description: uplink-syndicate-teleporter-desc
icon: { sprite: _CorvaxNext/Objects/Devices/syndicate_teleporter.rsi, state: icon }
productEntity: SyndicateTeleporter
cost:
Telecrystal: 12
categories:
- UplinkDisruption
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- type: entity
id: TeleportEffect
categories: [ HideSpawnMenu ]
components:
- type: TimedDespawn
lifetime: 0.4
- type: Sprite
drawdepth: Effects
noRot: true
layers:
- shader: unshaded
map: ["enum.EffectLayers.Unshaded"]
sprite: _CorvaxNext/Effects/teleport_sparks.rsi
state: sparks
- type: EffectVisuals
- type: Tag
tags:
- HideContextMenu
- type: EmitSoundOnSpawn
sound:
collection: ShortCircuit
- type: AnimationPlayer
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- type: entity
parent: BaseItem
id: SyndicateTeleporter
name: syndicate teleporter
description: Personal syndicate teleporter.
components:
- type: Sprite
sprite: _CorvaxNext/Objects/Devices/syndicate_teleporter.rsi
state: icon
- type: Item
- type: SyndicateTeleporter
- type: UseDelay
delay: 60
- type: EmitSoundOnUse
sound:
collection: BrokenDevice
params:
variation: 0.125
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- type: soundCollection
id: BrokenDevice
files:
- /Audio/_CorvaxNext/Effects/electrical_short_circuit.ogg

- type: soundCollection
id: ShortCircuit
files:
- /Audio/_CorvaxNext/Effects/electrical_short_circuit2.ogg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "created by pofitlo",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "sparks",
"delays": [
[
0.1,
0.1,
0.1,
0.1
]
]
}
]
}
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "created by pofitlo",

"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
}
]
}
Loading