* Async Interface * Update Content.Server/GameObjects/Components/Fluids/MopComponent.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Changed the glassbeaker * Update Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Interaction system fix * Removed I from the interface * Changed all implementations of the interface I could find * all public void implementation fixed * All built, no errors should remain * Update Resources/Prototypes/Entities/Objects/Specific/chemistry.yml Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/ActionBlocking/HandcuffComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Commit based off Sloth's commentary * Removed the Rag file from the PR * Reverted sloth's commentary changes on the publcity of the function * Injector component properly implemented interface * Update Content.Server/GameObjects/Components/Fluids/MopComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Fluids/SprayComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: BlueberryShortcake <rubetskoy234@mail.ru> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
98 lines
3.6 KiB
C#
98 lines
3.6 KiB
C#
using Content.Server.GameObjects.Components.Stack;
|
|
using Content.Shared.Audio;
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Utility;
|
|
using Robust.Server.GameObjects.EntitySystems;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Systems;
|
|
using Robust.Shared.Interfaces.Map;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Serialization;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Content.Server.GameObjects.Components.Items
|
|
{
|
|
[RegisterComponent]
|
|
public class FloorTileItemComponent : Component, IAfterInteract
|
|
{
|
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
|
|
|
public override string Name => "FloorTile";
|
|
private List<string> _outputTiles;
|
|
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
serializer.DataField(ref _outputTiles, "outputs", null);
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
Owner.EnsureComponent<StackComponent>();
|
|
}
|
|
|
|
private bool HasBaseTurf(ContentTileDefinition tileDef, string baseTurf)
|
|
{
|
|
foreach (var tileBaseTurf in tileDef.BaseTurfs)
|
|
{
|
|
if (baseTurf == tileBaseTurf)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private void PlaceAt(IMapGrid mapGrid, EntityCoordinates location, ushort tileId, float offset = 0)
|
|
{
|
|
mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId));
|
|
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Items/genhit.ogg", location, AudioHelpers.WithVariation(0.125f));
|
|
}
|
|
|
|
public async Task AfterInteract(AfterInteractEventArgs eventArgs)
|
|
{
|
|
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) return;
|
|
if (!Owner.TryGetComponent(out StackComponent stack)) return;
|
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
|
|
var location = eventArgs.ClickLocation.AlignWithClosestGridTile();
|
|
var locationMap = location.ToMap(Owner.EntityManager);
|
|
mapManager.TryGetGrid(location.GetGridId(Owner.EntityManager), out var mapGrid);
|
|
foreach (var currentTile in _outputTiles)
|
|
{
|
|
var currentTileDefinition = (ContentTileDefinition) _tileDefinitionManager[currentTile];
|
|
|
|
if (mapGrid != null)
|
|
{
|
|
var tile = mapGrid.GetTileRef(location);
|
|
var baseTurf = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
|
|
|
|
if (HasBaseTurf(currentTileDefinition, baseTurf.Name) && stack.Use(1))
|
|
{
|
|
PlaceAt(mapGrid, location, currentTileDefinition.TileId);
|
|
break;
|
|
}
|
|
}
|
|
else if (HasBaseTurf(currentTileDefinition, "space"))
|
|
{
|
|
mapGrid = mapManager.CreateGrid(locationMap.MapId);
|
|
mapGrid.WorldPosition = locationMap.Position;
|
|
location = new EntityCoordinates(mapGrid.GridEntityId, Vector2.Zero);
|
|
PlaceAt(mapGrid, location, _tileDefinitionManager[_outputTiles[0]].TileId, mapGrid.TileSize / 2f);
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|