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

Очки термального зрения #138

Merged
merged 12 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
45 changes: 45 additions & 0 deletions Content.Server/Stories/ThermalVision/ThermalVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Content.Shared.Actions;
using Content.Shared.GameTicking;
using Content.Shared.Inventory.Events;
using Content.Shared.Stories.Shadowling;
using Content.Shared.Stories.ThermalVision;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Server.Stories.ThermalVision;

public sealed class ThermalVisionSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ThermalVisionClothingComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<ThermalVisionClothingComponent, GotUnequippedEvent>(OnUnequipped);
SubscribeLocalEvent<ThermalVisionComponent, ComponentStartup>(OnStartUp);
SubscribeLocalEvent<ThermalVisionComponent, ComponentShutdown>(OnShutdown);
}
private void OnUnequipped(EntityUid uid, ThermalVisionClothingComponent component, GotUnequippedEvent args)
{
if (args.Slot == "eyes" && !HasComp<ShadowlingThrallComponent>(args.Equipee))
pheenty marked this conversation as resolved.
Show resolved Hide resolved
RemCompDeferred<ThermalVisionComponent>(args.Equipee);
}
private void OnEquipped(EntityUid uid, ThermalVisionClothingComponent component, GotEquippedEvent args)
{
if (_gameTiming.ApplyingState)
return;

if (component.Enabled && !HasComp<ThermalVisionComponent>(args.Equipee) && (args.Slot == "eyes"))
AddComp<ThermalVisionComponent>(args.Equipee);
}
private void OnStartUp(EntityUid uid, ThermalVisionComponent component, ComponentStartup args)
{
_actions.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
}
private void OnShutdown(EntityUid uid, ThermalVisionComponent component, ComponentShutdown args)
{
Del(component.ToggleActionEntity);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
namespace Content.Shared.Stories.ThermalVision;
using Robust.Shared.Timing;

namespace Content.Shared.Stories.ThermalVision;

public abstract class SharedThermalVisionSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ThermalVisionComponent, MapInitEvent>(OnThermalVisionMapInit);
SubscribeLocalEvent<ThermalVisionComponent, ComponentRemove>(OnThermalVisionRemove);

SubscribeLocalEvent<ThermalVisionComponent, AfterAutoHandleStateEvent>(OnThermalVisionAfterHandle);

SubscribeLocalEvent<ThermalVisionComponent, ToggleThermalVisionEvent>(OnToggle);
}

private void OnThermalVisionAfterHandle(Entity<ThermalVisionComponent> ent, ref AfterAutoHandleStateEvent args)
Expand All @@ -32,4 +39,12 @@ protected virtual void ThermalVisionChanged(Entity<ThermalVisionComponent> ent)
protected virtual void ThermalVisionRemoved(Entity<ThermalVisionComponent> ent)
{
}
private void OnToggle(EntityUid uid, ThermalVisionComponent component, ToggleThermalVisionEvent args)
{
if (!_timing.IsFirstTimePredicted)
return;
component.Enabled = !component.Enabled;
var ent = new Entity<ThermalVisionComponent>(uid, component);
ThermalVisionChanged(ent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Stories.ThermalVision;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
public sealed partial class ThermalVisionClothingComponent : Component
{
[DataField, AutoNetworkedField]
public bool Enabled = true;
}
10 changes: 8 additions & 2 deletions Content.Shared/Stories/ThermalVision/ThermalVisionComponent.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using Robust.Shared.GameStates;
using Content.Shared.Actions;
using Robust.Shared.GameStates;

namespace Content.Shared.Stories.ThermalVision;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
public sealed partial class ThermalVisionComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("enabled"), AutoNetworkedField]
public bool Enabled { get; set; } = false;
[DataField]
public string ToggleAction = "ToggleThermalVisionAction";
[DataField, AutoNetworkedField]
public bool Enabled = true;
public EntityUid? ToggleActionEntity;
}
public sealed partial class ToggleThermalVisionEvent : InstantActionEvent { }
9 changes: 9 additions & 0 deletions Resources/Prototypes/Stories/Actions/thermalvision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- type: entity
id: ToggleThermalVisionAction
name: Термальное зрение
description: Переключить своё термальное зрение.
components:
- type: InstantAction
useDelay: 5
icon: { sprite: Stories/Clothing/Eyes/Glasses/termalhud.rsi, state: action }
event: !type:ToggleThermalVisionEvent
36 changes: 36 additions & 0 deletions Resources/Prototypes/Stories/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,39 @@
Telecrystal: 2
categories:
- UplinkWearables

