-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил возможность вешать значки на броню (#608)
## Описание PR <!-- Что вы изменили в этом пулл реквесте? --> Название ## Почему / Баланс <!-- Почему оно было изменено? Ссылайтесь на любые обсуждения или вопросы здесь. Пожалуйста, обсудите, как это повлияет на игровой баланс. --> **Ссылка на публикацию в Discord** - [Баги](https://discord.com/channels/901772674865455115/1284125054375825439) ## Техническая информация <!-- Если речь идет об изменении кода, кратко изложите на высоком уровне принцип работы нового кода. Это облегчает рецензирование.- --> ## Медиа <!-- Пулл реквесты, которые вносят внутриигровые изменения (добавление одежды, предметов, новых возможностей и т.д.), должны содержать медиа, демонстрирующие изменения. Небольшие исправления/рефакторы не требуют медиа. Если Вы не уверены в том, что Ваш пулл реквест требует медиа, спросите мейнтейнера. --> ![изображение](https://github.com/user-attachments/assets/7e688ad2-3527-4af3-93f7-56d9c9ebc01f) ![изображение](https://github.com/user-attachments/assets/33454da1-06b9-47ea-b9ee-c023f8daaf1f) ![изображение](https://github.com/user-attachments/assets/2a707438-945b-4b3d-9f57-01eeab520810) ![изображение](https://github.com/user-attachments/assets/affd712b-b2d0-4654-8c98-d8e99910d828) ![изображение](https://github.com/user-attachments/assets/e26a5bf1-3d73-46e9-b32d-8d6b6d4825af) ![изображение](https://github.com/user-attachments/assets/109fd75f-4161-4aa2-ab47-888a7fd76b9b) ## Требования <!-- В связи с наплывом ПР'ов нам необходимо убедиться, что ПР'ы следуют правильным рекомендациям. Пожалуйста, уделите время прочтению, если делаете пулл реквест (ПР) впервые. Отметьте поля ниже, чтобы подтвердить, что Вы действительно видели их (поставьте X в скобках, например [X]): --> - [x] Я прочитал(а) и следую [Руководство по созданию пулл реквестов](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). Я понимаю, что в противном случае мой ПР может быть закрыт по усмотрению мейнтейнера. - [x] Я добавил скриншоты/видео к этому пулл реквесту, демонстрирующие его изменения в игре, **или** этот пулл реквест не требует демонстрации в игре ## Критические изменения <!-- Перечислите все критические изменения, включая изменения пространства имён, публичных классов/методов/полей, переименования прототипов, и предоставьте инструкции по их исправлению. --> **Чейнджлог** <!-- Здесь Вы можете заполнить журнал изменений, который будет автоматически добавлен в игру при мердже Вашего пулл реквест. Чтобы игроки узнали о новых возможностях и изменениях, которые могут повлиять на их игру, добавьте запись в журнал изменений. Не считайте суффикс типа записи (например, add) "частью" предложения: плохо: - add: новый инструмент для инженеров хорошо: - add: добавлен новый инструмент для инженеров Помещение имени после символа 🆑 изменит имя, которое будет отображаться в журнале изменений (в противном случае будет использоваться ваше имя пользователя GitHub). Например: 🆑 AruMoon --> 🆑 - add: Добавлена возможность закреплять значок на броне СБ --------- Co-authored-by: Tymur Valiiev <[email protected]> Co-authored-by: bananchiki <[email protected]> Co-authored-by: PyotrIgn <[email protected]> Co-authored-by: Schrödinger <[email protected]>
- Loading branch information
1 parent
423e11c
commit b59c69f
Showing
13 changed files
with
288 additions
and
11 deletions.
There are no files selected for viewing
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,15 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.ADT.Clothing.Badge; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class BadgeComponent : Component | ||
{ | ||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] | ||
public string BadgeNumber = String.Empty; | ||
|
||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] | ||
public string NotInDetailsText = "badge-cannot-be-seen-text"; | ||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] | ||
public string InDetailsText = "badge-can-be-seen-text"; | ||
} |
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,60 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Content.Shared.Examine; | ||
using Robust.Shared.Network; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Shared.ADT.Clothing.Badge; | ||
|
||
public sealed class BadgeSystem : EntitySystem | ||
{ | ||
[Dependency] protected readonly ExamineSystemShared ExamineSystem = default!; | ||
[Dependency] protected readonly IRobustRandom Random = default!; | ||
[Dependency] private readonly INetManager _net = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<BadgeComponent, ExaminedEvent>(OnExamined); | ||
} | ||
|
||
private void OnExamined(EntityUid uid, BadgeComponent component, ExaminedEvent args) | ||
{ | ||
if (!GetBadgeNumber(uid, out var badgeNumber, component)) | ||
return; | ||
|
||
if (!ExamineSystem.IsInDetailsRange(args.Examiner, uid)) | ||
{ | ||
if (component.NotInDetailsText != String.Empty) | ||
args.PushMarkup(Loc.GetString(component.NotInDetailsText, ("badgeNumber", badgeNumber))); | ||
|
||
return; | ||
} | ||
|
||
if (component.InDetailsText != String.Empty) | ||
args.PushMarkup(Loc.GetString(component.InDetailsText, ("badgeNumber", badgeNumber))); | ||
} | ||
|
||
public bool GetBadgeNumber(EntityUid badge, [NotNullWhen(true)] out string? badgeNumber, BadgeComponent? component = null) | ||
{ | ||
badgeNumber = null; | ||
if (!Resolve(badge, ref component)) | ||
return false; | ||
|
||
if (component.BadgeNumber == String.Empty) | ||
{ | ||
if (_net.IsClient) | ||
return false; | ||
component.BadgeNumber = GenerateBadgeNumber(badge, component); | ||
Dirty(badge, component); | ||
} | ||
|
||
badgeNumber = component.BadgeNumber; | ||
return true; | ||
} | ||
|
||
private string GenerateBadgeNumber(EntityUid badge, BadgeComponent component) | ||
{ | ||
return badge.Id + "-" + Random.Next(100, 99999) + "/" + Random.Next(1, 50); | ||
} | ||
} |
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,10 @@ | ||
|
||
namespace Content.Shared.ADT.Clothing.Badge; | ||
|
||
[RegisterComponent] | ||
public sealed partial class BadgeableComponent : Component | ||
{ | ||
public string Slot = "badge"; | ||
public string NotInDetailsText = "badgeable-badge-cannot-be-seen-text"; | ||
public string InDetailsText = "badgeable-badge-can-be-seen-text"; | ||
} |
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,81 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Content.Shared.ADT.Clothing.Badge; | ||
using Content.Shared.Clothing; | ||
using Content.Shared.Clothing.Components; | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.Examine; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Inventory; | ||
|
||
namespace Content.Shared.ADT.Clothing.Badge; | ||
|
||
[Virtual] | ||
public class BadgeableSystem : EntitySystem | ||
{ | ||
[Dependency] protected readonly ItemSlotsSystem ItemSlotsSystem = default!; | ||
[Dependency] protected readonly BadgeSystem BadgeSystem = default!; | ||
[Dependency] protected readonly InventorySystem InventorySystem = default!; | ||
[Dependency] protected readonly ExamineSystemShared ExamineSystem = default!; | ||
|
||
override public void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
|
||
SubscribeLocalEvent<BadgeableComponent, ExaminedEvent>(HandleExaminedEvent); | ||
SubscribeLocalEvent<InventoryComponent, ExaminedEvent>(HandleEntityExaminedEvent); | ||
} | ||
|
||
public bool GetBadgeNumber(EntityUid entity, [NotNullWhen(true)] out string? badgeNumber, BadgeableComponent? component = null) | ||
{ | ||
badgeNumber = null; | ||
|
||
if (!Resolve(entity, ref component)) | ||
return false; | ||
|
||
var badge = ItemSlotsSystem.GetItemOrNull(entity, component.Slot); | ||
if (badge is null) | ||
return false; | ||
|
||
return BadgeSystem.GetBadgeNumber(badge.Value, out badgeNumber); | ||
} | ||
|
||
protected void HandleExaminedEvent(EntityUid entity, BadgeableComponent component, ExaminedEvent ev) | ||
{ | ||
if (!GetBadgeNumber(entity, out var badgeNumber, component)) | ||
return; | ||
|
||
if (!ExamineSystem.IsInDetailsRange(ev.Examiner, entity)) | ||
{ | ||
if (component.NotInDetailsText != String.Empty) | ||
ev.PushMarkup(Loc.GetString(component.NotInDetailsText, ("badgeNumber", badgeNumber)), -5); | ||
|
||
return; | ||
} | ||
|
||
if (component.InDetailsText != String.Empty) | ||
ev.PushMarkup(Loc.GetString(component.InDetailsText, ("badgeNumber", badgeNumber)), -5); | ||
} | ||
|
||
protected void HandleEntityExaminedEvent(EntityUid entity, InventoryComponent _, ExaminedEvent ev) | ||
{ | ||
var enumerator = InventorySystem.GetSlotEnumerator(entity, SlotFlags.OUTERCLOTHING); | ||
while (enumerator.MoveNext(out var container)) | ||
{ | ||
if (!container.ContainedEntity.HasValue || container.ContainedEntity == null) | ||
continue; | ||
|
||
if (!TryComp<BadgeableComponent>(container.ContainedEntity, out var vest)) | ||
continue; | ||
|
||
if (GetBadgeNumber(container.ContainedEntity.Value, out var badgeNumber)) | ||
{ | ||
if (ExamineSystem.IsInDetailsRange(ev.Examiner, entity)) | ||
ev.PushMarkup(Loc.GetString(vest.InDetailsText, ("badgeNumber", badgeNumber)), -5); | ||
else | ||
ev.PushMarkup(Loc.GetString(vest.NotInDetailsText, ("badgeNumber", badgeNumber)), -5); | ||
} | ||
|
||
} | ||
} | ||
} |
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,8 @@ | ||
attach-to-armor = Нацепить на броню | ||
unattach-to-armor = Отцепить от брони | ||
badgeable-badge-cannot-be-seen-text = На броне закреплён какой-то значок | ||
badgeable-badge-can-be-seen-text = На броне закреплён значок №{$badgeNumber} | ||
badge-cannot-be-seen-text = Номер значка не видно | ||
badge-can-be-seen-text = Значок №{$badgeNumber} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,9 @@ | |
- type: Tag | ||
id: JanicartKeys | ||
|
||
- type: Tag | ||
id: ADTBadge | ||
|
||
- type: Tag | ||
id: ADTMagazineRifleExtended | ||
|
||
|
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
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
Oops, something went wrong.