-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ItemToggle + slots stuff - Add component for itemslot locks to match LockComponent (surprised this didn't exist). - Add thing for pointlight to match itemtoggle. In future should be used for PDAs and stuff but need to fix some other stuff first. * Also this * grill
- Loading branch information
1 parent
a89d4c7
commit c0a0761
Showing
10 changed files
with
163 additions
and
17 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Content.Shared/Containers/ItemSlot/ItemSlotsLockComponent.cs
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 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Containers.ItemSlots; | ||
|
||
/// <summary> | ||
/// Updates the relevant ItemSlots locks based on <see cref="LockComponent"/> | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class ItemSlotsLockComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public List<string> Slots = new(); | ||
} |
36 changes: 36 additions & 0 deletions
36
Content.Shared/Containers/ItemSlot/ItemSlotsSystem.Lock.cs
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,36 @@ | ||
using Content.Shared.Lock; | ||
|
||
namespace Content.Shared.Containers.ItemSlots; | ||
|
||
public sealed partial class ItemSlotsSystem | ||
{ | ||
private void InitializeLock() | ||
{ | ||
SubscribeLocalEvent<ItemSlotsLockComponent, MapInitEvent>(OnLockMapInit); | ||
SubscribeLocalEvent<ItemSlotsLockComponent, LockToggledEvent>(OnLockToggled); | ||
} | ||
|
||
private void OnLockMapInit(Entity<ItemSlotsLockComponent> ent, ref MapInitEvent args) | ||
{ | ||
if (!TryComp(ent.Owner, out LockComponent? lockComp)) | ||
return; | ||
|
||
UpdateLocks(ent, lockComp.Locked); | ||
} | ||
|
||
private void OnLockToggled(Entity<ItemSlotsLockComponent> ent, ref LockToggledEvent args) | ||
{ | ||
UpdateLocks(ent, args.Locked); | ||
} | ||
|
||
private void UpdateLocks(Entity<ItemSlotsLockComponent> ent, bool value) | ||
{ | ||
foreach (var slot in ent.Comp.Slots) | ||
{ | ||
if (!TryGetSlot(ent.Owner, slot, out var itemSlot)) | ||
continue; | ||
|
||
SetLock(ent.Owner, itemSlot, value); | ||
} | ||
} | ||
} |
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
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
12 changes: 12 additions & 0 deletions
12
Content.Shared/Light/Components/ItemTogglePointLightComponent.cs
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,12 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Light.Components; | ||
|
||
/// <summary> | ||
/// Toggles point light on an entity whenever ItemToggle hits. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class ItemTogglePointLightComponent : Component | ||
{ | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
Content.Shared/Light/EntitySystems/ItemTogglePointLightSystem.cs
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,29 @@ | ||
using Content.Shared.Item.ItemToggle.Components; | ||
using Content.Shared.Toggleable; | ||
using ItemTogglePointLightComponent = Content.Shared.Light.Components.ItemTogglePointLightComponent; | ||
|
||
namespace Content.Shared.Light.EntitySystems; | ||
|
||
/// <summary> | ||
/// Handles ItemToggle for PointLight | ||
/// </summary> | ||
public sealed class ItemTogglePointLightSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
[Dependency] private readonly SharedPointLightSystem _light = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ItemTogglePointLightComponent, ItemToggledEvent>(OnLightToggled); | ||
} | ||
|
||
private void OnLightToggled(Entity<ItemTogglePointLightComponent> ent, ref ItemToggledEvent args) | ||
{ | ||
if (!_light.TryGetLight(ent.Owner, out var light)) | ||
return; | ||
|
||
_appearance.SetData(ent, ToggleableLightVisuals.Enabled, args.Activated); | ||
_light.SetEnabled(ent.Owner, args.Activated, comp: light); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Content.Shared/Power/Components/ItemSlotRequiresPowerComponent.cs
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,9 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Power.Components; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class ItemSlotRequiresPowerComponent : Component | ||
{ | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
Content.Shared/Power/EntitySystems/ItemSlotRequiresPowerSystem.cs
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,23 @@ | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.Power.Components; | ||
|
||
namespace Content.Shared.Power.EntitySystems; | ||
|
||
public sealed class ItemSlotRequiresPowerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedPowerReceiverSystem _receiver = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ItemSlotRequiresPowerComponent, ItemSlotInsertAttemptEvent>(OnInsertAttempt); | ||
} | ||
|
||
private void OnInsertAttempt(Entity<ItemSlotRequiresPowerComponent> ent, ref ItemSlotInsertAttemptEvent args) | ||
{ | ||
if (!_receiver.IsPowered(ent.Owner)) | ||
{ | ||
args.Cancelled = true; | ||
} | ||
} | ||
} |
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,2 @@ | ||
item-toggle-activate = Activate | ||
item-toggle-deactivate = Deactivate |