Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Mining.Components
protected override void Initialize()
{
base.Initialize();
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
{
appearance.SetData(AsteroidRockVisuals.State, _random.Pick(SpriteStates));
}
@@ -34,12 +34,12 @@ namespace Content.Server.Mining.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
var item = eventArgs.Using;
if (!item.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Uid, out MeleeWeaponComponent? meleeWeaponComponent))
return false;
EntitySystem.Get<DamageableSystem>().TryChangeDamage(Owner.Uid, meleeWeaponComponent.Damage);
if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Uid, out PickaxeComponent? pickaxeComponent))
return true;
SoundSystem.Play(Filter.Pvs(Owner), pickaxeComponent.MiningSound.GetSound(), Owner, AudioParams.Default);