-
Notifications
You must be signed in to change notification settings - Fork 45
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
base: master
Are you sure you want to change the base?
Changes from 11 commits
8b7c516
06aa5df
d79015f
59489ee
f09c914
41bdb34
8a3812a
0b33cfd
41b3e84
40950f3
c47fb5f
3e9c1c1
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,11 @@ | ||
namespace Content.Server._CorvaxNext.Teleporter; | ||
|
||
[RegisterComponent] | ||
public sealed partial class SyndicateTeleporterComponent : Component | ||
{ | ||
[DataField] | ||
public float TeleportationRangeStart = 4; | ||
|
||
[DataField] | ||
public int TeleportationRangeLength = 4; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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!; | ||
|
||
[ValidatePrototypeId<EntityPrototype>] | ||
private const string TeleportEffectPrototype = "TeleportEffect"; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<SyndicateTeleporterComponent, UseInHandEvent>(OnUseInHand); | ||
} | ||
|
||
private void OnUseInHand(EntityUid entity, SyndicateTeleporterComponent teleproter, UseInHandEvent e) | ||
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. Лучше используй новую перегрузку |
||
{ | ||
if (e.Handled) | ||
return; | ||
|
||
var transform = Transform(e.User); | ||
|
||
var direction = transform.LocalRotation.ToWorldVec().Normalized(); | ||
|
||
List<EntityCoordinates> safeCoordinates = []; | ||
|
||
for (var i = 0; i <= teleproter.TeleportationRangeLength; i++) | ||
{ | ||
var offset = (teleproter.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, CollisionGroup.MobMask)) | ||
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. Колижен группу лучше вынести в компонент 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. И да, ты гибнешся при попытке тепа в космос, если тайла нет, то просто добавляй в сейфы 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. tile is null - true => tile is not null - false => if не срабатывает => continue не срабатывает => добавляется в safeCoordinates |
||
continue; | ||
|
||
safeCoordinates.Add(coordinates); | ||
} | ||
|
||
EntityCoordinates resultCoordinates; | ||
|
||
if (safeCoordinates.Count < 1) | ||
{ | ||
var offset = (teleproter.TeleportationRangeStart + _random.NextFloat(teleproter.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); | ||
} | ||
} |
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" |
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. Для листинга в папке корвакс некст сделай файл по такому же пути |
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 | ||
] | ||
] | ||
} | ||
] | ||
} |
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" | ||
} | ||
] | ||
} |
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.
Поменяй тип на
EntProtoId
и убери атрибут валидации, это работает именно так