* Disable Pulling When Buckling an entity * Projectile Improvements If you shoot at a person that is critted now it will only hit if you aim at that person otherwise go "above" him and hit other targets. - Dead people are still unhitable * Update Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> * Firelock In Progress * Revert "Projectile Improvements" This reverts commit 5821afc798e49e530d4086d7a9ddbe097805fdc4. * Firelock Graph * Revert "Merge branch 'master' into test2" This reverts commit c69661cc7d9dcdc6d8c0dd45770f9eb94b231463, reversing changes made to 5f1de8b8d24cd52190addb3df5617cb1012fd52c. * Bunch of stuff - Metal Rods - Reinforced Glass - SetStackCount Condition - Tables - Lattice * Output2 to FloorTileItemComponent * Plating, Underplating and Tiles (+FloorTile Improvements) * Turf Fixes + APC Electronics * Reinforced Glass In-hand textures * All the fixes * Final Changes * (Hopefully) Last commit * Update Resources/Prototypes/Entities/Constructible/Doors/firelock_frame.yml Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Server/GameObjects/Components/Atmos/FirelockComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * A Few more things * Edit FirelockComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
97 lines
3.5 KiB
C#
97 lines
3.5 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;
|
|
|
|
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 void 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;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|