-
Notifications
You must be signed in to change notification settings - Fork 17
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
Reflectors #76
Merged
Merged
Reflectors #76
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a8717b4
Перенос работы
NikitosAseev 233f5cd
Замена projectileReflectorList на whitelist / blacklist
NikitosAseev 20ccb5e
upstream
NikitosAseev be1ba4a
Рефактор
NikitosAseev f5e5e32
Merge remote-tracking branch 'upstream' into Reflectors
NikitosAseev 309b348
Update electronics.yml
NikitosAseev 14c0c66
Update meta.json
NikitosAseev 8cc2ac9
fix1
NikitosAseev 83ed117
Fix?
NikitosAseev ee621a1
...
NikitosAseev bb9fbbf
RobustToolbox fix?
NikitosAseev d342aa7
Update industrial.yml
NikitosAseev ea3eaa4
fix??
NikitosAseev c4f7fb0
Добавил в dynamicRecipes , сделал отдельное изучение для рефлекторов
NikitosAseev fe9aa83
update production , industrial
NikitosAseev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System.Numerics; | ||
using Content.Server.Weapons.Ranged.Systems; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Projectiles; | ||
using Direction = Robust.Shared.Maths.Direction; | ||
using Content.Shared.Stories.Reflectors; | ||
using Content.Shared.Whitelist; | ||
using Content.Shared.Weapons.Ranged.Components; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Network; | ||
|
||
namespace Content.Server.Stories.Reflectors; | ||
public sealed class ReflectorSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; | ||
[Dependency] private readonly SharedTransformSystem _transform = default!; | ||
[Dependency] private readonly INetManager _netManager = default!; | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
[Dependency] private readonly GunSystem _gun = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ReflectorComponent, ProjectileReflectAttemptEvent>(OnReflectCollide); | ||
} | ||
|
||
private void OnReflectCollide(EntityUid uid, ReflectorComponent component, ref ProjectileReflectAttemptEvent args) | ||
{ | ||
if (args.Cancelled) | ||
return; | ||
|
||
var collisionDirection = CalculateCollisionDirection(uid, args.ProjUid); | ||
if (component.BlockedDirections.Contains(collisionDirection.ToString())) | ||
return; | ||
|
||
if (TryReflectProjectile(uid, component, args.ProjUid , collisionDirection)) | ||
args.Cancelled = true; | ||
} | ||
private Direction CalculateCollisionDirection(EntityUid uid, EntityUid projectile) | ||
{ | ||
var projWorldPos = _transform.GetWorldPosition(projectile); | ||
var uidWorldMatrix = _transform.GetInvWorldMatrix(Transform(uid)); | ||
var localCollisionPoint = Vector2.Transform(projWorldPos, uidWorldMatrix); | ||
|
||
return localCollisionPoint.ToAngle().GetCardinalDir(); | ||
|
||
} | ||
|
||
private bool TryReflectProjectile(EntityUid user, ReflectorComponent component , EntityUid projectile, Direction collisionDirection) | ||
{ | ||
if (!TryComp<ReflectiveComponent>(projectile, out var reflective) || | ||
reflective.Reflective == 0x0 || | ||
!TryComp<GunComponent>(user, out var gunComponent) || | ||
_whitelistSystem.IsBlacklistPass(component.Blacklist, projectile) || | ||
_whitelistSystem.IsWhitelistFail(component.Whitelist, projectile)) | ||
{ | ||
return false; | ||
} | ||
|
||
var targetOffset = ReflectBasedOnType(component, collisionDirection); | ||
if (!targetOffset.HasValue) | ||
return false; | ||
|
||
var xform = Transform(user); | ||
var targetPos = new EntityCoordinates(user, targetOffset.Value); | ||
|
||
_transform.SetLocalPosition(projectile, xform.LocalPosition + xform.LocalRotation.RotateVec(targetOffset.Value)); | ||
|
||
_gun.Shoot(user, gunComponent, projectile, xform.Coordinates, targetPos, out _); | ||
|
||
if (_netManager.IsServer) | ||
_popup.PopupEntity(Loc.GetString("reflect-shot"), user); | ||
|
||
return true; | ||
} | ||
|
||
private Vector2 ReflectAngular(Direction collisionDirection) | ||
{ | ||
return collisionDirection switch | ||
{ | ||
Direction.North => Vector2.UnitY, | ||
Direction.South => -Vector2.UnitY, | ||
Direction.East => -Vector2.UnitX, | ||
Direction.West => Vector2.UnitX, | ||
_ => throw new ArgumentOutOfRangeException(nameof(collisionDirection)), | ||
}; | ||
} | ||
private Vector2? ReflectBasedOnType(ReflectorComponent component, Direction collisionDirection) | ||
{ | ||
return component.State switch | ||
{ | ||
ReflectorType.Simple => component.ReflectionDirection?.ToVec(), | ||
ReflectorType.Angular => ReflectAngular(collisionDirection), | ||
_ => throw new ArgumentOutOfRangeException(nameof(component.State), component.State, "Invalid ReflectorType encountered."), | ||
}; | ||
} | ||
} |
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 Content.Shared.Whitelist; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.Stories.Reflectors; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] | ||
public sealed partial class ReflectorComponent : Component | ||
{ | ||
[DataField] | ||
public EntityWhitelist? Whitelist; | ||
|
||
[DataField] | ||
public EntityWhitelist? Blacklist; | ||
|
||
[DataField] | ||
public List<string> BlockedDirections = new(); | ||
|
||
[DataField] | ||
public Direction? ReflectionDirection; | ||
|
||
[DataField, AutoNetworkedField] | ||
public ReflectorType State = ReflectorType.Simple; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public enum ReflectorType | ||
{ | ||
Simple, | ||
Angular, | ||
} |
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
116 changes: 116 additions & 0 deletions
116
Resources/Prototypes/Stories/Entities/Structures/Machines/refrectors.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,116 @@ | ||
- type: entity | ||
categories: [ HideSpawnMenu ] | ||
id: BaseReflector | ||
parent: [ BaseMachine, ConstructibleMachine ] | ||
components: | ||
- type: Transform | ||
noRot: false | ||
- type: Sprite | ||
sprite: Stories/Structures/Machines/reflectors.rsi | ||
- type: Reflector | ||
whitelist: | ||
tags: | ||
- EmitterBolt | ||
components: | ||
- AnomalousParticle | ||
- type: Gun | ||
projectileSpeed: 5 | ||
soundGunshot: | ||
path: /Audio/Weapons/Guns/Gunshots/taser2.ogg | ||
- type: Rotatable | ||
rotateWhileAnchored: true | ||
- type: Lock | ||
locked: false | ||
- type: LockedAnchorable | ||
- type: Destructible | ||
thresholds: | ||
- trigger: | ||
!type:DamageTrigger | ||
damage: 100 | ||
behaviors: | ||
- !type:PlaySoundBehavior | ||
sound: | ||
collection: MetalBreak | ||
- !type:ChangeConstructionNodeBehavior | ||
node: machineFrame | ||
- !type:DoActsBehavior | ||
acts: ["Destruction"] | ||
|
||
- type: entity | ||
id: ReflectorBox | ||
parent: BaseReflector | ||
name: Отражатель, тип "Коробка" | ||
description: Это устройство, способное отражать снаряды, попадающие в него, в указанном направлении. | ||
components: | ||
- type: Sprite | ||
state: reflector_circle | ||
- type: Reflector | ||
blockedDirections: | ||
- West | ||
reflectionDirection: South | ||
ReflectorType: Simple | ||
- type: Machine | ||
board: ReflectorBoxMachineCircuitboard | ||
- type: Rotatable | ||
rotateWhileAnchored: true | ||
|
||
- type: entity | ||
id: ReflectorCorner | ||
parent: BaseReflector | ||
name: Отражатель, тип "Угловой" | ||
description: Это устройство, способное отражать снаряды, попадающие в него, в указанном направлении. | ||
components: | ||
- type: Sprite | ||
state: reflector_corner | ||
- type: Reflector | ||
blockedDirections: | ||
- East | ||
- North | ||
state: Angular | ||
- type: Machine | ||
board: ReflectorCornerMachineCircuitboard | ||
- type: Rotatable | ||
rotateWhileAnchored: true | ||
- type: Fixtures | ||
fixtures: | ||
fix1: | ||
shape: | ||
!type:PolygonShape | ||
vertices: | ||
- "-0.3, 0.35" | ||
- "-0.3, -0.3" | ||
- "0.35, 0.35" | ||
mask: | ||
- FullTileMask | ||
layer: | ||
- FullTileLayer | ||
|
||
|
||
- type: entity | ||
id: ReflectorCornerTside | ||
parent: BaseReflector | ||
name: Отражатель, тип "Двойной-Угловой" | ||
description: Это устройство, способное отражать снаряды, попадающие в него, в указанном направлении. | ||
components: | ||
- type: Sprite | ||
state: reflector_corner_tside | ||
- type: Reflector | ||
state: Angular | ||
- type: Machine | ||
board: ReflectorCornerTsideMachineCircuitboard | ||
- type: Rotatable | ||
rotateWhileAnchored: true | ||
- type: Fixtures | ||
fixtures: | ||
fix1: | ||
shape: | ||
!type:PolygonShape | ||
vertices: | ||
- "0.15, 0.25" | ||
- "-0.1, -0.3" | ||
- "0.3, 0.15" | ||
- "-0.2, -0.1" | ||
mask: | ||
- FullTileMask | ||
layer: | ||
- FullTileLayer |
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,13 @@ | ||
- type: technology | ||
id: ReflectionTech | ||
name: Технологии отражения | ||
icon: | ||
sprite: Stories/Structures/Machines/reflectors.rsi | ||
state: reflector_circle | ||
discipline: Industrial | ||
tier: 2 | ||
cost: 5000 | ||
recipeUnlocks: | ||
- ReflectorBoxMachineCircuitboard | ||
- ReflectorCornerMachineCircuitboard | ||
- ReflectorCornerTsideMachineCircuitboard |
20 changes: 20 additions & 0 deletions
20
Resources/Textures/Stories/Objects/Misc/module.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,20 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Space Stories", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "reflectorbox_circuitboard" | ||
}, | ||
{ | ||
"name": "reflectorcorner_circuitboard" | ||
}, | ||
{ | ||
"name": "reflectortsidecorner_circuitboard" | ||
} | ||
] | ||
} |
Binary file added
BIN
+416 Bytes
Resources/Textures/Stories/Objects/Misc/module.rsi/reflectorbox_circuitboard.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
+416 Bytes
...urces/Textures/Stories/Objects/Misc/module.rsi/reflectorcorner_circuitboard.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
+416 Bytes
.../Textures/Stories/Objects/Misc/module.rsi/reflectortsidecorner_circuitboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ты добавил новую технологию, но тут не убрал.
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.
это dynamicRecipes , иначе говоря при изучении технологии отражения у принтера схем открывается рецепт
без него при изучении технологии - крафта плат не будет
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.
Понял.