* init * port better radials * change wizden radials to new radials * minor radial ui refactor * less redundant values * cleanup * minor cleanup + refactor * rename action + base ghost logic * ghost actions update * attack action + better action granting * add missing translation * add debug entity for testing * add radial actions sprites * micro fixes * translations for ghost panel * fix attack action logic * new pet action sprites * better attack target action params * add 2 new stock pets * add translation string for new pets * add additional checks for petting + cute effect for successful petting * add transfer pets to new body logic for cloning and gibbing * add summary for OnMasterGibbed * add stock pets to loadout menu * fix OnMasterGibbed logic and change it to OnMasterShutdown * add localisation support * add logic for shutdown pet component * pets that spawned as loadout automatically linked now * added new pets * cleanup * more pets * ы * фиксы --------- Co-authored-by: SplikZerys <tronezero700@yandex.ru> Co-authored-by: Vigers Ray <60344369+VigersRay@users.noreply.github.com> Co-authored-by: Vigers Ray <vigersray@gmail.com>
86 lines
2.4 KiB
C#
86 lines
2.4 KiB
C#
using Content.Client._Sunrise.UserInterface.Radial;
|
|
using Content.Shared._Sunrise.Pets;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._Sunrise.Pets;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class PetControlBoundUserInterface : BoundUserInterface
|
|
{
|
|
[Dependency] private readonly EntityManager _entityManager = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
|
|
private RadialContainer? _menu;
|
|
|
|
private bool _selected;
|
|
|
|
private ClientPetSystem? _clientPetSystem;
|
|
private SpriteSystem? _spriteSystem;
|
|
|
|
public PetControlBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_clientPetSystem = _entityManager.System<ClientPetSystem>();
|
|
_spriteSystem = _entityManager.System<SpriteSystem>();
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
var pet = _entityManager.GetComponent<PettableOnInteractComponent>(Owner);
|
|
var ourMaster = _playerManager.LocalSession?.AttachedEntity;
|
|
|
|
if (ourMaster != pet.Master)
|
|
return;
|
|
|
|
_menu = new RadialContainer();
|
|
|
|
_menu.Closed += () =>
|
|
{
|
|
if (_selected)
|
|
return;
|
|
|
|
Close();
|
|
};
|
|
|
|
foreach (var controlId in pet.AvailableControls)
|
|
{
|
|
var control = _prototypeManager.Index(controlId);
|
|
var button = _menu.AddButton(control.Name, _spriteSystem?.Frame0(control.Sprite));
|
|
|
|
button.Controller.OnPressed += _ =>
|
|
{
|
|
_selected = true;
|
|
SendPetMessage(control.Event);
|
|
_menu.Close();
|
|
Close();
|
|
};
|
|
}
|
|
|
|
_menu.OpenAttached(Owner);
|
|
}
|
|
|
|
public void SendPetMessage(PetBaseEvent ev)
|
|
{
|
|
// May god forgive us
|
|
// Чтобы реализовать поддержку ивентов вместо сообщений буи мне пришлось использовать систему-пустышку.
|
|
|
|
_clientPetSystem?.RaiseFuckingEvent(Owner, ev);
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
base.Dispose(disposing);
|
|
|
|
if (!disposing)
|
|
return;
|
|
|
|
_menu?.Close();
|
|
}
|
|
}
|