Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainSqrBeard committed Dec 22, 2024
1 parent 1b6cb20 commit a706e92
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ public override void Initialize()

private void OnFromTileCraftComplete(Entity<FromTileCrafterComponent> ent, ref FromTileCraftDoAfterEvent args)
{
var comp = ent.Comp;
if (_netManager.IsClient)
return;

if (args.Handled || args.Cancelled)
return;

var comp = ent.Comp;

var gridUid = GetEntity(args.Grid);
if (!TryComp<MapGridComponent>(gridUid, out var grid))
return;

var tileRef = _maps.GetTileRef(gridUid, grid, args.GridTile);
var coords = _maps.ToCoordinates(tileRef, grid);

var spread = comp.Spread * grid.TileSize;
var offset = new Vector2(
(_robustRandom.NextFloat() - 0.5f) * spread + grid.TileSize * 0.5f,
(_robustRandom.NextFloat() - 0.5f) * spread + grid.TileSize * 0.5f);
((_robustRandom.NextFloat() - 0.5f) * comp.Spread + 0.5f) * grid.TileSize,
((_robustRandom.NextFloat() - 0.5f) * comp.Spread + 0.5f) * grid.TileSize);

if (_netManager.IsServer)
Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset));
Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset));
}

private void OnAfterInteract(Entity<FromTileCrafterComponent> ent, ref AfterInteractEvent args)
Expand Down

0 comments on commit a706e92

Please sign in to comment.