- type: listing
id: UplinkClothingEyesThermalVisionMonocular
name: Монокль термального зрения
description: Новейшая разведочная технология, которую поместили внутрь монокля. Позволяет видеть органические цели в полной темноте и даже через стены.
productEntity: ClothingEyesThermalVisionMonocular
discountCategory: rareDiscounts
discountDownTo:
Telecrystal: 4
cost:
Telecrystal: 6
categories:
- UplinkWearables
conditions:
- !type:StoreWhitelistCondition
blacklist:
tags:
- NukeOpsUplink

- type: listing
id: UplinkClothingEyesThermalVisionHud
name: Термальный визор оперативника
description: Новейшая разведочная технология, которую поместили внутрь визора. Позволяет видеть органические цели в полной темноте и даже через стены. Этот вариант специально для Ядерных Оперативников имеет встроенный визор Синдиката.
productEntity: ClothingEyesThermalVisionHud
discountCategory: rareDiscounts
discountDownTo:
Telecrystal: 6
cost:
Telecrystal: 9
categories:
- UplinkWearables
conditions:
- !type:StoreWhitelistCondition
whitelist:
tags:
- NukeOpsUplink
29 changes: 29 additions & 0 deletions Resources/Prototypes/Stories/Entities/Clothing/Eyes/glasses.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
- type: entity
parent: ClothingEyesBase
id: ClothingEyesThermalVisionBase
abstract: true
components:
- type: ThermalVisionClothing

- type: entity
parent: ClothingEyesThermalVisionBase
id: ClothingEyesThermalVisionMonocular
name: монокль термального зрения
description: Новейшая разведочная технология, которую поместили внутрь монокля. Позволяет видеть органические цели в полной темноте и даже через стены.
components:
- type: Sprite
sprite: Stories/Clothing/Eyes/Glasses/termalhud_oneglass.rsi
- type: Clothing
sprite: Stories/Clothing/Eyes/Glasses/termalhud_oneglass.rsi

- type: entity
parent: [ ClothingEyesThermalVisionBase, ClothingEyesHudSyndicate ]
id: ClothingEyesThermalVisionHud
name: термальный визор оперативника
description: Новейшая разведочная технология, которую поместили внутрь визора. Позволяет видеть органические цели в полной темноте и даже через стены. Этот вариант специально для Ядерных Оперативников имеет встроенный визор Синдиката.
components:
- type: Sprite
sprite: Stories/Clothing/Eyes/Glasses/termalhud.rsi
- type: Clothing
sprite: Stories/Clothing/Eyes/Glasses/termalhud.rsi

- type: entity
parent: ClothingEyesBase
id: ClothingEyesNightvision
Expand Down
pheenty marked this conversation as resolved.
Show resolved Hide resolved
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.
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.
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,29 @@
{
"version": 1,
"license": "Собственная лицензия. Копирование, модификация и использование вне проекта Space Stories полностью запрещено без предварительного согласия текущего владельца проекта",
pheenty marked this conversation as resolved.
Show resolved Hide resolved
"copyright": "Created By RustedTim(discord:helloo4771) for SpaceStories(Server SS14).",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "action"
},
{
"name": "equipped-EYES",
"directions": 4
},
{
"name": "icon"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}
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.
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,26 @@
{
"version": 1,
"license": "Собственная лицензия. Копирование, модификация и использование вне проекта Space Stories полностью запрещено без предварительного согласия текущего владельца проекта",
pheenty marked this conversation as resolved.
Show resolved Hide resolved
"copyright": "Created By RustedTim(discord:helloo4771) for SpaceStories(Server SS14).",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "equipped-EYES",
"directions": 4
},
{
"name": "icon"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}
Loading