fix(contraband): Make contraband work with chameleon items (#30986)
* formatting --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Clothing.Components;
|
using Content.Shared.Clothing.Components;
|
||||||
|
using Content.Shared.Contraband;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
@@ -13,6 +14,7 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
|
|||||||
[Dependency] private readonly IComponentFactory _factory = default!;
|
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
|
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
|
||||||
|
[Dependency] private readonly ContrabandSystem _contraband = default!;
|
||||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||||
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
|
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
|
||||||
[Dependency] private readonly TagSystem _tag = default!;
|
[Dependency] private readonly TagSystem _tag = default!;
|
||||||
@@ -68,6 +70,17 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
_clothingSystem.CopyVisuals(uid, otherClothing, clothing);
|
_clothingSystem.CopyVisuals(uid, otherClothing, clothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// properly mark contraband
|
||||||
|
if (proto.TryGetComponent("Contraband", out ContrabandComponent? contra))
|
||||||
|
{
|
||||||
|
EnsureComp<ContrabandComponent>(uid, out var current);
|
||||||
|
_contraband.CopyDetails(uid, contra, current);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemComp<ContrabandComponent>(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateSprite(EntityUid uid, EntityPrototype proto) { }
|
protected virtual void UpdateSprite(EntityUid uid, EntityPrototype proto) { }
|
||||||
|
|||||||
@@ -33,6 +33,16 @@ public sealed class ContrabandSystem : EntitySystem
|
|||||||
_contrabandExamineEnabled = val;
|
_contrabandExamineEnabled = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CopyDetails(EntityUid uid, ContrabandComponent other, ContrabandComponent? contraband = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref contraband))
|
||||||
|
return;
|
||||||
|
|
||||||
|
contraband.Severity = other.Severity;
|
||||||
|
contraband.AllowedDepartments = other.AllowedDepartments;
|
||||||
|
Dirty(uid, contraband);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnExamined(Entity<ContrabandComponent> ent, ref ExaminedEvent args)
|
private void OnExamined(Entity<ContrabandComponent> ent, ref ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (!_contrabandExamineEnabled)
|
if (!_contrabandExamineEnabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user