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 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
44 changes: 44 additions & 0 deletions Content.Server/Stories/ThermalVision/ThermalVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Shared.Actions;
using Content.Shared.GameTicking;
using Content.Shared.Inventory.Events;
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" && !(TryComp<ThermalVisionComponent>(args.Equipee, out var comp) && comp.Innate))
RemCompDeferred<ThermalVisionComponent>(args.Equipee);
}
private void OnEquipped(EntityUid uid, ThermalVisionClothingComponent component, GotEquippedEvent args)
{
if (_gameTiming.ApplyingState)
return;

if (args.Slot == "eyes" && component.Enabled && !HasComp<ThermalVisionComponent>(args.Equipee))
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;
}
12 changes: 10 additions & 2 deletions Content.Shared/Stories/ThermalVision/ThermalVisionComponent.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
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;
[ViewVariables(VVAccess.ReadWrite), DataField("innate"), AutoNetworkedField]
public bool Innate { 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/Actions/thermalVision.rsi, state: toggle }
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 @@ -30,3 +30,39 @@
Telecrystal: 8
categories:
- UplinkWeaponry

- 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
components:
- type: ZombieImmune
- type: ThermalVision
innate: true
- type: MobState
allowedStates:
- Alive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
components:
- type: ZombieImmune
- type: ThermalVision
innate: true
- type: MobState
allowedStates:
- Alive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
components:
- type: ZombieImmune
- type: ThermalVision
innate: true
- type: ComplexInteraction
- type: Destructible
thresholds:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Stories/conversions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
color: Red
components:
- type: ThermalVision
innate: true
- type: ShadowlingThrall
mindRoles:
- MindRoleShadowlingThrall
Expand Down
14 changes: 14 additions & 0 deletions Resources/Textures/Stories/Actions/thermalVision.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": 1,
"license": "CC-BY-NC-SA-3.0",
"copyright": "Created By RustedTim(discord:helloo4771) for SpaceStories(Server SS14).",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "toggle"
}
]
}
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,26 @@
{
"version": 1,
"license": "CC-BY-NC-SA-3.0",
"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
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": "CC-BY-NC-SA-3.0",
"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