Make InteractUsing async, make tools use DoAfter. (#1772)
* Make IInteractUsing async, make tools use DoAfter. * Disable warning 1998 in Content.Server * Update Content.Server/GameObjects/Components/AnchorableComponent.cs
This commit is contained in:
committed by
GitHub
parent
bbdfe44224
commit
d9ae942759
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Construction;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
@@ -76,7 +77,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
TryStartItemConstruction(placingEnt, msg.PrototypeName);
|
||||
}
|
||||
|
||||
private void HandleToolInteraction(AfterInteractMessage msg)
|
||||
private async void HandleToolInteraction(AfterInteractMessage msg)
|
||||
{
|
||||
if(msg.Handled)
|
||||
return;
|
||||
@@ -104,7 +105,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
// the target entity is in the process of being constructed/deconstructed
|
||||
if (msg.Attacked.TryGetComponent<ConstructionComponent>(out var constructComp))
|
||||
{
|
||||
var result = TryConstructEntity(constructComp, handEnt, msg.User);
|
||||
var result = await TryConstructEntity(constructComp, handEnt, msg.User);
|
||||
|
||||
// TryConstructEntity may delete the existing entity
|
||||
|
||||
@@ -367,7 +368,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryConstructEntity(ConstructionComponent constructionComponent, IEntity handTool, IEntity user)
|
||||
private async Task<bool> TryConstructEntity(ConstructionComponent constructionComponent, IEntity handTool, IEntity user)
|
||||
{
|
||||
var constructEntity = constructionComponent.Owner;
|
||||
var spriteComponent = constructEntity.GetComponent<SpriteComponent>();
|
||||
@@ -384,7 +385,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
var stage = constructPrototype.Stages[constructionComponent.Stage];
|
||||
|
||||
if (TryProcessStep(constructEntity, stage.Forward, handTool, user, transformComponent.GridPosition))
|
||||
if (await TryProcessStep(constructEntity, stage.Forward, handTool, user, transformComponent.GridPosition))
|
||||
{
|
||||
constructionComponent.Stage++;
|
||||
if (constructionComponent.Stage == constructPrototype.Stages.Count - 1)
|
||||
@@ -406,7 +407,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
else if (TryProcessStep(constructEntity, stage.Backward, handTool, user, transformComponent.GridPosition))
|
||||
else if (await TryProcessStep(constructEntity, stage.Backward, handTool, user, transformComponent.GridPosition))
|
||||
{
|
||||
constructionComponent.Stage--;
|
||||
stage = constructPrototype.Stages[constructionComponent.Stage];
|
||||
@@ -443,7 +444,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryProcessStep(IEntity constructEntity, ConstructionStep step, IEntity slapped, IEntity user, GridCoordinates gridCoords)
|
||||
private async Task<bool> TryProcessStep(IEntity constructEntity, ConstructionStep step, IEntity slapped, IEntity user, GridCoordinates gridCoords)
|
||||
{
|
||||
if (step == null)
|
||||
{
|
||||
@@ -473,9 +474,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
// Handle welder manually since tool steps specify fuel amount needed, for some reason.
|
||||
if (toolStep.ToolQuality.HasFlag(ToolQuality.Welding))
|
||||
return slapped.TryGetComponent<WelderComponent>(out var welder)
|
||||
&& welder.UseTool(user, constructEntity, toolStep.ToolQuality, toolStep.Amount);
|
||||
&& await welder.UseTool(user, constructEntity, toolStep.DoAfterDelay, toolStep.ToolQuality, toolStep.Amount);
|
||||
|
||||
return tool.UseTool(user, constructEntity, toolStep.ToolQuality);
|
||||
return await tool.UseTool(user, constructEntity, toolStep.DoAfterDelay, toolStep.ToolQuality);
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user