2023-05-01 15:05:43 +06:00
|
|
|
|
using Content.Shared.ActionBlocker;
|
|
|
|
|
|
using Content.Shared.Actions;
|
2023-05-11 01:44:25 +06:00
|
|
|
|
using Content.Shared.Examine;
|
2023-05-01 15:05:43 +06:00
|
|
|
|
using Content.Shared.Hands.EntitySystems;
|
|
|
|
|
|
using Content.Shared.Popups;
|
|
|
|
|
|
using Content.Shared.Verbs;
|
2024-01-28 18:37:24 +07:00
|
|
|
|
using Content.Shared._White.Events;
|
2023-05-01 15:05:43 +06:00
|
|
|
|
using Robust.Server.GameObjects;
|
2024-01-13 12:24:00 +03:00
|
|
|
|
using Robust.Shared.Player;
|
2023-05-01 15:05:43 +06:00
|
|
|
|
|
2024-01-28 18:18:54 +07:00
|
|
|
|
namespace Content.Server._White.Other.CustomFluffSystems.merkka;
|
2023-05-01 15:05:43 +06:00
|
|
|
|
|
|
|
|
|
|
public sealed class EarsSpawnSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
|
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
|
|
|
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
SubscribeLocalEvent<EarsSpawnComponent, GetVerbsEvent<AlternativeVerb>>(AddSummonVerb);
|
|
|
|
|
|
SubscribeLocalEvent<EarsSpawnComponent, GetItemActionsEvent>(GetSummonAction);
|
|
|
|
|
|
SubscribeLocalEvent<EarsSpawnComponent, SummonActionEarsEvent>(OnSummon);
|
2023-05-11 01:44:25 +06:00
|
|
|
|
SubscribeLocalEvent<EarsSpawnComponent, SummonActionCatEvent>(OnSummonCat);
|
|
|
|
|
|
SubscribeLocalEvent<EarsSpawnComponent, ExaminedEvent>(OnExamined);
|
2023-05-01 15:05:43 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private const string Ears = "ClothingHeadHatCatEars";
|
2023-05-11 01:44:25 +06:00
|
|
|
|
private const string Cat = "MobCatMurka";
|
2023-05-01 15:05:43 +06:00
|
|
|
|
private const string UserNeededKey = "merkkaa";
|
|
|
|
|
|
|
2023-05-11 01:44:25 +06:00
|
|
|
|
private void OnExamined(EntityUid u, EarsSpawnComponent comp, ExaminedEvent ev)
|
|
|
|
|
|
{
|
|
|
|
|
|
ev.PushMarkup($"Зарядов для ушей: {comp.CatEarsUses}\n" +
|
|
|
|
|
|
$"Зарядов для создания кота: {comp.СatSpawnUses}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-01 15:05:43 +06:00
|
|
|
|
private void AddSummonVerb(EntityUid uid, EarsSpawnComponent component, GetVerbsEvent<AlternativeVerb> args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!args.CanInteract || !args.CanAccess)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
AlternativeVerb verb = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Act = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
AttemptSummon(component, args.User);
|
|
|
|
|
|
},
|
|
|
|
|
|
Text = Loc.GetString("summon cat ears"),
|
|
|
|
|
|
Priority = 2
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-05-11 01:44:25 +06:00
|
|
|
|
AlternativeVerb verbCat = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Act = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
AttemptSummonCat(component, args.User);
|
|
|
|
|
|
},
|
|
|
|
|
|
Text = Loc.GetString("summon cat"),
|
|
|
|
|
|
Priority = 3
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-05-01 15:05:43 +06:00
|
|
|
|
args.Verbs.Add(verb);
|
2023-05-11 01:44:25 +06:00
|
|
|
|
args.Verbs.Add(verbCat);
|
2023-05-01 15:05:43 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnSummon(EntityUid uid, EarsSpawnComponent component, SummonActionEarsEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
AttemptSummon(component, args.Performer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 01:44:25 +06:00
|
|
|
|
private void OnSummonCat(EntityUid uid, EarsSpawnComponent component, SummonActionCatEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
AttemptSummonCat(component, args.Performer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-01 15:05:43 +06:00
|
|
|
|
private void AttemptSummon(EarsSpawnComponent component, EntityUid user)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_blocker.CanInteract(user, component.Owner))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (TryComp<ActorComponent>(user, out var actorComponent))
|
|
|
|
|
|
{
|
|
|
|
|
|
var userKey = actorComponent.PlayerSession.Name;
|
|
|
|
|
|
if (userKey != UserNeededKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
_popupSystem.PopupEntity("Вы не являетесь потомком кошко-богини.", user, PopupType.Medium);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 01:44:25 +06:00
|
|
|
|
if (component.CatEarsUses == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_popupSystem.PopupEntity("Больше нет зарядов!", user, PopupType.Medium);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SpawnEars(user, component);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AttemptSummonCat(EarsSpawnComponent component, EntityUid user)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_blocker.CanInteract(user, component.Owner))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (TryComp<ActorComponent>(user, out var actorComponent))
|
|
|
|
|
|
{
|
|
|
|
|
|
var userKey = actorComponent.PlayerSession.Name;
|
|
|
|
|
|
if (userKey != UserNeededKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
_popupSystem.PopupEntity("Вы не являетесь потомком кошко-богини.", user, PopupType.Medium);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (component.СatSpawnUses == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_popupSystem.PopupEntity("Больше нет зарядов!", user, PopupType.Medium);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SpawnCat(user, component);
|
2023-05-01 15:05:43 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 01:44:25 +06:00
|
|
|
|
private void SpawnEars(EntityUid player, EarsSpawnComponent comp)
|
2023-05-01 15:05:43 +06:00
|
|
|
|
{
|
|
|
|
|
|
var transform = CompOrNull<TransformComponent>(player)?.Coordinates;
|
|
|
|
|
|
|
|
|
|
|
|
if (transform == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var ears = _entityManager.SpawnEntity(Ears, transform.Value);
|
|
|
|
|
|
_handsSystem.PickupOrDrop(player, ears);
|
2023-05-11 01:44:25 +06:00
|
|
|
|
comp.CatEarsUses--;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SpawnCat(EntityUid player, EarsSpawnComponent comp)
|
|
|
|
|
|
{
|
|
|
|
|
|
var transform = CompOrNull<TransformComponent>(player)?.Coordinates;
|
|
|
|
|
|
|
|
|
|
|
|
if (transform == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
_entityManager.SpawnEntity(Cat, transform.Value);
|
|
|
|
|
|
comp.СatSpawnUses--;
|
2023-05-01 15:05:43 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void GetSummonAction(EntityUid uid, EarsSpawnComponent component, GetItemActionsEvent args)
|
|
|
|
|
|
{
|
2023-05-11 01:44:25 +06:00
|
|
|
|
args.AddAction(ref component.SummonActionEntityEars, component.SummonActionEars);
|
|
|
|
|
|
args.AddAction(ref component.SummonActionEntityCat, component.SummonActionCat);
|
2023-05-01 15:05:43 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|