public void AfterAttack(AfterAttackEventArgs eventArgs) { var attacked = eventArgs.Attacked; var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID); var tile = mapGrid.GetTileRef(eventArgs.ClickLocation); var coordinates = mapGrid.GridTileToLocal(tile.GridIndices); float distance = coordinates.Distance(_mapManager, Owner.Transform.GridPosition); if (distance > InteractionSystem.InteractionRange) { return; } var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId]; if (tileDef.IsSubFloor && attacked == null && Stack.Use(1)) { var desiredTile = _tileDefinitionManager[_outputTile]; mapGrid.SetTile(eventArgs.ClickLocation, new Tile(desiredTile.TileId)); _entitySystemManager.GetEntitySystem <AudioSystem>().Play("/Audio/items/genhit.ogg", Owner); if (Stack.Count < 1) { Owner.Delete(); } } }
public void AfterInteract(AfterInteractEventArgs eventArgs) { if (!InteractionChecks.InRangeUnobstructed(eventArgs)) { return; } var attacked = eventArgs.Target; var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID); var tile = mapGrid.GetTileRef(eventArgs.ClickLocation); var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId]; if (tileDef.IsSubFloor && attacked == null && _stack.Use(1)) { var desiredTile = _tileDefinitionManager[_outputTile]; mapGrid.SetTile(eventArgs.ClickLocation, new Tile(desiredTile.TileId)); EntitySystem.Get <AudioSystem>().PlayAtCoords("/Audio/Items/genhit.ogg", eventArgs.ClickLocation); } }