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

[WIP] Attachables-220 #2672

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions Content.Client/Content.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
<Import Project="..\RobustToolbox\MSBuild\XamlIL.targets" />
<ItemGroup>
<EmbeddedResource Remove="ss220\attachables\AttachablesContainerMenu.xaml" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Update="SS220\Attachables\AttachablesContainerMenu.xaml">
<Generator>MSBuild:Compile</Generator>
</AdditionalFiles>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

using Robust.Client.UserInterface;

namespace Content.Client.SS220.Attachables;

public sealed class AttachablesContainerBoundUserInterface : BoundUserInterface
{
private AttachablesContainerMenu? _menu;

public AttachablesContainerBoundUserInterface(EntityUid owner, Enum uiKey) : base (owner, uiKey)
{
IoCManager.InjectDependencies(this);
}

protected override void Open()
{
base.Open();

_menu = this.CreateWindow<AttachablesContainerMenu>();
_menu.SetEntity(Owner);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ui:RadialMenu
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
CloseButtonStyleClass="RadialMenuCloseButton"
VerticalExpand="True"
HorizontalExpand="True">
</ui:RadialMenu>
29 changes: 29 additions & 0 deletions Content.Client/SS220/Attachables/AttachablesContainerMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using System.Numerics;

namespace Content.Client.SS220.Attachables;

[GenerateTypedNameReferences]
public sealed partial class AttachablesContainerMenu : RadialMenu
{
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

public EntityUid Entity { get; set; }

public AttachablesContainerMenu()
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
}

public void SetEntity(EntityUid ent)
{
Entity = ent;
}
}

public sealed class AttachablesContainerMenuButton : RadialMenuTextureButtonWithSector { }
4 changes: 4 additions & 0 deletions Content.Shared/Content.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="SS220\Attachables\Component\Guns\" />
<Folder Include="SS220\Attachables\Component\Clothes\" />
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
<Import Project="..\RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets" />
</Project>
15 changes: 15 additions & 0 deletions Content.Shared/SS220/Attachables/Component/AttachableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.Attachables;

public abstract partial class AttachableComponent : Component
{
[DataField]
public float AttachDelay;

[DataField]
public float DeattachDelay;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

using Content.Shared.Actions;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.Attachables;

[RegisterComponent, NetworkedComponent]
public sealed partial class AttachablesContainerComponent : Component
{
[DataField("slots")]
public Dictionary<string, ItemSlot> AllowedSlots = new();

public EntityUid? ActiveSlot;

[DataField]
public EntProtoId ToggleAction = "ActionToggleAttachablesMenu";

[DataField]
public EntityUid? ToggleActionEntity;
}

public sealed partial class AttachablesContainerOpenEvent : InstantActionEvent;
16 changes: 16 additions & 0 deletions Content.Shared/SS220/Attachables/Events/AttachableEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

using Robust.Shared.Serialization;

namespace Content.Shared.SS220.Attachables.Events;

[Serializable, NetSerializable]
public sealed class AttachablesContainerMessage : BoundUserInterfaceMessage
{
public AttachablesContainerMessage(EntityUid owner) {}
}

[Serializable, NetSerializable]
public enum AttachablesContainerUiKey : byte
{
Key
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

using Content.Shared.Actions;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.Attachables.Systems;

public sealed partial class AttachablesContainerSystem : EntitySystem
{
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly SharedContainerSystem _sharedContainerSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainerSystem = default!;

[Dependency] private readonly SharedUserInterfaceSystem _sharedUserInterfaceSystem = default!;
[Dependency] private readonly SharedActionsSystem _sharedActionsSystem = default!;


[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AttachablesContainerComponent, MapInitEvent>(OnMapInit);

SubscribeLocalEvent<AttachablesContainerComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<AttachablesContainerComponent, ComponentRemove>(OnComponentRemove);

SubscribeLocalEvent<AttachablesContainerComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
SubscribeLocalEvent<AttachablesContainerComponent, EntRemovedFromContainerMessage>(OnEntRemoved);

}

#region Main component events

public void OnMapInit(EntityUid uid, AttachablesContainerComponent component, MapInitEvent args)
{
_actionContainerSystem.EnsureAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
Dirty(uid, component);
}

public void OnComponentInit(EntityUid uid, AttachablesContainerComponent component, ComponentInit args)
{
foreach (var (id, slot) in component.AllowedSlots)
{
_itemSlotsSystem.AddItemSlot(uid, id, slot);
// _itemSlotsSystem.SetLock(uid, slot, true);
_sharedContainerSystem.GetContainer(uid, id).OccludesLight = false;
}
}

public void OnComponentRemove(EntityUid uid, AttachablesContainerComponent component, ComponentRemove args)
{
foreach (var (id, slot) in component.AllowedSlots)
{
_itemSlotsSystem.RemoveItemSlot(uid, slot);
}
}

#endregion

#region Messages

public void OnEntInserted(EntityUid uid, AttachablesContainerComponent component, EntInsertedIntoContainerMessage args) { }
public void OnEntRemoved(EntityUid uid, AttachablesContainerComponent component, EntRemovedFromContainerMessage args) { }

#endregion

#region I dunno
protected void OnAttach() { }

protected void OnDeattach() { }

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
- type: Tag
tags:
- SecBeltEquip
- AttachmentSlotMuzzle #SS220-NewAttachables
- type: ItemSlots
slots:
cell_slot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@
description: A rooty tooty point and shooty.
abstract: true
components:
#SS220-NewAttachables begin
- type: AttachablesContainer
slots:
attachment_slot_muzzle:
name: Muzzle
whitelist:
tags:
- AttachmentSlotMuzzle
attachment_slot_rail:
name: Rail
whitelist:
tags:
- AttachmentSlotRail
attachment_slot_underbarrel:
name: Underbarrel
whitelist:
tags:
- AttachmentSlotUnder
attachment_slot_stock:
name: Stock
whitelist:
tags:
- AttachmentSlotStock
- type: UserInterface
interfaces:
enum.AttachablesContainerUiKey.Key:
type: AttachablesContainerBoundUserInterface
#SS220-NewAttachables end
- type: EmitSoundOnLand
sound:
path: /Audio/SS220/Effects/Drop/rifles.ogg
Expand Down Expand Up @@ -55,6 +83,12 @@
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
#SS220-NewAttachables begin
attachment_slot_muzzle: !type:ContainerSlot
attachment_slot_rail: !type:ContainerSlot
attachment_slot_underbarrel: !type:ContainerSlot
attachment_slot_stock: !type:ContainerSlot
#SS220-NewAttachables end
- type: StaticPrice
price: 500

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
- type: Tag
tags:
- CombatKnife
- AttachmentSlotMuzzle #SS220-NewAttachables
- Knife
- type: Sprite
sprite: Objects/Weapons/Melee/combat_knife.rsi
Expand Down
8 changes: 8 additions & 0 deletions Resources/Prototypes/SS220/Attachables/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- type: entity
id: ActionToggleAttachablesMenu
name: Idk
components:
- type: InstantAction
itemIconStyle: BigItem
event: !type:AttachablesContainerOpenEvent
useDelay: 0.5
16 changes: 16 additions & 0 deletions Resources/Prototypes/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@
- type: Tag
id: ATVKeys

#SS220-NewAttachables begin

- type: Tag
id: AttachmentSlotMuzzle

- type: Tag
id: AttachmentSlotRail

- type: Tag
id: AttachmentSlotStock

- type: Tag
id: AttachmentSlotUnder

#SS220-NewAttachables end

- type: Tag
id: Balloon

Expand Down
Loading
Loading