Skip to content

Commit

Permalink
unhardcode night and thermal vision clothing, fix squadron helmet sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
pheenty committed Nov 13, 2024
1 parent ef26d4b commit 313da41
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 57 deletions.
20 changes: 14 additions & 6 deletions Content.Server/Stories/Nightvision/NightvisionSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Content.Shared.Actions;
using Content.Shared.GameTicking;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Stories.Nightvision;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Content.Shared.Stories.Nightvision;

namespace Content.Server.Stories.Nightvision;

Expand All @@ -21,16 +21,24 @@ public override void Initialize()
}
private void OnUnequipped(EntityUid uid, NightvisionClothingComponent component, GotUnequippedEvent args)
{
if (args.Slot == "eyes")
RemCompDeferred<NightvisionComponent>(args.Equipee);
if (TryComp<NightvisionComponent>(args.Equipee, out var comp) && comp.Sources != null)
{
comp.Sources.Remove(uid);
if (comp.Sources.Count == 0)
RemCompDeferred<NightvisionComponent>(args.Equipee);
}
}
private void OnEquipped(EntityUid uid, NightvisionClothingComponent component, GotEquippedEvent args)
{
if (_gameTiming.ApplyingState)
return;

if (component.Enabled && !HasComp<NightvisionComponent>(args.Equipee) && (args.Slot == "eyes"))
AddComp<NightvisionComponent>(args.Equipee);
if (!args.SlotFlags.HasFlag(SlotFlags.POCKET))
{
EnsureComp<NightvisionComponent>(args.Equipee, out var comp);
if (comp.Sources != null)
comp.Sources.Add(uid);
}
}
private void OnStartUp(EntityUid uid, NightvisionComponent component, ComponentStartup args)
{
Expand Down
19 changes: 13 additions & 6 deletions Content.Server/Stories/ThermalVision/ThermalVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Shared.Actions;
using Content.Shared.GameTicking;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Stories.ThermalVision;
using Robust.Shared.Player;
Expand All @@ -11,7 +11,6 @@ public sealed class ThermalVisionSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;

public override void Initialize()
{
base.Initialize();
Expand All @@ -22,16 +21,24 @@ public override void Initialize()
}
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);
if (TryComp<ThermalVisionComponent>(args.Equipee, out var comp) && comp.Sources != null)
{
comp.Sources.Remove(uid);
if (comp.Sources.Count == 0)
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);
if (!args.SlotFlags.HasFlag(SlotFlags.POCKET))
{
EnsureComp<ThermalVisionComponent>(args.Equipee, out var comp);
if (comp.Sources != null)
comp.Sources.Add(uid);
}
}
private void OnStartUp(EntityUid uid, ThermalVisionComponent component, ComponentStartup args)
{
Expand Down
7 changes: 3 additions & 4 deletions Content.Shared/Stories/Nightvision/NightvisionComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Shared.Actions;
using Content.Shared.Eye.Blinding.Systems;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;

Expand All @@ -11,6 +10,8 @@ public sealed partial class NightvisionComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("enabled"), AutoNetworkedField]
public bool Enabled { get; set; } = false;
[DataField("sources")]
public List<EntityUid>? Sources = new List<EntityUid>();
[DataField]
public string ToggleAction = "ToggleNightvisionAction";
[DataField, AutoNetworkedField]
Expand All @@ -20,10 +21,8 @@ public sealed partial class NightvisionComponent : Component
}

[RegisterComponent]
[NetworkedComponent]
public sealed partial class NightvisionClothingComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("enabled")]
public bool Enabled { get; set; } = true;
}

public sealed partial class ToggleNightvisionEvent : InstantActionEvent { }

This file was deleted.

10 changes: 8 additions & 2 deletions Content.Shared/Stories/ThermalVision/ThermalVisionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ 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("sources")]
public List<EntityUid>? Sources = new List<EntityUid>();
[DataField]
public string ToggleAction = "ToggleThermalVisionAction";
[DataField, AutoNetworkedField]
public EntityUid? ToggleActionEntity;
}

[RegisterComponent]
public sealed partial class ThermalVisionClothingComponent : Component
{
}

public sealed partial class ToggleThermalVisionEvent : InstantActionEvent { }
5 changes: 3 additions & 2 deletions Resources/Prototypes/Entities/Mobs/NPCs/carp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@
interactFailureString: petting-failure-carp
interactFailureSound:
path: /Audio/Effects/bite.ogg
- type: Nightvision # Stories
toggleOnSound: null # Stories
- type: Nightvision # Stories - start
toggleOnSound: null
sources: null # Stories - end

- type: entity
parent: BaseMobCarp
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Player/dragon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
needsHands: false
- type: Nightvision # Stories - start
toggleOnSound: null
sources: null
- type: TTS
voice: ranrak # Stories - end

Expand Down
32 changes: 13 additions & 19 deletions Resources/Prototypes/Stories/Entities/Clothing/Eyes/glasses.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
- type: entity
parent: ClothingEyesBase
id: ClothingEyesThermalVisionBase
abstract: true
id: ClothingEyesNightvision
name: прибор ночного видения
description: Позволяет видеть в полной темноте. Работает на ядерной батарее внутри и совсем не вреден для глаз.
components:
- type: ThermalVisionClothing
- type: NightvisionClothing
- type: Sprite
sprite: Stories/Clothing/Eyes/Glasses/nvg.rsi
- type: Clothing
sprite: Stories/Clothing/Eyes/Glasses/nvg.rsi

- type: entity
parent: ClothingEyesThermalVisionBase
parent: ClothingEyesBase
id: ClothingEyesThermalVisionMonocular
name: монокль термального зрения
description: Новейшая разведочная технология, которую поместили внутрь монокля. Позволяет видеть органические цели в полной темноте и даже через стены.
description: Новейшая разведывательная технология, которую поместили внутрь монокля. Позволяет видеть органические цели в полной темноте и даже через стены.
components:
- type: ThermalVisionClothing
- 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 ]
parent: [ ClothingEyesHudSyndicate, ClothingEyesThermalVisionMonocular ]
id: ClothingEyesThermalVisionHud
name: термальный визор оперативника
description: Новейшая разведочная технология, которую поместили внутрь визора. Позволяет видеть органические цели в полной темноте и даже через стены. Этот вариант специально для Ядерных Оперативников имеет встроенный визор Синдиката.
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
name: прибор ночного видения
description: Позволяет видеть в полной темноте. Работает на ядерной батарее внутри и совсем не вреден для глаз.
components:
- type: NightvisionClothing # Space Stories
- type: Sprite
sprite: Stories/Clothing/Eyes/Glasses/nvg.rsi
- type: Clothing
sprite: Stories/Clothing/Eyes/Glasses/nvg.rsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
components:
- type: ZombieImmune
- type: ThermalVision
innate: true
sources: null
- type: MobState
allowedStates:
- Alive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
components:
- type: ZombieImmune
- type: ThermalVision
innate: true
sources: null
- type: MobState
allowedStates:
- Alive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
timeModifier: 2
- type: ZombieImmune
- type: ThermalVision
innate: true
source: null
- type: ComplexInteraction
- type: Destructible
thresholds:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Stories/conversions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
color: Red
components:
- type: ThermalVision
innate: true
sources: null
- type: ShadowlingThrall
mindRoles:
- MindRoleShadowlingThrall
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
"name": "icon"
},
{
"name": "icon-flash"
},
{
"name": "off-equipped-HELMET",
"name": "equipped-HELMET",
"directions": 4
},
{
Expand Down

0 comments on commit 313da41

Please sign in to comment.