фикс хамелеона
This commit is contained in:
@@ -16,6 +16,7 @@ using Robust.Shared.Network;
|
|||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.Manager;
|
using Robust.Shared.Serialization.Manager;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Content.Shared.Polymorph.Systems;
|
namespace Content.Shared.Polymorph.Systems;
|
||||||
@@ -36,7 +37,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _xform = default!;
|
[Dependency] private readonly SharedTransformSystem _xform = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!; // WD
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -44,6 +45,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ChameleonDisguiseComponent, InteractHandEvent>(OnDisguiseInteractHand, before: [typeof(SharedItemSystem)]);
|
SubscribeLocalEvent<ChameleonDisguiseComponent, InteractHandEvent>(OnDisguiseInteractHand, before: [typeof(SharedItemSystem)]);
|
||||||
SubscribeLocalEvent<ChameleonDisguiseComponent, DamageChangedEvent>(OnDisguiseDamaged);
|
SubscribeLocalEvent<ChameleonDisguiseComponent, DamageChangedEvent>(OnDisguiseDamaged);
|
||||||
SubscribeLocalEvent<ChameleonDisguiseComponent, ComponentShutdown>(OnDisguiseShutdown);
|
SubscribeLocalEvent<ChameleonDisguiseComponent, ComponentShutdown>(OnDisguiseShutdown);
|
||||||
|
SubscribeLocalEvent<ChameleonDisguiseComponent, GotEquippedHandEvent>(OnPickup); // WD
|
||||||
|
|
||||||
SubscribeLocalEvent<ChameleonProjectorComponent, AfterInteractEvent>(OnInteract);
|
SubscribeLocalEvent<ChameleonProjectorComponent, AfterInteractEvent>(OnInteract);
|
||||||
SubscribeLocalEvent<ChameleonProjectorComponent, GetVerbsEvent<UtilityVerb>>(OnGetVerbs);
|
SubscribeLocalEvent<ChameleonProjectorComponent, GetVerbsEvent<UtilityVerb>>(OnGetVerbs);
|
||||||
@@ -62,11 +64,19 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WD. Horrible fix, but functional.
|
||||||
|
/// </summary>
|
||||||
|
private void OnPickup(Entity<ChameleonDisguiseComponent> ent, ref GotEquippedHandEvent args)
|
||||||
|
{
|
||||||
|
Timer.Spawn(100, () => TryReveal(ent.Comp.User));
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDisguiseDamaged(Entity<ChameleonDisguiseComponent> ent, ref DamageChangedEvent args)
|
private void OnDisguiseDamaged(Entity<ChameleonDisguiseComponent> ent, ref DamageChangedEvent args)
|
||||||
{
|
{
|
||||||
// anything that would damage both like an explosion gets doubled
|
// anything that would damage both like an explosion gets doubled
|
||||||
// feature? projector makes your atoms weaker or some bs
|
// feature? projector makes your atoms weaker or some bs
|
||||||
if (args.DamageDelta is {} damage)
|
if (args.DamageDelta is { } damage)
|
||||||
_damageable.TryChangeDamage(ent.Comp.User, damage);
|
_damageable.TryChangeDamage(ent.Comp.User, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +91,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnInteract(Entity<ChameleonProjectorComponent> ent, ref AfterInteractEvent args)
|
private void OnInteract(Entity<ChameleonProjectorComponent> ent, ref AfterInteractEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled || !args.CanReach || args.Target is not {} target)
|
if (args.Handled || !args.CanReach || args.Target is not { } target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
@@ -126,7 +136,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnToggleNoRot(Entity<ChameleonProjectorComponent> ent, ref DisguiseToggleNoRotEvent args)
|
private void OnToggleNoRot(Entity<ChameleonProjectorComponent> ent, ref DisguiseToggleNoRotEvent args)
|
||||||
{
|
{
|
||||||
if (ent.Comp.Disguised is not {} uid)
|
if (ent.Comp.Disguised is not { } uid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var xform = Transform(uid);
|
var xform = Transform(uid);
|
||||||
@@ -137,7 +147,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnToggleAnchored(Entity<ChameleonProjectorComponent> ent, ref DisguiseToggleAnchoredEvent args)
|
private void OnToggleAnchored(Entity<ChameleonProjectorComponent> ent, ref DisguiseToggleAnchoredEvent args)
|
||||||
{
|
{
|
||||||
if (ent.Comp.Disguised is not {} uid)
|
if (ent.Comp.Disguised is not { } uid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var xform = Transform(uid);
|
var xform = Transform(uid);
|
||||||
@@ -249,7 +259,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void RevealProjector(Entity<ChameleonProjectorComponent> ent)
|
public void RevealProjector(Entity<ChameleonProjectorComponent> ent)
|
||||||
{
|
{
|
||||||
if (ent.Comp.Disguised is {} user)
|
if (ent.Comp.Disguised is { } user)
|
||||||
TryReveal(user);
|
TryReveal(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +271,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This would probably be a good thing to add to engine in the future.
|
/// This would probably be a good thing to add to engine in the future.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected bool CopyComp<T>(Entity<ChameleonDisguiseComponent> ent) where T: Component, new()
|
protected bool CopyComp<T>(Entity<ChameleonDisguiseComponent> ent) where T : Component, new()
|
||||||
{
|
{
|
||||||
if (!GetSrcComp<T>(ent.Comp, out var src))
|
if (!GetSrcComp<T>(ent.Comp, out var src))
|
||||||
return true;
|
return true;
|
||||||
@@ -277,13 +287,13 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to get a single component from the source entity/prototype.
|
/// Try to get a single component from the source entity/prototype.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool GetSrcComp<T>(ChameleonDisguiseComponent comp, [NotNullWhen(true)] out T? src) where T: Component
|
private bool GetSrcComp<T>(ChameleonDisguiseComponent comp, [NotNullWhen(true)] out T? src) where T : Component
|
||||||
{
|
{
|
||||||
src = null;
|
src = null;
|
||||||
if (TryComp(comp.SourceEntity, out src))
|
if (TryComp(comp.SourceEntity, out src))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (comp.SourceProto is not {} protoId)
|
if (comp.SourceProto is not { } protoId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_proto.TryIndex<EntityPrototype>(protoId, out var proto))
|
if (!_proto.TryIndex<EntityPrototype>(protoId, out var proto))
|
||||||
|
|||||||
Reference in New Issue
Block a user