private void OnGotEquipped(EntityUid uid, SpillableComponent component, GotEquippedEvent args) { if (!component.SpillWorn) { return; } if (!TryComp(uid, out ClothingComponent? clothing)) { return; } // check if entity was actually used as clothing // not just taken in pockets or something var isCorrectSlot = clothing.SlotFlags.HasFlag(args.SlotFlags); if (!isCorrectSlot) { return; } if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var solution)) { return; } if (solution.TotalVolume == 0) { return; } // spill all solution on the player var drainedSolution = _solutionContainerSystem.Drain(uid, solution, solution.DrainAvailable); SpillAt(args.Equipee, drainedSolution, "PuddleSmear"); }
private void HandleLand(EntityUid uid, DrinkComponent component, LandEvent args) { if (component.Pressurized && !component.Opened && _random.Prob(0.25f) && _solutionContainerSystem.TryGetDrainableSolution(uid, out var interactions)) { component.Opened = true; UpdateAppearance(component); var solution = _solutionContainerSystem.Drain(uid, interactions, interactions.DrainAvailable); _spillableSystem.SpillAt(uid, solution, "PuddleSmear"); SoundSystem.Play(Filter.Pvs(uid), component.BurstSound.GetSound(), uid, AudioParams.Default.WithVolume(-4)); } }
private void OnAfterInteract(EntityUid uid, FireExtinguisherComponent component, AfterInteractEvent args) { if (args.Target == null || !args.CanReach) { return; } if (args.Handled) { return; } args.Handled = true; if (component.HasSafety && component.Safety) { _popupSystem.PopupEntity(Loc.GetString("fire-extinguisher-component-safety-on-message"), uid, Filter.Entities(args.User)); return; } if (args.Target is not { Valid : true } target || !_solutionContainerSystem.TryGetDrainableSolution(target, out var targetSolution) || !_solutionContainerSystem.TryGetRefillableSolution(uid, out var container)) { return; } var transfer = container.AvailableVolume; if (TryComp <SolutionTransferComponent>(uid, out var solTrans)) { transfer = solTrans.TransferAmount; } transfer = FixedPoint2.Min(transfer, targetSolution.DrainAvailable); if (transfer > 0) { var drained = _solutionContainerSystem.Drain(target, targetSolution, transfer); _solutionContainerSystem.TryAddSolution(uid, container, drained); SoundSystem.Play(Filter.Pvs(uid), component.RefillSound.GetSound(), uid); _popupSystem.PopupEntity(Loc.GetString("fire-extinguisher-component-after-interact-refilled-message", ("owner", uid)), uid, Filter.Entities(args.Target.Value)); } }
private void SpillOnLand(EntityUid uid, SpillableComponent component, LandEvent args) { if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var solution)) { return; } if (args.User != null) { _logSystem.Add(LogType.Landed, $"{EntityManager.ToPrettyString(uid)} spilled {SolutionContainerSystem.ToPrettyString(solution)} on landing"); } var drainedSolution = _solutionContainerSystem.Drain(uid, solution, solution.DrainAvailable); SpillAt(drainedSolution, EntityManager.GetComponent <TransformComponent>(uid).Coordinates, "PuddleSmear"); }
private void OnInteractUsing(EntityUid uid, PlantHolderComponent component, InteractUsingEvent args) { if (TryComp(args.Used, out SeedComponent? seeds)) { if (component.Seed == null) { if (!_botanySystem.TryGetSeed(seeds, out var seed)) { return; } _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-plant-success-message", ("seedName", seed.Name), ("seedNoun", seed.Noun)), Filter.Entities(args.User), PopupType.Medium); component.Seed = seed; component.Dead = false; component.Age = 1; component.Health = component.Seed.Endurance; component.LastCycle = _gameTiming.CurTime; EntityManager.QueueDeleteEntity(args.Used); component.CheckLevelSanity(); component.UpdateSprite(); return; } _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-already-seeded-message", ("name", Comp <MetaDataComponent>(uid).EntityName)), Filter.Entities(args.User), PopupType.Medium); return; } if (_tagSystem.HasTag(args.Used, "Hoe")) { if (component.WeedLevel > 0) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-remove-weeds-message", ("name", Comp <MetaDataComponent>(uid).EntityName)), Filter.Entities(args.User), PopupType.Medium); _popupSystem.PopupEntity(Loc.GetString("plant-holder-component-remove-weeds-others-message", ("otherName", Comp <MetaDataComponent>(args.User).EntityName)), uid, Filter.PvsExcept(args.User)); component.WeedLevel = 0; component.UpdateSprite(); } else { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-no-weeds-message"), Filter.Entities(args.User)); } return; } if (_tagSystem.HasTag(args.Used, "Shovel")) { if (component.Seed != null) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-remove-plant-message", ("name", Comp <MetaDataComponent>(uid).EntityName)), Filter.Entities(args.User), PopupType.Medium); _popupSystem.PopupEntity(Loc.GetString("plant-holder-component-remove-plant-others-message", ("name", Comp <MetaDataComponent>(args.User).EntityName)), uid, Filter.PvsExcept(args.User)); component.RemovePlant(); } else { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-no-plant-message", ("name", Comp <MetaDataComponent>(uid).EntityName)), Filter.Entities(args.User)); } return; } if (_solutionSystem.TryGetDrainableSolution(args.Used, out var solution) && _solutionSystem.TryGetSolution(uid, component.SoilSolutionName, out var targetSolution) && TryComp(args.Used, out SprayComponent? spray)) { var amount = FixedPoint2.New(1); var targetEntity = uid; var solutionEntity = args.Used; SoundSystem.Play(spray.SpraySound.GetSound(), Filter.Pvs(args.Used), args.Used, AudioHelpers.WithVariation(0.125f)); var split = _solutionSystem.Drain(solutionEntity, solution, amount); if (split.TotalVolume == 0) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-no-plant-message", ("owner", args.Used)), Filter.Entities(args.User)); return; } _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-spray-message", ("owner", uid), ("amount", split.TotalVolume)), Filter.Entities(args.User), PopupType.Medium); _solutionSystem.TryAddSolution(targetEntity, targetSolution, split); component.ForceUpdateByExternalCause(); return; } if (_tagSystem.HasTag(args.Used, "PlantSampleTaker")) { if (component.Seed == null) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-nothing-to-sample-message"), Filter.Entities(args.User)); return; } if (component.Sampled) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-already-sampled-message"), Filter.Entities(args.User)); return; } if (component.Dead) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-dead-plant-message"), Filter.Entities(args.User)); return; } component.Seed.Unique = false; var seed = _botanySystem.SpawnSeedPacket(component.Seed, Transform(args.User).Coordinates); seed.RandomOffset(0.25f); _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-take-sample-message", ("seedName", component.Seed.DisplayName)), Filter.Entities(args.User)); component.Health -= (_random.Next(3, 5) * 10); if (_random.Prob(0.3f)) { component.Sampled = true; } // Just in case. component.CheckLevelSanity(); component.ForceUpdateByExternalCause(); return; } if (HasComp <SharpComponent>(args.Used)) { component.DoHarvest(args.User); } if (TryComp <ProduceComponent?>(args.Used, out var produce)) { _popupSystem.PopupCursor(Loc.GetString("plant-holder-component-compost-message", ("owner", uid), ("usingItem", args.Used)), Filter.Entities(args.User), PopupType.Medium); _popupSystem.PopupEntity(Loc.GetString("plant-holder-component-compost-others-message", ("user", Identity.Entity(args.User, EntityManager)), ("usingItem", args.Used), ("owner", uid)), uid, Filter.PvsExcept(args.User)); if (_solutionSystem.TryGetSolution(args.Used, produce.SolutionName, out var solution2)) { // This deliberately discards overfill. _solutionSystem.TryAddSolution(args.Used, solution2, _solutionSystem.SplitSolution(args.Used, solution2, solution2.TotalVolume)); component.ForceUpdateByExternalCause(); } EntityManager.QueueDeleteEntity(args.Used); } }