Skip to content

Commit

Permalink
Kerfus is real (#419)
Browse files Browse the repository at this point in the history
<!-- ЭТО ШАБЛОН ВАШЕГО PULL REQUEST. Текст между стрелками - это
комментарии - они не будут видны в PR. -->

## Описание PR
Легендарный фикс вендоматов, возвращение причесок слаймов, а также...
Керфус?
<!-- Ниже опишите ваш Pull Request. Что он изменяет? На что еще это
может повлиять? Постарайтесь описать все внесённые вами изменения! -->

**Медиа**
Да что такое фотопленка.
<!-- Если приемлемо, добавьте скриншоты для демонстрации вашего PR. Если
ваш PR представляет собой визуальное изменение, добавьте
скриншоты, иначе он может быть закрыт. -->

**Проверки**
<!-- Выполнение всех следующих действий, если это приемлемо для вида
изменений сильно ускорит разбор вашего PR -->
- [ ] PR полностью завершён и мне не нужна помощь чтобы его закончить.
- [ ] Я внимательно просмотрел все свои изменения и багов в них не
нашёл.
- [ ] Я запускал локальный сервер со своими изменениями и всё
протестировал.
- [ ] Я добавил скриншот/видео демонстрации PR в игре, **или** этот PR
этого не требует.

**Изменения**
<!--
Здесь вы можете написать список изменений, который будет автоматически
добавлен в игру, когда ваш PR будет принят.

В журнал изменений следует помещать только то, что действительно важно
игрокам.

В списке изменений тип значка не является часть предложения, поэтому
явно указывайте - Добавлен, Удалён, Изменён.
плохо: - add: Новый инструмент для инженеров
хорошо: - add: Добавлен новый инструмент для инженеров

Вы можете указать своё имя после символа 🆑 именно оно будет
отображаться в журнале изменений (иначе будет использоваться ваше имя на
GitHub)
Например: 🆑 Ian

-->

🆑 KashRas2
- add: Возвращена возможность менять прически слаймам.
- add: Отдел разработок Нанотрейзен представляет новую модель боргов для
командования - Керфус.
- fix: Починены цены в вендоматах после апстрима. 
- fix: Спрайт голограммы банкомата сбоку получило недостающие пиксели.

---------

Co-authored-by: KashRas2 <[email protected]>
  • Loading branch information
KashRas2 and KashRas committed Sep 6, 2024
1 parent cd07891 commit 642043f
Show file tree
Hide file tree
Showing 39 changed files with 1,109 additions and 3 deletions.
66 changes: 66 additions & 0 deletions Content.Client/ADT/SlimeHair/SlimeHairBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Content.Shared.Humanoid.Markings;
using Content.Shared.ADT.SlimeHair;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

namespace Content.Client.ADT.SlimeHair;

public sealed class SlimeHairBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SlimeHairWindow? _window;

public SlimeHairBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

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

_window = this.CreateWindow<SlimeHairWindow>();

_window.OnHairSelected += tuple => SelectHair(SlimeHairCategory.Hair, tuple.id, tuple.slot);
_window.OnHairColorChanged += args => ChangeColor(SlimeHairCategory.Hair, args.marking, args.slot);
_window.OnHairSlotAdded += delegate () { AddSlot(SlimeHairCategory.Hair); };
_window.OnHairSlotRemoved += args => RemoveSlot(SlimeHairCategory.Hair, args);

_window.OnFacialHairSelected += tuple => SelectHair(SlimeHairCategory.FacialHair, tuple.id, tuple.slot);
_window.OnFacialHairColorChanged +=
args => ChangeColor(SlimeHairCategory.FacialHair, args.marking, args.slot);
_window.OnFacialHairSlotAdded += delegate () { AddSlot(SlimeHairCategory.FacialHair); };
_window.OnFacialHairSlotRemoved += args => RemoveSlot(SlimeHairCategory.FacialHair, args);
}

private void SelectHair(SlimeHairCategory category, string marking, int slot)
{
SendMessage(new SlimeHairSelectMessage(category, marking, slot));
}

private void ChangeColor(SlimeHairCategory category, Marking marking, int slot)
{
SendMessage(new SlimeHairChangeColorMessage(category, new(marking.MarkingColors), slot));
}

private void RemoveSlot(SlimeHairCategory category, int slot)
{
SendMessage(new SlimeHairRemoveSlotMessage(category, slot));
}

private void AddSlot(SlimeHairCategory category)
{
SendMessage(new SlimeHairAddSlotMessage(category));
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not SlimeHairUiState data || _window == null)
{
return;
}

_window.UpdateState(data);
}
}
9 changes: 9 additions & 0 deletions Content.Client/ADT/SlimeHair/SlimeHairWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:humanoid="clr-namespace:Content.Client.Humanoid"
Title="{Loc 'slime-hair-window-title'}"
MinSize="600 400">
<BoxContainer>
<humanoid:SingleMarkingPicker Name="HairPicker" Category="Hair" />
<humanoid:SingleMarkingPicker Name="FacialHairPicker" Category="FacialHair" />
</BoxContainer>
</DefaultWindow>
48 changes: 48 additions & 0 deletions Content.Client/ADT/SlimeHair/SlimeHairWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Content.Shared.Humanoid.Markings;
using Content.Shared.ADT.SlimeHair;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.ADT.SlimeHair;

