The power of componentdependencies (#2211)
* stuff * bucklemeup * powerreceiver * things * Update RobustToolbox * Fix nullability errors Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@ using Robust.Server.GameObjects.EntitySystemMessages;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.ComponentDependencies;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -39,6 +40,11 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
[ComponentDependency] public readonly AppearanceComponent? AppearanceComponent = null;
|
||||
[ComponentDependency] private readonly ServerStatusEffectsComponent? _serverStatusEffectsComponent = null;
|
||||
[ComponentDependency] private readonly StunnableComponent? _stunnableComponent = null;
|
||||
[ComponentDependency] private readonly MobStateManagerComponent? _mobStateManagerComponent = null;
|
||||
|
||||
private int _size;
|
||||
|
||||
/// <summary>
|
||||
@@ -109,15 +115,15 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
/// </summary>
|
||||
private void BuckleStatus()
|
||||
{
|
||||
if (Owner.TryGetComponent(out ServerStatusEffectsComponent? status))
|
||||
if (_serverStatusEffectsComponent != null)
|
||||
{
|
||||
if (Buckled)
|
||||
{
|
||||
status.ChangeStatusEffectIcon(StatusEffect.Buckled, BuckledTo!.BuckledIcon);
|
||||
_serverStatusEffectsComponent.ChangeStatusEffectIcon(StatusEffect.Buckled, BuckledTo!.BuckledIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
status.RemoveStatusEffect(StatusEffect.Buckled);
|
||||
_serverStatusEffectsComponent.RemoveStatusEffect(StatusEffect.Buckled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,10 +286,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(BuckleVisuals.Buckled, true);
|
||||
}
|
||||
AppearanceComponent?.SetData(BuckleVisuals.Buckled, true);
|
||||
|
||||
BuckledTo = strap;
|
||||
|
||||
@@ -345,12 +348,9 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
Owner.Transform.WorldRotation = oldBuckledTo.Owner.Transform.WorldRotation;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(BuckleVisuals.Buckled, false);
|
||||
}
|
||||
AppearanceComponent?.SetData(BuckleVisuals.Buckled, false);
|
||||
|
||||
if (Owner.TryGetComponent(out StunnableComponent? stunnable) && stunnable.KnockedDown)
|
||||
if (_stunnableComponent != null && _stunnableComponent.KnockedDown)
|
||||
{
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner);
|
||||
}
|
||||
@@ -359,19 +359,16 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out MobStateManagerComponent? stateManager))
|
||||
if (_mobStateManagerComponent != null)
|
||||
{
|
||||
stateManager.CurrentMobState.EnterState(Owner);
|
||||
_mobStateManagerComponent.CurrentMobState.EnterState(Owner);
|
||||
}
|
||||
|
||||
BuckleStatus();
|
||||
|
||||
if (oldBuckledTo.Owner.TryGetComponent(out StrapComponent? strap))
|
||||
{
|
||||
strap.Remove(this);
|
||||
_entitySystem.GetEntitySystem<AudioSystem>()
|
||||
.PlayFromEntity(strap.UnbuckleSound, Owner);
|
||||
}
|
||||
oldBuckledTo.Remove(this);
|
||||
_entitySystem.GetEntitySystem<AudioSystem>()
|
||||
.PlayFromEntity(oldBuckledTo.UnbuckleSound, Owner);
|
||||
|
||||
SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner));
|
||||
|
||||
@@ -520,11 +517,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
_entityManager.EventBus.UnsubscribeEvents(this);
|
||||
|
||||
if (BuckledTo != null &&
|
||||
BuckledTo.Owner.TryGetComponent(out StrapComponent? strap))
|
||||
{
|
||||
strap.Remove(this);
|
||||
}
|
||||
BuckledTo?.Remove(this);
|
||||
|
||||
TryUnbuckle(Owner, true);
|
||||
|
||||
@@ -538,9 +531,9 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
if (BuckledTo != null &&
|
||||
Owner.Transform.WorldRotation.GetCardinalDir() == Direction.North &&
|
||||
BuckledTo.Owner.TryGetComponent(out SpriteComponent? strapSprite))
|
||||
BuckledTo.SpriteComponent != null)
|
||||
{
|
||||
drawDepth = strapSprite.DrawDepth - 1;
|
||||
drawDepth = BuckledTo.SpriteComponent.DrawDepth - 1;
|
||||
}
|
||||
|
||||
return new BuckleComponentState(Buckled, drawDepth);
|
||||
|
||||
Reference in New Issue
Block a user