перенос файлов сервера из папки White в _White
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server._White.Other.CustomFluffSystems.Pets;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class PetSummonComponent : Component
|
||||
{
|
||||
[DataField("petSummonAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string PetSummonAction = "PetSummonAction";
|
||||
|
||||
[DataField("petGhostSummonAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string PetGhostSummonAction = "PetGhostSummonAction";
|
||||
|
||||
[DataField("petSummonActionEntity")] public EntityUid? PetSummonActionEntity;
|
||||
[DataField("petGhostSummonActionEntity")] public EntityUid? PetGhostSummonActionEntity;
|
||||
|
||||
public int UsesLeft = 10;
|
||||
|
||||
public EntityUid? SummonedEntity;
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.White.Events;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.Other.CustomFluffSystems.Pets;
|
||||
|
||||
public sealed class PetSummonSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
private IReadOnlyDictionary<string, string> MobMap = new Dictionary<string, string>()
|
||||
{
|
||||
{ "Wanderer_", "KommandantPetSpider" },
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PetSummonComponent, GetItemActionsEvent>(GetSummonAction);
|
||||
SubscribeLocalEvent<PetSummonComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<PetSummonComponent, GetVerbsEvent<AlternativeVerb>>(AddSummonVerb);
|
||||
SubscribeLocalEvent<PetSummonComponent, PetSummonActionEvent>(OnSummon);
|
||||
SubscribeLocalEvent<PetSummonComponent, PetGhostSummonActionEvent>(OnGhostSummon);
|
||||
}
|
||||
|
||||
private void OnGhostSummon(EntityUid uid, PetSummonComponent component, PetGhostSummonActionEvent args)
|
||||
{
|
||||
AttemptSummon(component, args.Performer, true);
|
||||
}
|
||||
|
||||
private void OnSummon(EntityUid uid, PetSummonComponent component, PetSummonActionEvent args)
|
||||
{
|
||||
AttemptSummon(component, args.Performer, false);
|
||||
}
|
||||
|
||||
private void AddSummonVerb(EntityUid uid, PetSummonComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanInteract || !args.CanAccess)
|
||||
return;
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
AttemptSummon(component, args.User, false);
|
||||
},
|
||||
Text = "Призвать питомца",
|
||||
Priority = 2
|
||||
};
|
||||
|
||||
AlternativeVerb ghostVerb = new()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
AttemptSummon(component, args.User, true);
|
||||
},
|
||||
Text = "Призвать питомца-призрак",
|
||||
Priority = 2
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
args.Verbs.Add(ghostVerb);
|
||||
}
|
||||
|
||||
private void OnExamine(EntityUid uid, PetSummonComponent component, ExaminedEvent args)
|
||||
{
|
||||
args.PushMarkup($"Осталось призывов: {component.UsesLeft}");
|
||||
}
|
||||
|
||||
private void AttemptSummon(PetSummonComponent component, EntityUid user, bool ghostRole)
|
||||
{
|
||||
if (!_blocker.CanInteract(user, component.Owner))
|
||||
return;
|
||||
|
||||
string? mobProto = null;
|
||||
if (TryComp<ActorComponent>(user, out var actorComponent))
|
||||
{
|
||||
var userKey = actorComponent.PlayerSession.Name;
|
||||
|
||||
if (!MobMap.TryGetValue(userKey, out var proto))
|
||||
{
|
||||
_popupSystem.PopupEntity("Вы не достойны", user, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
mobProto = proto;
|
||||
}
|
||||
|
||||
if (component.UsesLeft == 0)
|
||||
{
|
||||
_popupSystem.PopupEntity("Больше нет зарядов!", user, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.SummonedEntity != null)
|
||||
{
|
||||
if (!TryComp<MobStateComponent>(component.SummonedEntity, out var mobState))
|
||||
{
|
||||
component.SummonedEntity = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mobState.CurrentState is MobState.Dead or MobState.Invalid)
|
||||
component.SummonedEntity = null;
|
||||
else
|
||||
{
|
||||
_popupSystem.PopupEntity("Ваш питомец уже призван", user, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (mobProto != null)
|
||||
SummonPet(user, component, mobProto, ghostRole);
|
||||
}
|
||||
|
||||
private void SummonPet(EntityUid user, PetSummonComponent component, string mobProto, bool ghostRole)
|
||||
{
|
||||
var transform = CompOrNull<TransformComponent>(user)?.Coordinates;
|
||||
|
||||
if (transform == null)
|
||||
return;
|
||||
|
||||
var entity = _entityManager.SpawnEntity(mobProto, transform.Value);
|
||||
component.UsesLeft--;
|
||||
component.SummonedEntity = entity;
|
||||
|
||||
if (ghostRole)
|
||||
SetupGhostRole(entity, user);
|
||||
else
|
||||
RemComp<GhostRoleComponent>(entity);
|
||||
}
|
||||
|
||||
private void SetupGhostRole(EntityUid entity, EntityUid user)
|
||||
{
|
||||
EnsureComp<GhostTakeoverAvailableComponent>(entity);
|
||||
|
||||
if (!TryComp<GhostRoleComponent>(entity, out var ghostRole))
|
||||
return;
|
||||
|
||||
var meta = MetaData(user);
|
||||
ghostRole.RoleName = $"Питомец {meta.EntityName}";
|
||||
ghostRole.RoleDescription = $"Следуйте за хозяином - {meta.EntityName} и выполняйте его приказы";
|
||||
ghostRole.RoleRules = $"Вы должны до самого конца следовать за своим хозяином - {meta.EntityName} и послушно выполнять его приказы, иначе можете быть уничтожены.";
|
||||
}
|
||||
|
||||
private void GetSummonAction(EntityUid uid, PetSummonComponent component, GetItemActionsEvent args)
|
||||
{
|
||||
args.AddAction(ref component.PetSummonActionEntity, component.PetSummonAction);
|
||||
args.AddAction(ref component.PetGhostSummonActionEntity, component.PetGhostSummonAction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server._White.Other.CustomFluffSystems.merkka;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class CustomCatExamineComponent : Component
|
||||
{
|
||||
public string? CatOwner;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Examine;
|
||||
using Robust.Server.Player;
|
||||
|
||||
namespace Content.Server._White.Other.CustomFluffSystems.merkka;
|
||||
|
||||
public sealed class CustomCatExamineSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<CustomCatExamineComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid u, CustomCatExamineComponent comp, ExaminedEvent ev)
|
||||
{
|
||||
GetOwner(comp);
|
||||
|
||||
if (comp.CatOwner == null)
|
||||
return;
|
||||
|
||||
ev.PushMarkup($"Владелец: {comp.CatOwner}");
|
||||
}
|
||||
|
||||
private void GetOwner(CustomCatExamineComponent comp)
|
||||
{
|
||||
if (!_playerManager.TryGetSessionByUsername("merkkaa", out var player))
|
||||
return;
|
||||
|
||||
if (!TryComp<MetaDataComponent>(player.AttachedEntity, out var meta))
|
||||
return;
|
||||
|
||||
comp.CatOwner = meta.EntityName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server._White.Other.CustomFluffSystems.merkka;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class EarsSpawnComponent : Component
|
||||
{
|
||||
[DataField("summonActionEars", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string SummonActionEars = "ActionEarsSummon";
|
||||
|
||||
[DataField("summonActionCat", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string SummonActionCat = "ActionCatSummon";
|
||||
|
||||
[DataField("summonActionEntityEars")] public EntityUid? SummonActionEntityEars;
|
||||
[DataField("summonActionEntityCat")] public EntityUid? SummonActionEntityCat;
|
||||
|
||||
public int CatEarsUses = 30;
|
||||
public int СatSpawnUses = 20;
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.White.Events;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.Other.CustomFluffSystems.merkka;
|
||||
|
||||
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);
|
||||
SubscribeLocalEvent<EarsSpawnComponent, SummonActionCatEvent>(OnSummonCat);
|
||||
SubscribeLocalEvent<EarsSpawnComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private const string Ears = "ClothingHeadHatCatEars";
|
||||
private const string Cat = "MobCatMurka";
|
||||
private const string UserNeededKey = "merkkaa";
|
||||
|
||||
private void OnExamined(EntityUid u, EarsSpawnComponent comp, ExaminedEvent ev)
|
||||
{
|
||||
ev.PushMarkup($"Зарядов для ушей: {comp.CatEarsUses}\n" +
|
||||
$"Зарядов для создания кота: {comp.СatSpawnUses}");
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
AlternativeVerb verbCat = new()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
AttemptSummonCat(component, args.User);
|
||||
},
|
||||
Text = Loc.GetString("summon cat"),
|
||||
Priority = 3
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
args.Verbs.Add(verbCat);
|
||||
}
|
||||
|
||||
private void OnSummon(EntityUid uid, EarsSpawnComponent component, SummonActionEarsEvent args)
|
||||
{
|
||||
AttemptSummon(component, args.Performer);
|
||||
}
|
||||
|
||||
private void OnSummonCat(EntityUid uid, EarsSpawnComponent component, SummonActionCatEvent args)
|
||||
{
|
||||
AttemptSummonCat(component, args.Performer);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void SpawnEars(EntityUid player, EarsSpawnComponent comp)
|
||||
{
|
||||
var transform = CompOrNull<TransformComponent>(player)?.Coordinates;
|
||||
|
||||
if (transform == null)
|
||||
return;
|
||||
|
||||
var ears = _entityManager.SpawnEntity(Ears, transform.Value);
|
||||
_handsSystem.PickupOrDrop(player, ears);
|
||||
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--;
|
||||
}
|
||||
|
||||
private static void GetSummonAction(EntityUid uid, EarsSpawnComponent component, GetItemActionsEvent args)
|
||||
{
|
||||
args.AddAction(ref component.SummonActionEntityEars, component.SummonActionEars);
|
||||
args.AddAction(ref component.SummonActionEntityCat, component.SummonActionCat);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user