Skip to content

Commit

Permalink
[✔]
Browse files Browse the repository at this point in the history
  • Loading branch information
NameLunar committed Jan 3, 2025
1 parent 1d7c1b3 commit 0ca4753
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 172 deletions.
43 changes: 22 additions & 21 deletions Content.Server/ADT/Abilities/XenoQueen/XenoQueenComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

Expand All @@ -9,43 +10,43 @@ namespace Content.Server.Abilities.XenoQueen
[RegisterComponent]
public sealed partial class XenoQueenComponent : Component
{
/// <summary>
/// Whether this component is active or not.
/// </summarY>
[DataField("enabled")]
public bool Enabled = true;

/// <summary>
/// The wall prototype to use.
/// </summary>
[DataField]
public bool XenoCreatTurretEnabled = true;

//
[DataField("wallPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string XenoTurret = "WeaponTurretXeno";

[DataField("xenoTurretAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? XenoTurretAction = "ActionXenoQueenTurret";

[DataField("xenoTurretActionEntity")] public EntityUid? XenoTurretActionEntity;

//Призывы
[DataField]
// Призывы
public EntityUid? XenoTurretActionEntity;
public EntityUid? ActionSpawnXenoBurrower;

[DataField]
public EntityUid? ActionSpawnXenoDrone;
public EntityUid? ActionSpawnXenoRunner;
public EntityUid? ActionSpawnXenoSpitter;
public EntityUid? ActionSpawnXenoPraetorian;
public EntityUid? ActionSpawnXenoRavager;
public EntityUid? ActionSpawnXenoQueen;

// Регенрация очков
[DataField]
public EntityUid? ActionSpawnXenoRunner;
public bool Regenetarion = true; // Можно ли регенерировать очки.

[DataField]
public EntityUid? ActionSpawnXenoSpitter;
public float RegenDelay = 60f; // Секунды до регена. Используется в счетчике

[ViewVariables]
public float Accumulator = 0f; // Сам счетчик 0.000000

[DataField]
public EntityUid? ActionSpawnXenoPraetorian;
public FixedPoint2 BloobCount = 20; // Очки. Начальные очки равны 20

[DataField]
public EntityUid? ActionSpawnXenoRavager;
public FixedPoint2 MaxBloobCount = 150; // Максимальыне количество очков

[DataField]
public EntityUid? ActionSpawnXenoQueen;
public int RegenBloobCount = 3; // Реген очков в минуту
}
}
100 changes: 47 additions & 53 deletions Content.Server/ADT/Abilities/XenoQueen/XenoQueenSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
using Content.Shared.Magic.Events;
using Content.Shared.Physics;
using Robust.Shared.Containers;
using Robust.Shared.Spawners;
using Robust.Shared.Map;
using Robust.Shared.Random;
using System.Numerics;
using Content.Shared.Storage;
using Content.Shared.ADT.Events;
using Robust.Shared.Network;
using Content.Shared.Magic;
using Content.Shared.FixedPoint;

namespace Content.Server.Abilities.XenoQueen
{
Expand All @@ -30,15 +29,47 @@ public sealed class XenoQueenSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<XenoQueenComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<XenoQueenComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<XenoQueenComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<XenoQueenComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<XenoQueenComponent, InvisibleWallActionEvent>(OnCreateTurret);
SubscribeLocalEvent<XenoQueenComponent, SpawnXenoQueenEvent> (OnWorldSpawn);
SubscribeLocalEvent<XenoQueenComponent, SpawnXenoQueenEvent>(OnWorldSpawn);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<XenoQueenComponent>();
while (query.MoveNext(out var uid, out var component) && component.Regenetarion) // Костыль, но супер рабочий)
{
if (component.BloobCount >= component.MaxBloobCount)
{
component.Accumulator = 0f;
continue;
}

component.Accumulator += frameTime; // 0.000001

if (component.Accumulator <= component.RegenDelay)
continue;

component.Accumulator -= component.RegenDelay; // component.Accumulator = 0f;
if (component.BloobCount < component.MaxBloobCount)
{
ChangePowerAmount(uid, component.RegenBloobCount, component);
}
}
}
public void ChangePowerAmount(EntityUid uid, FixedPoint2 amount, XenoQueenComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

if (component.BloobCount + amount < 0)
return;

component.BloobCount += amount;
//_alerts.ShowAlert(uid, _proto.Index(component.Alert), (short)Math.Clamp(Math.Round(component.Power.Float()), 0, 5));
}
private void OnMapInit(EntityUid uid, XenoQueenComponent component, MapInitEvent args)
{
Expand All @@ -49,7 +80,7 @@ private void OnMapInit(EntityUid uid, XenoQueenComponent component, MapInitEvent
_actionsSystem.AddAction(uid, ref component.ActionSpawnXenoSpitter, "ActionSpawnMobXenoSpitter");
_actionsSystem.AddAction(uid, ref component.ActionSpawnXenoPraetorian, "ActionSpawnMobXenoPraetorian");
_actionsSystem.AddAction(uid, ref component.ActionSpawnXenoRavager, "ActionSpawnMobXenoRavager");
//_actionsSystem.AddAction(uid, ref component.ActionSpawnXenoQueen, "ActionSpawnMobXenoQueen");
_actionsSystem.AddAction(uid, ref component.ActionSpawnXenoQueen, "ActionSpawnMobXenoQueen");
}
private void OnShutdown(EntityUid uid, XenoQueenComponent component, ComponentShutdown args)
{
Expand All @@ -60,11 +91,11 @@ private void OnShutdown(EntityUid uid, XenoQueenComponent component, ComponentSh
_actionsSystem.RemoveAction(uid, component.ActionSpawnXenoSpitter);
_actionsSystem.RemoveAction(uid, component.ActionSpawnXenoPraetorian);
_actionsSystem.RemoveAction(uid, component.ActionSpawnXenoRavager);
//_actionsSystem.RemoveAction(uid, component.ActionSpawnXenoQueen);
_actionsSystem.RemoveAction(uid, component.ActionSpawnXenoQueen);
}
private void OnCreateTurret(EntityUid uid, XenoQueenComponent component, InvisibleWallActionEvent args)
{
if (!component.Enabled)
if (!component.XenoCreatTurretEnabled)
return;

if (_container.IsEntityOrParentInContainer(uid))
Expand Down Expand Up @@ -92,57 +123,20 @@ private void OnCreateTurret(EntityUid uid, XenoQueenComponent component, Invisib
args.Handled = true;
}
// Spawn Tipo
private void OnWorldSpawn(EntityUid uid, XenoQueenComponent component, SpawnXenoQueenEvent args)
private void OnWorldSpawn(EntityUid uid, XenoQueenComponent component, SpawnXenoQueenEvent args) // SpawnXenoQueenEvent
{
if (args.Handled || !PassesSpellPrerequisites(args.Action, args.Performer))
return;

var targetMapCoords = args.Target;

WorldSpawnSpellHelper(args.Prototypes, targetMapCoords, args.Performer, args.Lifetime, args.Offset);
Speak(args);
args.Handled = true;
}
// Help
private void WorldSpawnSpellHelper(List<EntitySpawnEntry> entityEntries, EntityCoordinates entityCoords, EntityUid performer, float? lifetime, Vector2 offsetVector2)
{
var getProtos = EntitySpawnCollection.GetSpawns(entityEntries, _random);

var offsetCoords = entityCoords;
foreach (var proto in getProtos)
{
SpawnSpellHelper(proto, offsetCoords, performer, lifetime);
offsetCoords = offsetCoords.Offset(offsetVector2);
}
}
// Help 2
private void SpawnSpellHelper(string? proto, EntityCoordinates position, EntityUid performer, float? lifetime = null, bool preventCollide = false)
{
if (!_net.IsServer)
return;

var ent = Spawn(proto, position.SnapToGrid(EntityManager, _mapManager));

if (lifetime != null)
if (component.BloobCount > args.Cost)
{
var comp = EnsureComp<TimedDespawnComponent>(ent);
comp.Lifetime = lifetime.Value;
component.BloobCount -= args.Cost.Value;
Spawn(args.Prototypes[0].PrototypeId, Transform(uid).Coordinates);
Speak(args);
args.Handled = true;
}

if (preventCollide)
else
{
var comp = EnsureComp<PreventCollideComponent>(ent);
comp.Uid = performer;
_popupSystem.PopupEntity(Loc.GetString("queen-no-bloob-count", ("CountBloob", args.Cost.GetValueOrDefault() - component.BloobCount)), uid);
}
}
//
private bool PassesSpellPrerequisites(EntityUid spell, EntityUid performer)
{
var ev = new BeforeCastSpellEvent(performer);
RaiseLocalEvent(spell, ref ev);
return !ev.Cancelled;
}
//
private void Speak(BaseActionEvent args)
{
if (args is not ISpeakSpell speak || string.IsNullOrWhiteSpace(speak.Speech))
Expand Down
37 changes: 0 additions & 37 deletions Content.Server/ADT/Events/SpawnXenoQueenEvent.cs

This file was deleted.

18 changes: 18 additions & 0 deletions Content.Shared/ADT/Actions/SpawnXenoQueenEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Content.Shared.Actions;
using Content.Shared.Storage;
using Content.Shared.Magic;

namespace Content.Shared.ADT.Events;

// TODO: This class needs combining with InstantSpawnSpellEvent
public sealed partial class SpawnXenoQueenEvent : WorldTargetActionEvent, ISpeakSpell
{
[DataField]
public List<EntitySpawnEntry> Prototypes = new();

[DataField]
public string? Speech { get; private set; }

[DataField]
public int? Cost { get; private set; }
}
19 changes: 10 additions & 9 deletions Resources/Locale/ru-RU/ADT/prototypes/Actions/XenoQueen.ftl
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
ent-ActionXenoQeenTurret = Создать ксено турель.
ent-ActionXenoQeenTurret = Создать ксено турель. [color=green]25[/color]
.desc = Создаёт перед вами ксену турель, если хватает места.
create-turret-failed = Найдите другое место.
create-turret = Арргхсс. Шшшшш!
ent-ActionSpawnMobXenoSpitter = Призвать Плевальщик
ent-ActionSpawnMobXenoSpitter = Призвать Плевальщик [color=green]20[/color]
.desc = Родите Плевальщика, который будет плеваться!
ent-ActionSpawnMobXenoPraetorian = Призвать Преторианеца
ent-ActionSpawnMobXenoPraetorian = Призвать Преторианеца [color=green]50[/color]
.desc = Родите Преторианеца, который будет сражаться за вас!
ent-ActionSpawnMobXenoDrone = Просто Дрон. Кому он нужен?
ent-ActionSpawnMobXenoDrone = Просто Дрон [color=green]30[/color]. Кому он нужен?
.desc = Родите рабочего, Дрон.
ent-ActionSpawnMobXenoRavager = Призвать Разрушителя
ent-ActionSpawnMobXenoRavager = Призвать Разрушителя [color=green]80[/color]
.desc = Родите [color=red]смерть[/color] во плоти!
ent-ActionSpawnMobXenoRunner = Призвать Бегуна
ent-ActionSpawnMobXenoRunner = Призвать Бегуна [color=green]40[/color]
.desc = Родите самую быструю личинку!
ent-ActionSpawnMobXenoBurrower = Призвать рабочего
ent-ActionSpawnMobXenoBurrower = Призвать рабочего [color=green]10[/color]
.desc = Стандартный ксено.
ent-ActionSpawnMobXenoQueen = Призвать [color=violet]Королеву[/color].
.desc = [color=red]Новое потомство! Новое поколение! Эволюция![/color]
ent-ActionSpawnMobXenoQueen = Призвать [color=violet]Королеву[/color] [color=green]100[/color]
.desc = [color=red]Новое потомство! Новое поколение! Эволюция![/color]
queen-no-bloob-count = Недостаточно {$CountBloob} очков.
Loading

0 comments on commit 0ca4753

Please sign in to comment.