Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Галлюцинации #498

Merged
merged 11 commits into from
Mar 17, 2024
49 changes: 49 additions & 0 deletions Content.Client/ADT/ChangelingEggsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Content.Shared.Drugs;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
using Content.Shared.Alert;
using Content.Client.UserInterface.Systems.DamageOverlays;
using Content.Shared.ADT;
using Content.Shared.Changeling.Components;

namespace Content.Client.Changeling;

public sealed class LingEggsSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
public static string EggKey = "LingEggs";

private void InitializeAlert()
{

SubscribeLocalEvent<LingEggsHolderComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<LingEggsHolderComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<LingEggsHolderComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<LingEggsHolderComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

}

private void OnInit(EntityUid uid, LingEggsHolderComponent component, ComponentInit args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
_alertsSystem.ShowAlert(uid, AlertType.ADTAlertApathy);
}

private void OnShutdown(EntityUid uid, LingEggsHolderComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
_alertsSystem.ClearAlert(uid, AlertType.ADTAlertApathy);
}

private void OnPlayerAttached(EntityUid uid, LingEggsHolderComponent component, LocalPlayerAttachedEvent args)
{
_alertsSystem.ShowAlert(uid, AlertType.ADTAlertApathy);
}

private void OnPlayerDetached(EntityUid uid, LingEggsHolderComponent component, LocalPlayerDetachedEvent args)
{
_alertsSystem.ClearAlert(uid, AlertType.ADTAlertApathy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using Content.Shared.Damage.Prototypes;
using Content.Shared.Popups;
using Robust.Shared.Prototypes;
using Content.Shared.Mind;
using Content.Shared.Alert;
using Robust.Shared.Containers;

namespace Content.Server.Changeling.EntitySystems;

Expand All @@ -15,6 +18,9 @@ public sealed partial class ChangelingEggSystem : EntitySystem
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;

public override void Initialize()
{
Expand All @@ -24,20 +30,20 @@ public override void Initialize()
SubscribeLocalEvent<LingEggsHolderComponent, ComponentShutdown>(OnShutdown);

}
public ProtoId<DamageGroupPrototype> BruteDamageGroup = "Brute";
public ProtoId<DamageGroupPrototype> BruteDamageGroup = "Genetic";
private void OnInit(EntityUid uid, LingEggsHolderComponent component, MapInitEvent args)
{
component.Stomach = ContainerSystem.EnsureContainer<Container>(uid, "stomach");
var damage_burn = new DamageSpecifier(_proto.Index(BruteDamageGroup), component.DamageAmount);
_damageableSystem.TryChangeDamage(uid, damage_burn); /// To be sure that target is dead
var newLing = EnsureComp<ChangelingComponent>(uid);
newLing.EggedBody = true; /// To make egged person into a ling
var selfMessage = Loc.GetString("changeling-eggs-inform");
_popup.PopupEntity(selfMessage, uid, uid, PopupType.LargeCaution); /// Popup
_action.AddAction(uid, ref component.ChangelingHatchActionEntity, component.ChangelingHatchAction);
}
private void OnShutdown(EntityUid uid, LingEggsHolderComponent component, ComponentShutdown args)
{
RemComp<ChangelingComponent>(uid);
_action.RemoveAction(uid, component.ChangelingHatchActionEntity);
//_action.RemoveAction(uid, component.ChangelingHatchActionEntity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
using Content.Shared.Popups;
using Content.Shared.IdentityManagement;
using Robust.Shared.Audio.Systems;
using Content.Server.Emp;
using Robust.Shared.Player;
using Content.Shared.DoAfter;
using Content.Shared.Humanoid;
using Content.Server.Fluids.EntitySystems;
using Robust.Shared.Containers;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Damage;
using Robust.Server.GameObjects;
using Content.Server.Resist;

namespace Content.Server.Changeling.EntitySystems;

Expand All @@ -20,11 +25,14 @@ public sealed partial class LingSlugSystem
[Dependency] private readonly BloodstreamSystem _bloodstreamSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly TransformSystem _transform = default!;

private void InitializeLingAbilities()
{
SubscribeLocalEvent<LingSlugComponent, LingEggActionEvent>(OnLayEggs);
SubscribeLocalEvent<LingSlugComponent, LingEggDoAfterEvent>(OnLayEggsDoAfter);
SubscribeLocalEvent<LingSlugComponent, LingHatchActionEvent>(OnHatch);

}

private void OnLayEggs(EntityUid uid, LingSlugComponent component, LingEggActionEvent args) /// TODO: Заменить на кладку яиц при ударе.
Expand Down Expand Up @@ -90,18 +98,70 @@ private void OnLayEggsDoAfter(EntityUid uid, LingSlugComponent component, LingEg
else
{
var holderComp = EnsureComp<LingEggsHolderComponent>(target);

var lingComp = EnsureComp<ChangelingComponent>(target);
var xform = Transform(target);
var selfMessage = Loc.GetString("changeling-eggs-self-success", ("target", Identity.Entity(target, EntityManager)));
_popup.PopupEntity(selfMessage, uid, uid, PopupType.MediumCaution);

component.EggsLaid = true;
component.EggLing = target;

holderComp.ChangelingHatchAction = component.HatchAction;
lingComp.AbsorbedDnaModifier = component.AbsorbedDnaModifier;

_transform.SetParent(uid, xform.ParentUid);
_transform.SetCoordinates(uid, xform.Coordinates);

ContainerSystem.Insert(uid, holderComp.Stomach);
RemComp<CanEscapeInventoryComponent>(uid);
if (component.Spread == false)
_action.AddAction(uid, ref holderComp.ChangelingHatchActionEntity, holderComp.ChangelingHatchAction);
else
_action.AddAction(target, ref holderComp.ChangelingHatchActionEntity, holderComp.ChangelingHatchAction);

_action.RemoveAction(uid, component.LayEggsActionEntity); /// Яйца откладываются только один раз

return;
}
}
//public ProtoId<DamageGroupPrototype> BruteDamageGroup = "Brute";

private void OnHatch(EntityUid uid, LingSlugComponent component, LingHatchActionEvent args) /// TODO: Сделать из акшона автоматическую систему!
{
if (args.Handled)
return;

if (!component.EggsReady && component.EggLing != null)
{
///_mobState.ChangeMobState(uid, MobState.Critical);

var othersMessage = Loc.GetString("changeling-egg-others", ("user", Identity.Entity(component.EggLing.Value, EntityManager)));
_popup.PopupEntity(othersMessage, component.EggLing.Value, Filter.PvsExcept(uid), true, PopupType.MediumCaution);

var selfMessage = Loc.GetString("changeling-egg-self");
_popup.PopupEntity(selfMessage, uid, uid, PopupType.MediumCaution);

component.EggsReady = !component.EggsReady;

args.Handled = true;
}

else
{
//RemComp<LingEggsHolderComponent>(uid);

if (SpawnLingMonkey(uid, component))
{
if (component.EggLing != null)
{
var damage_brute = new DamageSpecifier(_proto.Index(BruteDamageGroup), component.GibDamage);
_damageableSystem.TryChangeDamage(component.EggLing.Value, damage_brute);
_damageableSystem.TryChangeDamage(args.Performer, damage_brute);

args.Handled = true;
}
}
}
}

}
86 changes: 43 additions & 43 deletions Content.Server/ADT/Changeling/EntitySystems/ChangelingSlugSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
using Content.Shared.Mobs.Systems;
using Content.Shared.Humanoid;
using Content.Shared.IdentityManagement;
using Content.Server.Polymorph.Systems;
using Content.Shared.Polymorph;
using Content.Shared.Actions;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Containers;
using Content.Shared.Alert;
using Content.Shared.Tag;
using Content.Shared.StatusEffect;
using Content.Shared.Chemistry.Components;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Movement.Systems;
using Content.Shared.Damage.Systems;
using Content.Shared.Damage;
using Content.Shared.Gibbing.Systems;
using Content.Server.Polymorph.Systems;
using Content.Shared.Mind;
using Content.Shared.DoAfter;
using Robust.Shared.Prototypes;
Expand All @@ -32,11 +31,12 @@ public sealed partial class LingSlugSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PolymorphSystem _polymorph = default!;
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly PolymorphSystem _polymorph = default!;

public override void Initialize()
{
Expand All @@ -59,44 +59,6 @@ private void OnMapInit(EntityUid uid, LingSlugComponent component, MapInitEvent

public ProtoId<DamageGroupPrototype> BruteDamageGroup = "Brute";

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

var query = EntityQueryEnumerator<LingSlugComponent>();
while (query.MoveNext(out var uid, out var ling))
{
if (ling.EggsLaid) /// TODO: Зачем я вообще сделал это через Update?
{
if (ling.EggLing != null)
{
var oldUid = uid;

if (ling.Spread == false)
{
if (_mindSystem.TryGetMind(uid, out var mindId, out var mind))
_mindSystem.TransferTo(mindId, ling.EggLing.Value, mind: mind);
}
else
{
continue;
}

if (!_entityManager.TryGetComponent<BloodstreamComponent>(oldUid, out var bloodstream))
return;

var toxinInjection = new Solution(ling.ChemicalToxin, ling.ToxinAmount);
_bloodstreamSystem.TryAddToChemicals(oldUid, toxinInjection, bloodstream);

ling.EggsLaid = false;

return;
}
}
}
}


private bool LayEggs(EntityUid uid, EntityUid target, LingSlugComponent component)
{
if (!TryComp<MetaDataComponent>(target, out var metaData))
Expand Down Expand Up @@ -128,4 +90,42 @@ private bool LayEggs(EntityUid uid, EntityUid target, LingSlugComponent componen
_doAfter.TryStartDoAfter(doAfter);
return true;
}

public const string LingMonkeyId = "MobMonkeyChangeling";

public bool SpawnLingMonkey(EntityUid uid, LingSlugComponent component)
{
if (component.EggLing != null)
{
var slug = Spawn(LingMonkeyId, Transform(component.EggLing.Value).Coordinates);

var newLingComponent = EnsureComp<ChangelingComponent>(slug);
newLingComponent.LesserFormActive = true;
newLingComponent.AbsorbedDnaModifier = component.AbsorbedDnaModifier;


_action.AddAction(slug, ref newLingComponent.ChangelingLesserFormActionEntity, newLingComponent.ChangelingLesserFormAction);


newLingComponent.StoredDNA = new List<PolymorphHumanoidData>(); /// Создание нового ДНК списка
if (component.EggLing != null)
{
var newHumanoidData = _polymorph.TryRegisterPolymorphHumanoidData(component.EggLing.Value);
if (newHumanoidData == null)
return false;
newLingComponent.StoredDNA.Add(newHumanoidData.Value);
}
else
return false;

if (_mindSystem.TryGetMind(uid, out var mindId, out var mind))
_mindSystem.TransferTo(mindId, slug, mind: mind);
if (mind != null)
mind.PreventGhosting = false;
return true;

}
else
return false;
}
}
Loading
Loading