mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
* buildableAI * Сборка ИИ * Разборка ИИ * Фиксики * Производство и локализация * Это такой конец? * Это такой конец. * Фиксики * Еще больше фиксиков! * Заяц умный * Странно, но ладно * Typos * Разное ч.1 * Разное * Фикс локализации * Фикс линтера * clean up * Разное ч.3 * Уменьшение слотов работы * Фикс тестов (кролик умный?) * марки * Фикс тестов х2 * Забытая стадия сборки * Фикс тестов х3 * Фикс тестов хНеПомню * Фикс тестов хНеПомню х2 --------- Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com>
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Robust.Shared.Containers;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.Containers;
|
|
|
|
/// <summary>
|
|
/// Applies / removes an entity prototype from a child entity when it's inserted into a container.
|
|
/// </summary>
|
|
public sealed class ContainerCompSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!; // WD EDIT
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ContainerCompComponent, EntInsertedIntoContainerMessage>(OnConInsert);
|
|
SubscribeLocalEvent<ContainerCompComponent, EntRemovedFromContainerMessage>(OnConRemove);
|
|
}
|
|
|
|
private void OnConRemove(Entity<ContainerCompComponent> ent, ref EntRemovedFromContainerMessage args)
|
|
{
|
|
if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState) // WD EDIT
|
|
return;
|
|
|
|
// WD EDIT START
|
|
if (_proto.TryIndex(ent.Comp.Proto, out var entProto))
|
|
{
|
|
EntityManager.RemoveComponents(args.Entity, entProto.Components);
|
|
}
|
|
// WD EDIT END
|
|
}
|
|
|
|
private void OnConInsert(Entity<ContainerCompComponent> ent, ref EntInsertedIntoContainerMessage args)
|
|
{
|
|
if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState) // WD EDIT
|
|
return;
|
|
|
|
if (_proto.TryIndex(ent.Comp.Proto, out var entProto))
|
|
{
|
|
EntityManager.AddComponents(args.Entity, entProto.Components);
|
|
}
|
|
}
|
|
}
|