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

Мини-апдейт #493

Merged
merged 14 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Content.Server/ADT/Changeling/EntitySystems/ChangelingEggSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Content.Shared.Changeling.Components;
using Content.Server.Actions;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Popups;
using Robust.Shared.Prototypes;

namespace Content.Server.Changeling.EntitySystems;

public sealed partial class ChangelingEggSystem : EntitySystem
{
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<LingEggsHolderComponent, MapInitEvent>(OnInit);
SubscribeLocalEvent<LingEggsHolderComponent, ComponentShutdown>(OnShutdown);

}
public ProtoId<DamageGroupPrototype> BruteDamageGroup = "Brute";
private void OnInit(EntityUid uid, LingEggsHolderComponent component, MapInitEvent args)
{
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void InitializeLingAbilities()
SubscribeLocalEvent<LingSlugComponent, LingEggDoAfterEvent>(OnLayEggsDoAfter);
}

private void OnLayEggs(EntityUid uid, LingSlugComponent component, LingEggActionEvent args)
private void OnLayEggs(EntityUid uid, LingSlugComponent component, LingEggActionEvent args) /// TODO: Заменить на кладку яиц при ударе.
{
if (args.Handled)
return;
Expand Down Expand Up @@ -89,14 +89,16 @@ private void OnLayEggsDoAfter(EntityUid uid, LingSlugComponent component, LingEg

else
{
EnsureComp<LingEggsHolderComponent>(target);
var holderComp = EnsureComp<LingEggsHolderComponent>(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;

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

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,21 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<LingSlugComponent>();
while (query.MoveNext(out var uid, out var ling))
{
if (ling.EggsLaid)
if (ling.EggsLaid) /// TODO: Зачем я вообще сделал это через Update?
{
if (ling.EggLing != null)
{
var oldUid = uid;
var newLing = EnsureComp<ChangelingComponent>(ling.EggLing.Value);
newLing.EggedBody = true;
_action.AddAction(ling.EggLing.Value, ref newLing.ChangelingHatchActionEntity, newLing.ChangelingHatchAction);

if (_mindSystem.TryGetMind(uid, out var mindId, out var mind))
_mindSystem.TransferTo(mindId, ling.EggLing.Value, mind: mind);
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Content.Shared.Eye.Blinding.Systems;
using Content.Server.Destructible;
using Content.Shared.Polymorph;
using Content.Server.Ghost.Components;

namespace Content.Server.Changeling.EntitySystems;

Expand Down Expand Up @@ -694,6 +695,8 @@ private void OnStasisDeathAction(EntityUid uid, ChangelingComponent component, S

args.Handled = true;

RemComp<GhostOnMoveComponent>(uid);

var damage_burn = new DamageSpecifier(_proto.Index(BurnDamageGroup), component.StasisDeathDamageAmount);
_damageableSystem.TryChangeDamage(uid, damage_burn); /// Самоопиздюливание

Expand Down Expand Up @@ -723,6 +726,9 @@ private void OnStasisDeathAction(EntityUid uid, ChangelingComponent component, S
_mobState.ChangeMobState(uid, MobState.Critical); /// Переходим в крит, если повреждений окажется меньше нужных для крита, поднимемся в MobState.Alive сами
_damageableSystem.TryChangeDamage(uid, damage_burn);
component.StasisDeathActive = false;
EnsureComp<GhostOnMoveComponent>(uid);
var ghostOnMove = EnsureComp<GhostOnMoveComponent>(uid);
ghostOnMove.MustBeDead = true;
}
}

Expand Down Expand Up @@ -970,7 +976,7 @@ private void OnLastResort(EntityUid uid, ChangelingComponent component, LastReso
}
}

private void OnHatch(EntityUid uid, ChangelingComponent component, LingHatchActionEvent args)
private void OnHatch(EntityUid uid, ChangelingComponent component, LingHatchActionEvent args) /// TODO: Сделать из акшона автоматическую систему!
{
if (args.Handled)
return;
Expand All @@ -997,10 +1003,14 @@ private void OnHatch(EntityUid uid, ChangelingComponent component, LingHatchActi

else
{
_action.RemoveAction(uid, component.ChangelingHatchActionEntity);
RemComp<LingEggsHolderComponent>(uid);

if (SpawnLingMonkey(uid, component))
{

var damage_brute = new DamageSpecifier(_proto.Index(BruteDamageGroup), component.GibDamage);
_damageableSystem.TryChangeDamage(uid, damage_brute);

args.Handled = true;
}
}
Expand Down
28 changes: 16 additions & 12 deletions Content.Server/ADT/Changeling/EntitySystems/ChangelingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Content.Shared.Gibbing.Systems;
using Content.Shared.Mind;
using Content.Shared.Sirena.NightVision.Components;
using Content.Shared.CombatMode;

namespace Content.Server.Changeling.EntitySystems;

Expand All @@ -56,12 +57,15 @@ public sealed partial class ChangelingSystem : EntitySystem
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly GibbingSystem _gibbingSystem = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ChangelingComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ChangelingComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ChangelingComponent, ComponentShutdown>(OnShutdown);

SubscribeLocalEvent<ChangelingComponent, ChangelingEvolutionMenuActionEvent>(OnShop);
SubscribeLocalEvent<ChangelingComponent, ChangelingCycleDNAActionEvent>(OnCycleDNA);
Expand Down Expand Up @@ -146,6 +150,17 @@ private void OnMapInit(EntityUid uid, ChangelingComponent component, MapInitEven
_action.AddAction(uid, ref component.ChangelingTransformActionEntity, component.ChangelingTransformAction);
_action.AddAction(uid, ref component.ChangelingRefreshActionEntity, component.ChangelingRefreshAction);
}

private void OnShutdown(EntityUid uid, ChangelingComponent component, ComponentShutdown args)
{
_action.RemoveAction(uid, component.ChangelingEvolutionMenuActionEntity);
_action.RemoveAction(uid, component.ChangelingRegenActionEntity);
_action.RemoveAction(uid, component.ChangelingAbsorbActionEntity);
_action.RemoveAction(uid, component.ChangelingDNAStingActionEntity);
_action.RemoveAction(uid, component.ChangelingDNACycleActionEntity);
_action.RemoveAction(uid, component.ChangelingTransformActionEntity);
_action.RemoveAction(uid, component.ChangelingRefreshActionEntity);
}
private void OnShop(EntityUid uid, ChangelingComponent component, ChangelingEvolutionMenuActionEvent args)
{
_store.OnInternalShop(uid);
Expand Down Expand Up @@ -718,12 +733,8 @@ public bool SpawnLingSlug(EntityUid uid, ChangelingComponent component)

public bool SpawnLingMonkey(EntityUid uid, ChangelingComponent component)
{
_action.RemoveAction(uid, component.ChangelingHatchActionEntity);

var slug = Spawn(LingMonkeyId, Transform(uid).Coordinates);

RemComp<NightVisionComponent>(slug);

var newLingComponent = EnsureComp<ChangelingComponent>(slug);
newLingComponent.Chemicals = component.Chemicals;
newLingComponent.ChemicalsPerSecond = component.ChemicalsPerSecond;
Expand All @@ -735,14 +746,10 @@ public bool SpawnLingMonkey(EntityUid uid, ChangelingComponent component)
newLingComponent.CanRefresh = component.CanRefresh;
newLingComponent.LesserFormActive = !component.LesserFormActive;

_action.AddAction(uid, ref component.ChangelingLesserFormActionEntity, component.ChangelingLesserFormAction);

RemComp(uid, component);

_actionContainer.TransferAllActionsWithNewAttached(uid, slug, slug);

_action.AddAction(slug, ref newLingComponent.ChangelingLastResortActionEntity, newLingComponent.ChangelingLastResortAction);
_action.RemoveAction(slug, newLingComponent.ChangelingLastResortActionEntity);
_action.AddAction(slug, ref component.ChangelingLesserFormActionEntity, component.ChangelingLesserFormAction);


newLingComponent.StoredDNA = new List<PolymorphHumanoidData>(); /// Создание нового ДНК списка
Expand All @@ -758,9 +765,6 @@ public bool SpawnLingMonkey(EntityUid uid, ChangelingComponent component)
if (_mindSystem.TryGetMind(uid, out var mindId, out var mind))
_mindSystem.TransferTo(mindId, slug, mind: mind);

var damage_brute = new DamageSpecifier(_proto.Index(BruteDamageGroup), component.GibDamage);
_damageableSystem.TryChangeDamage(uid, damage_brute);

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
using Content.Shared.Physics;
using Content.Shared.Storage;
using Robust.Server.GameObjects;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Spawners;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Throwing;

namespace Content.Server.ComponentalActions.EntitySystems;
Expand Down Expand Up @@ -83,8 +83,34 @@ private void InitializeCompAbilities()
SubscribeLocalEvent<ProjectileActComponent, CompProjectileActionEvent>(OnProjectile);
SubscribeLocalEvent<HealActComponent, CompHealActionEvent>(OnHeal);
SubscribeLocalEvent<JumpActComponent, CompJumpActionEvent>(OnJump);
SubscribeLocalEvent<StasisHealActComponent, CompStasisHealActionEvent>(OnStasisHeal);
SubscribeLocalEvent<InvisibilityActComponent, CompInvisibilityActionEvent>(OnInvisibility);
}

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

var query = EntityQueryEnumerator<StasisHealActComponent>();
while (query.MoveNext(out var uid, out var stasis))
{
if (stasis.Active)
{
var damage_brute = new DamageSpecifier(_proto.Index(BruteDamageGroup), stasis.RegenerateBruteHealAmount);
var damage_burn = new DamageSpecifier(_proto.Index(BurnDamageGroup), stasis.RegenerateBurnHealAmount);
var damage_airloss = new DamageSpecifier(_proto.Index(AirlossDamageGroup), stasis.RegenerateBurnHealAmount);
var damage_toxin = new DamageSpecifier(_proto.Index(ToxinDamageGroup), stasis.RegenerateBurnHealAmount);
var damage_genetic = new DamageSpecifier(_proto.Index(GeneticDamageGroup), stasis.RegenerateBurnHealAmount);
_damageableSystem.TryChangeDamage(uid, damage_brute);
_damageableSystem.TryChangeDamage(uid, damage_burn);
_damageableSystem.TryChangeDamage(uid, damage_airloss);
_damageableSystem.TryChangeDamage(uid, damage_toxin);
_damageableSystem.TryChangeDamage(uid, damage_genetic);
_bloodstreamSystem.TryModifyBloodLevel(uid, stasis.RegenerateBloodVolumeHealAmount); // give back blood and remove bleeding
_bloodstreamSystem.TryModifyBleedAmount(uid, stasis.RegenerateBleedReduceAmount);
}
}
}
private List<EntityCoordinates> GetSpawnPositions(TransformComponent casterXform, ComponentalActionsSpawnData data)
{
switch (data)
Expand Down Expand Up @@ -188,6 +214,9 @@ private void OnProjectile(EntityUid uid, ProjectileActComponent component, CompP

public ProtoId<DamageGroupPrototype> BruteDamageGroup = "Brute";
public ProtoId<DamageGroupPrototype> BurnDamageGroup = "Burn";
public ProtoId<DamageGroupPrototype> AirlossDamageGroup = "Airloss";
public ProtoId<DamageGroupPrototype> ToxinDamageGroup = "Toxin";
public ProtoId<DamageGroupPrototype> GeneticDamageGroup = "Genetic";

private void OnHeal(EntityUid uid, HealActComponent component, CompHealActionEvent args)
{
Expand Down Expand Up @@ -220,4 +249,58 @@ private void OnJump(EntityUid uid, JumpActComponent component, CompJumpActionEve
args.Handled = true;
}

private void OnStasisHeal(EntityUid uid, StasisHealActComponent component, CompStasisHealActionEvent args)
{
if (args.Handled)
return;

if (component.Active)
{
var movementSpeed = EnsureComp<MovementSpeedModifierComponent>(uid);
var sprintSpeed = component.BaseSprintSpeed;
var walkSpeed = component.BaseWalkSpeed;
_movementSpeedModifierSystem?.ChangeBaseSpeed(uid, walkSpeed, sprintSpeed, movementSpeed.Acceleration, movementSpeed);
}

if (!component.Active)
{
var movementSpeed = EnsureComp<MovementSpeedModifierComponent>(uid);
var sprintSpeed = component.SpeedModifier;
var walkSpeed = component.SpeedModifier;
_movementSpeedModifierSystem?.ChangeBaseSpeed(uid, walkSpeed, sprintSpeed, movementSpeed.Acceleration, movementSpeed);
}

component.Active = !component.Active;

args.Handled = true;
}

private void OnInvisibility(EntityUid uid, InvisibilityActComponent component, CompInvisibilityActionEvent args)
{
if (args.Handled)
return;

var stealth = EnsureComp<StealthComponent>(uid); // cant remove the armor
var stealthonmove = EnsureComp<StealthOnMoveComponent>(uid); // cant remove the armor

var message = Loc.GetString(!component.Active ? "changeling-chameleon-toggle-on" : "changeling-chameleon-toggle-off");
_popup.PopupEntity(message, uid, uid);

if (!component.Active)
{
stealthonmove.PassiveVisibilityRate = component.PassiveVisibilityRate;
stealthonmove.MovementVisibilityRate = component.MovementVisibilityRate;
stealth.MinVisibility = component.MinVisibility;
stealth.MaxVisibility = component.MaxVisibility;
}
else
{
RemCompDeferred(uid, stealth);
RemCompDeferred(uid, stealthonmove);
}

component.Active = !component.Active;

args.Handled = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public override void Initialize()
SubscribeLocalEvent<JumpActComponent, MapInitEvent>(OnJumpInit);
SubscribeLocalEvent<JumpActComponent, ComponentShutdown>(OnJumpShutdown);

SubscribeLocalEvent<StasisHealActComponent, MapInitEvent>(OnStasisHealInit);
SubscribeLocalEvent<StasisHealActComponent, ComponentShutdown>(OnStasisHealShutdown);

SubscribeLocalEvent<InvisibilityActComponent, MapInitEvent>(OnStealthInit);
SubscribeLocalEvent<InvisibilityActComponent, ComponentShutdown>(OnStealthShutdown);

InitializeCompAbilities();
}

Expand Down Expand Up @@ -110,4 +116,25 @@ private void OnJumpShutdown(EntityUid uid, JumpActComponent component, Component
_action.RemoveAction(uid, component.ActionEntity);
}

private void OnStasisHealInit(EntityUid uid, StasisHealActComponent component, MapInitEvent args)
{
var movementSpeed = EnsureComp<MovementSpeedModifierComponent>(uid);
component.BaseSprintSpeed = movementSpeed.BaseSprintSpeed;
component.BaseWalkSpeed = movementSpeed.BaseWalkSpeed;
_action.AddAction(uid, ref component.ActionEntity, component.Action);
}
private void OnStasisHealShutdown(EntityUid uid, StasisHealActComponent component, ComponentShutdown args)
{
_action.RemoveAction(uid, component.ActionEntity);
}

private void OnStealthInit(EntityUid uid, InvisibilityActComponent component, MapInitEvent args)
{
_action.AddAction(uid, ref component.ActionEntity, component.Action);
}
private void OnStealthShutdown(EntityUid uid, InvisibilityActComponent component, ComponentShutdown args)
{
_action.RemoveAction(uid, component.ActionEntity);
}

}
Loading
Loading