[GenerateTypedNameReferences]
public sealed partial class SlimeHairWindow : DefaultWindow
{
public Action<(int slot, string id)>? OnHairSelected;
public Action<(int slot, Marking marking)>? OnHairColorChanged;
public Action<int>? OnHairSlotRemoved;
public Action? OnHairSlotAdded;

public Action<(int slot, string id)>? OnFacialHairSelected;
public Action<(int slot, Marking marking)>? OnFacialHairColorChanged;
public Action<int>? OnFacialHairSlotRemoved;
public Action? OnFacialHairSlotAdded;

public SlimeHairWindow()
{
RobustXamlLoader.Load(this);

HairPicker.OnMarkingSelect += args => OnHairSelected!(args);
HairPicker.OnColorChanged += args => OnHairColorChanged!(args);
HairPicker.OnSlotRemove += args => OnHairSlotRemoved!(args);
HairPicker.OnSlotAdd += delegate { OnHairSlotAdded!(); };

FacialHairPicker.OnMarkingSelect += args => OnFacialHairSelected!(args);
FacialHairPicker.OnColorChanged += args => OnFacialHairColorChanged!(args);
FacialHairPicker.OnSlotRemove += args => OnFacialHairSlotRemoved!(args);
FacialHairPicker.OnSlotAdd += delegate { OnFacialHairSlotAdded!(); };
}

public void UpdateState(SlimeHairUiState state)
{
HairPicker.UpdateData(state.Hair, state.Species, state.HairSlotTotal);
FacialHairPicker.UpdateData(state.FacialHair, state.Species, state.FacialHairSlotTotal);

if (!HairPicker.Visible && !FacialHairPicker.Visible)
{
AddChild(new Label { Text = Loc.GetString("magic-mirror-component-activate-user-has-no-hair") });
}
}
}
8 changes: 5 additions & 3 deletions Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void Populate(EntityUid entityUid, List<VendingMachineInventoryEntry> inv
};
var vendComp = _entityManager.GetComponent<VendingMachineComponent>(entityUid); //ADT-Economy
//ADT-Economy-End

if (inventory.Count == 0 && VendingContents.Visible)
{
SearchBar.Visible = false;
Expand Down Expand Up @@ -123,6 +124,7 @@ public void Populate(EntityUid entityUid, List<VendingMachineInventoryEntry> inv

if (!_prototypeManager.TryIndex(entry.ID, out var prototype))
continue;

//ADT-Economy-Start
var price = 0;
if (!vendComp.AllForFree)
Expand All @@ -142,12 +144,12 @@ public void Populate(EntityUid entityUid, List<VendingMachineInventoryEntry> inv
}

var itemName = Identity.Name(dummy, _entityManager);
var itemText = $"{itemName} [{entry.Amount}]";
var itemText = $" [{price}$] {itemName} [{entry.Amount}]"; //ADT-Economy

if (itemText.Length > longestEntry.Length)
longestEntry = itemText;

listData.Add(new VendorItemsListData(prototype.ID, itemText, i, price));
listData.Add(new VendorItemsListData(prototype.ID, itemText, i));
}

VendingContents.PopulateList(listData);
Expand All @@ -163,4 +165,4 @@ private void SetSizeAfterUpdate(int longestEntryLength, int contentCount)
}
}

public record VendorItemsListData(EntProtoId ItemProtoID, string ItemText, int ItemIndex, int price) : ListData;
public record VendorItemsListData(EntProtoId ItemProtoID, string ItemText, int ItemIndex) : ListData;
61 changes: 61 additions & 0 deletions Content.Server/ADT/SlimeHair/SlimeHairComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Shared.DoAfter;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio;

namespace Content.Server.ADT.SlimeHair;

/// <summary>
/// Allows humanoids to change their appearance mid-round.
/// </summary>
[RegisterComponent]
public sealed partial class SlimeHairComponent : Component
{
[DataField]
public DoAfterId? DoAfter;

/// <summary>
/// Magic mirror target, used for validating UI messages.
/// </summary>
[DataField]
public EntityUid? Target;

/// <summary>
/// doafter time required to add a new slot
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan AddSlotTime = TimeSpan.FromSeconds(2);

/// <summary>
/// doafter time required to remove a existing slot
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan RemoveSlotTime = TimeSpan.FromSeconds(2);

/// <summary>
/// doafter time required to change slot
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan SelectSlotTime = TimeSpan.FromSeconds(2);

/// <summary>
/// doafter time required to recolor slot
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan ChangeSlotTime = TimeSpan.FromSeconds(1);

/// <summary>
/// Sound emitted when slots are changed
/// </summary>
[DataField]
public SoundSpecifier ChangeHairSound = new SoundPathSpecifier("/Audio/ADT/slime-hair.ogg")
{
Params = AudioParams.Default.WithVolume(-1f),
};

[DataField("hairAction")]
public EntProtoId Action = "ActionSlimeHair";

[DataField, AutoNetworkedField]
public EntityUid? ActionEntity;

}
30 changes: 30 additions & 0 deletions Content.Server/ADT/SlimeHair/SlimeHairSystem.Abilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Content.Shared.ADT.SlimeHair;
using Robust.Shared.Player;

namespace Content.Server.ADT.SlimeHair;

/// <summary>
/// Allows humanoids to change their appearance mid-round.
/// </summary>
public sealed partial class SlimeHairSystem
{
private void InitializeSlimeAbilities()
{
SubscribeLocalEvent<SlimeHairComponent, SlimeHairActionEvent>(SlimeHairAction);
}

private void SlimeHairAction(EntityUid uid, SlimeHairComponent comp, SlimeHairActionEvent args)
{
if (args.Handled)
return;

if (!TryComp<ActorComponent>(uid, out var actor))
return;

_uiSystem.TryOpenUi(uid, SlimeHairUiKey.Key, actor.Owner);

UpdateInterface(uid, comp);

args.Handled = true;
}
}
Loading

0 comments on commit 642043f

Please sign in to comment.