public void Update() { if (!_running) { return; } // Get all intersecting tiles with the vapor and spray the divided solution on there if (Owner.TryGetComponent(out ICollidableComponent collidable)) { var worldBounds = collidable.WorldAABB; var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID); var tiles = mapGrid.GetTilesIntersecting(worldBounds); var amount = _transferAmount / ReagentUnit.New(tiles.Count()); foreach (var tile in tiles) { var pos = tile.GridIndices.ToGridCoordinates(_mapManager, tile.GridIndex); SpillHelper.SpillAt(pos, _contents.SplitSolution(amount), "PuddleSmear", false); //make non PuddleSmear? } } if (_contents.CurrentVolume == 0) { // Delete this Owner.Delete(); } }
public override bool TryUseFood(IEntity user, IEntity target, UtensilComponent utensilUsed = null) { if (user == null) { return(false); } var trueTarget = target ?? user; if (!trueTarget.TryGetComponent(out StomachComponent stomach)) { return(false); } if (!InteractionChecks.InRangeUnobstructed(user, trueTarget.Transform.MapPosition)) { return(false); } var transferAmount = ReagentUnit.Min(_transferAmount, _contents.CurrentVolume); var split = _contents.SplitSolution(transferAmount); if (!stomach.TryTransferSolution(split)) { _contents.TryAddSolution(split); trueTarget.PopupMessage(user, Loc.GetString("You can't eat any more!")); return(false); } if (_useSound != null) { _entitySystem.GetEntitySystem <AudioSystem>() .PlayFromEntity(_useSound, trueTarget, AudioParams.Default.WithVolume(-1f)); } trueTarget.PopupMessage(user, Loc.GetString("You swallow the pill.")); Owner.Delete(); return(true); }