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

Доработка ночного зрения #455

Merged
merged 21 commits into from
Oct 6, 2024
Merged
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
17 changes: 16 additions & 1 deletion Content.Client/_Sunrise/Eye/NightVision/NVGSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,28 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<NVGComponent, AfterNVGUpdateVisualsEvent>(OnAfterNVGUpdateVisualsEvent);
SubscribeLocalEvent<NVGComponent, NVGClientUpdateVisualsEvent>(OnNVGClientUpdateVisualsEvent);
}

private void OnAfterNVGUpdateVisualsEvent(EntityUid uid, NVGComponent component, AfterNVGUpdateVisualsEvent args)
{
var nvcomp = args.nvcomp;

if (TryComp<SpriteComponent>(component.Owner, out var sprite))
sprite.LayerSetVisible(NVGVisuals.Light, nvcomp.IsNightVision);
{
if (sprite.LayerMapTryGet(NVGVisuals.Light, out var layer))
sprite.LayerSetVisible(layer, !nvcomp.IsNightVision);
}
}

private void OnNVGClientUpdateVisualsEvent(EntityUid uid, NVGComponent component, NVGClientUpdateVisualsEvent args)
{
var nvcomp = args.nvcomp;

if (TryComp<SpriteComponent>(component.Owner, out var sprite))
{
if (sprite.LayerMapTryGet(NVGVisuals.Light, out var layer))
sprite.LayerSetVisible(layer, args.enable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)

_nightvisionComponent = nightvisionComp;

NightvisionColor = _nightvisionComponent.NightVisionColor;

var nightvision = _nightvisionComponent.IsNightVision;

if (!nightvision && _nightvisionComponent.DrawShadows) // Disable our Night Vision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public sealed partial class NVGComponent : Component
[DataField] public EntProtoId<InstantActionComponent> ActionProto = "NVToggleAction";
[DataField] public EntityUid? ActionContainer;

[DataField("color")]
public Color NVGColor = Color.Green;

[DataField("playSounds")]
public bool PlaySounds = true;
public SoundSpecifier SoundOn = new SoundPathSpecifier("/Audio/_Sunrise/Items/night_vision_on.ogg");
Expand Down
50 changes: 38 additions & 12 deletions Content.Shared/_Sunrise/Eye/NightVision/Systems/NVGSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ private void OnNVGUpdateVisuals(EntityUid uid, NVGComponent component, NVGUpdate
{
var nvcomp = args.nvcomp;

_actionsSystem.SetCooldown(component.ActionContainer, TimeSpan.FromSeconds(15));
_actionsSystem.SetCooldown(component.ActionContainer, TimeSpan.FromSeconds(5));

if (nvcomp.IsNightVision)
if (!nvcomp.IsNightVision)
{
if (_net.IsServer && component.PlaySounds)
_audioSystem.PlayPvs(component.SoundOn, uid);
}
else if (!nvcomp.IsNightVision)
else if (nvcomp.IsNightVision)
{
if (_net.IsServer && component.PlaySounds)
_audioSystem.PlayPvs(component.SoundOff, uid);
Expand All @@ -53,6 +53,23 @@ private void OnNVGUpdateVisuals(EntityUid uid, NVGComponent component, NVGUpdate
var updVisEv = new AfterNVGUpdateVisualsEvent(nvcomp);
RaiseLocalEvent(component.Owner, ref updVisEv);
}

public void UpdateVisuals(EntityUid uid, NVGComponent component, bool enable, NightVisionComponent nvcomp)
{
if (enable)
{
if (_net.IsServer && component.PlaySounds)
_audioSystem.PlayPvs(component.SoundOn, uid);
}
else if (!enable)
{
if (_net.IsServer && component.PlaySounds)
_audioSystem.PlayPvs(component.SoundOff, uid);
}

var updVisEv = new NVGClientUpdateVisualsEvent(nvcomp, enable);
RaiseLocalEvent(component.Owner, ref updVisEv);
}

private void OnEquipped(EntityUid uid, NVGComponent component, GotEquippedEvent args)
{
Expand All @@ -69,14 +86,7 @@ private void OnEquipped(EntityUid uid, NVGComponent component, GotEquippedEvent
_nightvisionableSystem.UpdateIsNightVision(args.Equipee, nvcomp);
if (component.ActionContainer == null)
_actionsSystem.AddAction(args.Equipee, ref component.ActionContainer, component.ActionProto);
_actionsSystem.SetCooldown(component.ActionContainer, TimeSpan.FromSeconds(1)); // GCD?

if (component.PlaySounds && nvcomp.IsNightVision)
{
if (_net.IsServer)
_audioSystem.PlayPvs(component.SoundOn, uid);
}

_actionsSystem.SetCooldown(component.ActionContainer, TimeSpan.FromSeconds(5)); // GCD?
}

private void OnUnequipped(EntityUid uid, NVGComponent component, GotUnequippedEvent args)
Expand All @@ -94,7 +104,10 @@ private void OnUnequipped(EntityUid uid, NVGComponent component, GotUnequippedEv
component.ActionContainer = null;
}

RemCompDeferred<NightVisionComponent>(args.Equipee);
UpdateVisuals(uid ,component, false, nvcomp);

if (_net.IsServer)
RemCompDeferred<NightVisionComponent>(args.Equipee);
}
}

Expand All @@ -106,4 +119,17 @@ public AfterNVGUpdateVisualsEvent(NightVisionComponent component)
{
nvcomp = component;
}
}

[PublicAPI, ByRefEvent]
public sealed class NVGClientUpdateVisualsEvent : EntityEventArgs {
public NightVisionComponent nvcomp;
public bool enable;

public NVGClientUpdateVisualsEvent(NightVisionComponent component, bool isenable)
{
nvcomp = component;
enable = isenable;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,38 @@ private void OnComponentStartup(EntityUid uid, NightVisionComponent component, C

private void OnActionToggle(EntityUid uid, NightVisionComponent component, NVInstantActionEvent args)
{
component.IsNightVision = !component.IsNightVision;
var changeEv = new NightVisionToggledEvent(component.IsNightVision);
RaiseLocalEvent(uid, ref changeEv);
Dirty(uid, component);
_actionsSystem.SetCooldown(component.ActionContainer, TimeSpan.FromSeconds(15));


var updVisEv = new NVGUpdateVisualsEvent(component);

if (_inventory.TryGetSlotEntity(uid, "eyes", out var eyesEntity))
{
if (HasComp<NVGComponent>(eyesEntity))
if (TryComp<NVGComponent>(eyesEntity, out var nvcomp))
{
component.NightVisionColor = nvcomp.NVGColor;
RaiseLocalEvent(eyesEntity.Value, ref updVisEv);
}
}
else if (_inventory.TryGetSlotEntity(uid, "mask", out var maskEntity))
{
if (HasComp<NVGComponent>(maskEntity))
if (TryComp<NVGComponent>(maskEntity, out var nvcomp))
{
component.NightVisionColor = nvcomp.NVGColor;
RaiseLocalEvent(maskEntity.Value, ref updVisEv);
}
}
else if (_inventory.TryGetSlotEntity(uid, "head", out var headEntity))
{
if (HasComp<NVGComponent>(headEntity))
if (TryComp<NVGComponent>(headEntity, out var nvcomp))
{
component.NightVisionColor = nvcomp.NVGColor;
RaiseLocalEvent(headEntity.Value, ref updVisEv);
}
}

component.IsNightVision = !component.IsNightVision;
var changeEv = new NightVisionToggledEvent(component.IsNightVision);
RaiseLocalEvent(uid, ref changeEv);
Dirty(uid, component);
_actionsSystem.SetCooldown(component.ActionContainer, TimeSpan.FromSeconds(5));
}

[PublicAPI]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ent-ClothingEyesVision = ПНВ
.desc = Прибор ночного видения. Обеспечивает изображение местности в условиях низкой освещенности.
ent-ClothingEyesVisionNuki = { ent-ClothingEyesVision }
.desc = { ent-ClothingEyesVision.desc }
.suffix = ЯО
ent-ClothingEyesNVD = ПНВ
.desc = Прибор ночного видения. Обеспечивает улучшение видимости в условиях низкой освещенности.
ent-ClothingEyesNVDSyndicate = ПНВ синдиката
.desc = Качественно исполненый прибор ночного видения, производства компании "Горлакс секьюрити", использует красные линзы для улучшения видимости в условиях низкой освещенности.
.suffix = Синдикат
ent-ClothingEyesNVDHandcrafted = кустарное ПНВ
.desc = Прибор ночного видения. Обеспечивает улучшение видимости в условиях низкой освещенности. На вид явно сделаное не качетсвенно. На боку визора видна надпись "Ручного производства".
.suffix = Кустарное
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
research-technology-energy-gun = Энергетическое вооружение
research-technology-energy-gun-advance = Продвинутое энергетическое вооружение
research-technology-advance-laser = Военное энергетическое вооружение
research-technology-handcraft-nvd = Кустарные ПНВ
research-technology-basic-nvd = Продвинутое ПНВ
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ uplink-hardsuit-syndie-commander-name = скафандр Командира Си
uplink-hardsuit-syndie-commander-desc = Скафандр предназначеный для командиров отрядов Горлекса.
uplink-hardsuit-syndie-medic-name = скафандр Медика Синдиката
uplink-hardsuit-syndie-medic-desc = Скафандр предназначеный для боевых врачей отрядов Горлекса.
uplink-syndie-nvd-name = ПНВ Синдиката
uplink-syndie-nvd-desc = Качественно исполненый прибор ночного видения, производства компании "Горлакс секьюрити", использует красные линзы для улучшения видимости в условиях низкой освещенности.
3 changes: 0 additions & 3 deletions Resources/Locale/ru-RU/_strings/research/technologies.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,3 @@ research-technology-honk-weapons = Бананиумное вооружение
research-technology-advanced-spray = Продвинутые спреи
research-technology-quantum-fiber-weaving = Плетение квантового волокна
research-technology-bluespace-cargo-transport = Блюспейс-транспортировка грузов
research-technology-energy-gun = Энергетическое вооружение
research-technology-energy-gun-advance = Продвинутое энергетическое вооружение
research-technology-advance-laser = Военное энергетическое вооружение
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@
- type: PressureProtection
highPressureMultiplier: 0.1
lowPressureMultiplier: 1000
- type: EyeProtection # Sunrise-Edit
- type: FlashImmunity # Sunrise-Edit
# Sunrise-Start
- type: EyeProtection
- type: FlashImmunity
- type: NVG
color: "#ebeb00"
# Sunrise-End

#Spationaut Hardsuit
- type: entity
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@
- OreBagOfHolding
- DeviceQuantumSpinInverter
- EnergyDomeDirectionalTurtle
# Sunrise-start
- HandCraftedNVD
- BasicNVD
# Sunrise-end
- type: EmagLatheRecipes
emagDynamicRecipes:
# Sunrise-Start
Expand Down
8 changes: 2 additions & 6 deletions Resources/Prototypes/_Sunrise/Actions/nvg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
components:
- type: InstantAction
useDelay: 2.5
icon:
sprite: Clothing/Eyes/Glasses/ninjavisor.rsi
state: icon
icon: { sprite: _Sunrise/Clothing/Eyes/Glasses/nvg.rsi, state: icon }
event: !type:NVInstantActionEvent

- type: entity
Expand All @@ -19,7 +17,5 @@
components:
- type: InstantAction
useDelay: 2.5
icon:
sprite: Clothing/Eyes/Glasses/ninjavisor.rsi
state: icon
icon: { sprite: _Sunrise/Clothing/Eyes/Glasses/nvg.rsi, state: icon }
event: !type:NVInstantActionEvent
11 changes: 11 additions & 0 deletions Resources/Prototypes/_Sunrise/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
- type: listing
id: UplinkSyndieNVD
name: uplink-syndie-nvd-name
description: uplink-syndie-nvd-desc
icon: { sprite: /Textures/_Sunrise/Clothing/Eyes/Glasses/syndie_nvd.rsi, state: icon }
productEntity: ClothingEyesNVDSyndicate
cost:
Telecrystal: 4
categories:
- UplinkWearables

# For the Buldog
- type: listing
id: UplinkMagazineShotgun
Expand Down
34 changes: 32 additions & 2 deletions Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/nvg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
components:
- type: Item
- type: Sprite
sprite: _Sunrise/Clothing/Eyes/Glasses/nvg.rsi
sprite: _Sunrise/Clothing/Eyes/Glasses/nvd.rsi
layers:
- state: icon
- state: icon-unshaded
Expand Down Expand Up @@ -40,4 +40,34 @@
id: ClothingEyesNVDSyndicate
suffix: syndicate
components:
- type: ShowSyndicateIcons
- type: Sprite
sprite: _Sunrise/Clothing/Eyes/Glasses/syndie_nvd.rsi
layers:
- state: icon
- state: icon-unshaded
shader: unshaded
- state: light-overlay
visible: false
shader: unshaded
map: [ "enum.NVGVisuals.Light" ]
- type: ShowSyndicateIcons
- type: NVG
color: "#800000"

- type: entity
parent: ClothingEyesNVD
id: ClothingEyesNVDHandcrafted
suffix: handcrafted
components:
- type: Sprite
sprite: _Sunrise/Clothing/Eyes/Glasses/handcrafted_nvd.rsi
layers:
- state: icon
- state: icon-unshaded
shader: unshaded
- state: light-overlay
visible: false
shader: unshaded
map: [ "enum.NVGVisuals.Light" ]
- type: NVG
color: "#ebeb00"
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
flashDamage:
types:
Shock: 5.0
- type: NightVision
isToggle: true
color: "#808080"

- type: entity
save: false
Expand Down
18 changes: 18 additions & 0 deletions Resources/Prototypes/_Sunrise/Recipes/Lathes/devices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- type: latheRecipe
id: HandCraftedNVD
result: ClothingEyesNVDHandcrafted
completetime: 10
materials:
Steel: 500
Plastic: 200
Plasma: 300

- type: latheRecipe
id: BasicNVD
result: ClothingEyesNVD
completetime: 10
materials:
Steel: 1000
Plastic: 400
Silver: 100
Diamond: 100
27 changes: 27 additions & 0 deletions Resources/Prototypes/_Sunrise/Research/industrial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Tier 1

- type: technology
id: HandcraftNVD
name: research-technology-handcraft-nvd
icon:
sprite: _Sunrise/Clothing/Eyes/Glasses/handcrafted_nvd.rsi
state: icon
discipline: Industrial
tier: 1
cost: 2500
recipeUnlocks:
- HandCraftedNVD

# Tier 2

- type: technology
id: BasicNVD
name: research-technology-basic-nvd
icon:
sprite: _Sunrise/Clothing/Eyes/Glasses/nvd.rsi
state: icon
discipline: Industrial
tier: 2
cost: 5000
recipeUnlocks:
- BasicNVD
Loading
Loading