public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) { if (args.Length == 0) { var result = new StringBuilder(); foreach (Faction value in Enum.GetValues(typeof(Faction))) { if (value == Faction.None) { continue; } result.Append(value + "\n"); } shell.SendText(player, result.ToString()); return; } if (args.Length < 2) { shell.SendText(player, Loc.GetString("Need more args")); return; } if (!Enum.TryParse(args[0], true, out Faction faction)) { shell.SendText(player, Loc.GetString("Invalid faction")); return; } Faction targetFaction; switch (args[1]) { case "friendly": if (args.Length < 3) { shell.SendText(player, Loc.GetString("Need to supply a target faction")); return; } if (!Enum.TryParse(args[2], true, out targetFaction)) { shell.SendText(player, Loc.GetString("Invalid target faction")); return; } EntitySystem.Get <AiFactionTagSystem>().MakeFriendly(faction, targetFaction); shell.SendText(player, Loc.GetString("Command successful")); break; case "hostile": if (args.Length < 3) { shell.SendText(player, Loc.GetString("Need to supply a target faction")); return; } if (!Enum.TryParse(args[2], true, out targetFaction)) { shell.SendText(player, Loc.GetString("Invalid target faction")); return; } EntitySystem.Get <AiFactionTagSystem>().MakeHostile(faction, targetFaction); shell.SendText(player, Loc.GetString("Command successful")); break; case "list": shell.SendText(player, EntitySystem.Get <AiFactionTagSystem>().GetHostileFactions(faction).ToString()); break; default: shell.SendText(player, Loc.GetString("Unknown faction arg")); break; } return; }
public void Examine(FormattedMessage message, bool inDetailsRange) { var text = Loc.GetString("ammo-component-on-examine", ("caliber", Caliber)); message.AddMarkup(text); }
public async Task <bool> InteractUsing(InteractUsingEventArgs eventArgs) { var user = eventArgs.User; var usingItem = eventArgs.Using; if (usingItem == null || usingItem.Deleted || !ActionBlockerSystem.CanInteract(user)) { return(false); } if (usingItem.TryGetComponent(out SeedComponent? seeds)) { if (Seed == null) { if (seeds.Seed == null) { user.PopupMessageCursor(Loc.GetString("The packet seems to be empty. You throw it away.")); usingItem.Delete(); return(false); } user.PopupMessageCursor(Loc.GetString("You plant the {0} {1}.", seeds.Seed.SeedName, seeds.Seed.SeedNoun)); Seed = seeds.Seed; Dead = false; Age = 1; Health = Seed.Endurance; _lastCycle = _gameTiming.CurTime; usingItem.Delete(); CheckLevelSanity(); UpdateSprite(); return(true); } user.PopupMessageCursor(Loc.GetString("The {0} already has seeds in it!", Owner.Name)); return(false); } if (usingItem.HasComponent <HoeComponent>()) { if (WeedLevel > 0) { user.PopupMessageCursor(Loc.GetString("You remove the weeds from the {0}.", Owner.Name)); user.PopupMessageOtherClients(Loc.GetString("{0} starts uprooting the weeds.", user.Name)); WeedLevel = 0; UpdateSprite(); } else { user.PopupMessageCursor(Loc.GetString("This plot is devoid of weeds! It doesn't need uprooting.")); } return(true); } if (usingItem.TryGetComponent(out SolutionContainerComponent? solution) && solution.CanRemoveSolutions) { var amount = 5f; var sprayed = false; if (usingItem.TryGetComponent(out SprayComponent? spray)) { sprayed = true; amount = 1f; EntitySystem.Get <AudioSystem>().PlayFromEntity(spray.SpraySound, usingItem, AudioHelpers.WithVariation(0.125f)); } var chemAmount = ReagentUnit.New(amount); var split = solution.Solution.SplitSolution(chemAmount <= solution.Solution.TotalVolume ? chemAmount : solution.Solution.TotalVolume); user.PopupMessageCursor(Loc.GetString(sprayed ? $"You spray {Owner.Name} with {usingItem.Name}." : $"You transfer {split.TotalVolume.ToString()}u to {Owner.Name}")); _solutionContainer?.TryAddSolution(split); SkipAging++; // We're forcing an update cycle, so one age hasn't passed. ForceUpdate = true; Update(); return(true); } if (usingItem.HasComponent <PlantSampleTakerComponent>()) { if (Seed == null) { user.PopupMessageCursor(Loc.GetString("There is nothing to take a sample of!")); return(false); } if (Sampled) { user.PopupMessageCursor(Loc.GetString("This plant has already been sampled.")); return(false); } if (Dead) { user.PopupMessageCursor(Loc.GetString("This plant is dead.")); return(false); } var seed = Seed.SpawnSeedPacket(user.Transform.Coordinates); seed.RandomOffset(0.25f); user.PopupMessageCursor(Loc.GetString($"You take a sample from the {Seed.DisplayName}.")); Health -= (_random.Next(3, 5) * 10); if (_random.Prob(0.3f)) { Sampled = true; } // Just in case. CheckLevelSanity(); SkipAging++; // We're forcing an update cycle, so one age hasn't passed. ForceUpdate = true; Update(); return(true); } if (usingItem.HasComponent <BotanySharpComponent>()) { return(DoHarvest(user)); } return(false); }
public void Examine(FormattedMessage message, bool inDetailsRange) { message.AddMarkup(Loc.GetString("Requires:\n")); foreach (var(part, amount) in Requirements) { message.AddMarkup(Loc.GetString("[color=yellow]{0}x[/color] [color=green]{1}[/color]\n", amount, Loc.GetString(part.ToString()))); } foreach (var(material, amount) in MaterialRequirements) { message.AddMarkup(Loc.GetString("[color=yellow]{0}x[/color] [color=green]{1}[/color]\n", amount, Loc.GetString(material.ToString()))); } foreach (var(_, info) in ComponentRequirements) { message.AddMarkup(Loc.GetString("[color=yellow]{0}x[/color] [color=green]{1}[/color]\n", info.Amount, Loc.GetString(info.ExamineName))); } }
public void UpdateText() { Button.Text = Binding?.GetKeyString() ?? Loc.GetString("ui-options-unbound"); }
private void ConnectionStateChanged(ClientConnectionState state) { ConnectStatus.Text = Loc.GetString($"connecting-state-{state}"); }
public CharacterPickerButton( IEntityManager entityManager, IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager, ButtonGroup group, ICharacterProfile profile) { AddStyleClass(StyleClassButton); ToggleMode = true; Group = group; var humanoid = profile as HumanoidCharacterProfile; if (humanoid is not null) { var dummy = prototypeManager.Index <SpeciesPrototype>(humanoid.Species).DollPrototype; _previewDummy = entityManager.SpawnEntity(dummy, MapCoordinates.Nullspace); } else { _previewDummy = entityManager.SpawnEntity(prototypeManager.Index <SpeciesPrototype>(SpeciesManager.DefaultSpecies).DollPrototype, MapCoordinates.Nullspace); } EntitySystem.Get <SharedHumanoidAppearanceSystem>().UpdateFromProfile(_previewDummy, profile); if (humanoid != null) { LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy, humanoid); } var isSelectedCharacter = profile == preferencesManager.Preferences?.SelectedCharacter; if (isSelectedCharacter) { Pressed = true; } var view = new SpriteView { Sprite = entityManager.GetComponent <SpriteComponent>(_previewDummy), Scale = (2, 2), OverrideDirection = Direction.South }; var description = profile.Name; var highPriorityJob = humanoid?.JobPriorities.SingleOrDefault(p => p.Value == JobPriority.High).Key; if (highPriorityJob != null) { var jobName = IoCManager.Resolve <IPrototypeManager>().Index <JobPrototype>(highPriorityJob).Name; description = $"{description}\n{jobName}"; } var descriptionLabel = new Label { Text = description, ClipText = true, HorizontalExpand = true }; var deleteButton = new Button { Text = Loc.GetString("character-setup-gui-character-picker-button-delete-button"), Visible = !isSelectedCharacter, }; deleteButton.OnPressed += _ => { Parent?.RemoveChild(this); preferencesManager.DeleteCharacter(profile); }; var internalHBox = new BoxContainer { Orientation = LayoutOrientation.Horizontal, HorizontalExpand = true, SeparationOverride = 0, Children = { view, descriptionLabel, deleteButton } }; AddChild(internalHBox); }
public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, RoundEndMessageEvent.RoundEndPlayerInfo[] info) { MinSize = SetSize = (520, 580); Title = Loc.GetString("round-end-summary-window-title"); //Round End Window is split into two tabs, one about the round stats //and the other is a list of RoundEndPlayerInfo for each player. //This tab would be a good place for things like: "x many people died.", //"clown slipped the crew x times.", "x shots were fired this round.", etc. //Also good for serious info. RoundEndSummaryTab = new VBoxContainer() { Name = Loc.GetString("round-end-summary-window-round-end-summary-tab-title") }; //Tab for listing unique info per player. PlayerManifestoTab = new VBoxContainer() { Name = Loc.GetString("round-end-summary-window-player-manifesto-tab-title") }; RoundEndWindowTabs = new TabContainer(); RoundEndWindowTabs.AddChild(RoundEndSummaryTab); RoundEndWindowTabs.AddChild(PlayerManifestoTab); Contents.AddChild(RoundEndWindowTabs); //Gamemode Name var gamemodeLabel = new RichTextLabel(); gamemodeLabel.SetMarkup(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gm))); RoundEndSummaryTab.AddChild(gamemodeLabel); //Round end text if (!string.IsNullOrEmpty(roundEnd)) { var roundEndLabel = new RichTextLabel(); roundEndLabel.SetMarkup(Loc.GetString(roundEnd)); RoundEndSummaryTab.AddChild(roundEndLabel); } //Duration var roundTimeLabel = new RichTextLabel(); roundTimeLabel.SetMarkup(Loc.GetString("round-end-summary-window-duration-label", ("hours", roundTimeSpan.Hours), ("minutes", roundTimeSpan.Minutes), ("seconds", roundTimeSpan.Seconds))); RoundEndSummaryTab.AddChild(roundTimeLabel); //Initialize what will be the list of players display. var scrollContainer = new ScrollContainer { VerticalExpand = true }; var innerScrollContainer = new VBoxContainer(); //Put observers at the bottom of the list. Put antags on top. var manifestSortedList = info.OrderBy(p => p.Observer).ThenBy(p => !p.Antag); //Create labels for each player info. foreach (var playerInfo in manifestSortedList) { var playerInfoText = new RichTextLabel(); if (playerInfo.PlayerICName != null) { if (playerInfo.Observer) { playerInfoText.SetMarkup( Loc.GetString("round-end-summary-window-player-info-if-observer-text", ("playerOOCName", playerInfo.PlayerOOCName), ("playerICName", playerInfo.PlayerICName))); } else { //TODO: On Hover display a popup detailing more play info. //For example: their antag goals and if they completed them sucessfully. var icNameColor = playerInfo.Antag ? "red" : "white"; playerInfoText.SetMarkup( Loc.GetString("round-end-summary-window-player-info-if-not-observer-text", ("playerOOCName", playerInfo.PlayerOOCName), ("icNameColor", icNameColor), ("playerICName", playerInfo.PlayerICName), ("playerRole", Loc.GetString(playerInfo.Role)))); } } innerScrollContainer.AddChild(playerInfoText); } scrollContainer.AddChild(innerScrollContainer); //Attach the entire ScrollContainer that holds all the playerinfo. PlayerManifestoTab.AddChild(scrollContainer); //Finally, display the window. OpenCentered(); MoveToFront(); }
public Button MachineLinkingButton; // Enables/disables machine linking mode. public SandboxWindow() { Resizable = false; Title = "Sandbox Panel"; var vBox = new VBoxContainer { SeparationOverride = 4 }; Contents.AddChild(vBox); RespawnButton = new Button { Text = Loc.GetString("Respawn") }; vBox.AddChild(RespawnButton); SpawnEntitiesButton = new Button { Text = Loc.GetString("Spawn Entities") }; vBox.AddChild(SpawnEntitiesButton); SpawnTilesButton = new Button { Text = Loc.GetString("Spawn Tiles") }; vBox.AddChild(SpawnTilesButton); GiveFullAccessButton = new Button { Text = Loc.GetString("Grant Full Access") }; vBox.AddChild(GiveFullAccessButton); GiveAghostButton = new Button { Text = Loc.GetString("Ghost") }; vBox.AddChild(GiveAghostButton); ToggleLightButton = new Button { Text = Loc.GetString("Toggle Lights"), ToggleMode = true }; vBox.AddChild(ToggleLightButton); ToggleFovButton = new Button { Text = Loc.GetString("Toggle FOV"), ToggleMode = true }; vBox.AddChild(ToggleFovButton); ToggleShadowsButton = new Button { Text = Loc.GetString("Toggle Shadows"), ToggleMode = true }; vBox.AddChild(ToggleShadowsButton); ToggleSubfloorButton = new Button { Text = Loc.GetString("Toggle Subfloor"), ToggleMode = true }; vBox.AddChild(ToggleSubfloorButton); SuicideButton = new Button { Text = Loc.GetString("Suicide") }; vBox.AddChild(SuicideButton); ShowMarkersButton = new Button { Text = Loc.GetString("Show Spawns"), ToggleMode = true }; vBox.AddChild(ShowMarkersButton); ShowBbButton = new Button { Text = Loc.GetString("Show Bb"), ToggleMode = true }; vBox.AddChild(ShowBbButton); MachineLinkingButton = new Button { Text = Loc.GetString("Link machines"), ToggleMode = true }; vBox.AddChild(MachineLinkingButton); }
private void OnForceFeed(EntityUid uid, SharedBodyComponent body, ForceFeedEvent args) { if (args.Food.Deleted) { return; } args.Food.CancelToken = null; if (!_bodySystem.TryGetComponentsOnMechanisms <StomachComponent>(uid, out var stomachs, body)) { return; } var transferAmount = args.Food.TransferAmount != null ? FixedPoint2.Min((FixedPoint2)args.Food.TransferAmount, args.FoodSolution.CurrentVolume) : args.FoodSolution.CurrentVolume; var split = _solutionContainerSystem.SplitSolution((args.Food).Owner, args.FoodSolution, transferAmount); var firstStomach = stomachs.FirstOrNull( stomach => _stomachSystem.CanTransferSolution((stomach.Comp).Owner, split)); if (firstStomach == null) { _solutionContainerSystem.TryAddSolution(uid, args.FoodSolution, split); _popupSystem.PopupEntity(Loc.GetString("food-system-you-cannot-eat-any-more-other"), uid, Filter.Entities(args.User)); return; } split.DoEntityReaction(uid, ReactionMethod.Ingestion); _stomachSystem.TryTransferSolution((firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp); EntityManager.TryGetComponent(uid, out MetaDataComponent? targetMeta); var targetName = targetMeta?.EntityName ?? string.Empty; EntityManager.TryGetComponent(args.User, out MetaDataComponent? userMeta); var userName = userMeta?.EntityName ?? string.Empty; _popupSystem.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName)), uid, Filter.Entities(uid)); _popupSystem.PopupEntity(Loc.GetString("food-system-force-feed-success-user", ("target", targetName)), args.User, Filter.Entities(args.User)); SoundSystem.Play(Filter.Pvs(uid), args.Food.UseSound.GetSound(), uid, AudioParams.Default.WithVolume(-1f)); // Try to break all used utensils foreach (var utensil in args.Utensils) { _utensilSystem.TryBreak((utensil).Owner, args.User); } if (args.Food.UsesRemaining > 0) { return; } if (string.IsNullOrEmpty(args.Food.TrashPrototype)) { EntityManager.QueueDeleteEntity((args.Food).Owner); } else { DeleteAndSpawnTrash(args.Food, args.User); } }
/// <summary> /// Force feeds someone remotely. Does not require utensils (well, not the normal type anyways). /// </summary> public void ProjectileForceFeed(EntityUid uid, EntityUid target, EntityUid?user, FoodComponent?food = null, BodyComponent?body = null) { if (!Resolve(uid, ref food) || !Resolve(target, ref body, false)) { return; } if (IsMouthBlocked(target)) { return; } if (!_solutionContainerSystem.TryGetSolution(uid, food.SolutionName, out var foodSolution)) { return; } if (!_bodySystem.TryGetComponentsOnMechanisms <StomachComponent>(target, out var stomachs, body)) { return; } if (food.UsesRemaining <= 0) { DeleteAndSpawnTrash(food); } var firstStomach = stomachs.FirstOrNull( stomach => _stomachSystem.CanTransferSolution(((IComponent)stomach.Comp).Owner, foodSolution)); if (firstStomach == null) { return; } // logging if (user == null) { _logSystem.Add(LogType.ForceFeed, $"{ToPrettyString(uid):food} {SolutionContainerSystem.ToPrettyString(foodSolution):solution} was thrown into the mouth of {ToPrettyString(target):target}"); } else { _logSystem.Add(LogType.ForceFeed, $"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):food} {SolutionContainerSystem.ToPrettyString(foodSolution):solution} into the mouth of {ToPrettyString(target):target}"); } var filter = user == null?Filter.Entities(target) : Filter.Entities(target, user.Value); _popupSystem.PopupEntity(Loc.GetString(food.EatMessage), target, filter); foodSolution.DoEntityReaction(uid, ReactionMethod.Ingestion); _stomachSystem.TryTransferSolution(((IComponent)firstStomach.Value.Comp).Owner, foodSolution, firstStomach.Value.Comp); SoundSystem.Play(Filter.Pvs(target), food.UseSound.GetSound(), target, AudioParams.Default.WithVolume(-1f)); if (string.IsNullOrEmpty(food.TrashPrototype)) { EntityManager.QueueDeleteEntity(((IComponent)food).Owner); } else { DeleteAndSpawnTrash(food); } }
/// <summary> /// Attempts to force feed a target. Returns true if any interaction occurred, including pop-up generation /// </summary> public bool TryForceFeed(EntityUid uid, EntityUid user, EntityUid target, FoodComponent?food = null) { if (!Resolve(uid, ref food)) { return(false); } // if currently being used to force-feed, cancel that action. if (food.CancelToken != null) { food.CancelToken.Cancel(); food.CancelToken = null; return(true); } if (!EntityManager.HasComponent <SharedBodyComponent>(target)) { return(false); } if (!_solutionContainerSystem.TryGetSolution(uid, food.SolutionName, out var foodSolution)) { return(false); } if (food.UsesRemaining <= 0) { _popupSystem.PopupEntity(Loc.GetString("food-system-try-use-food-is-empty", ("entity", uid)), user, Filter.Entities(user)); DeleteAndSpawnTrash(food, user); return(true); } if (IsMouthBlocked(target, user)) { return(true); } if (!TryGetRequiredUtensils(user, food, out var utensils)) { return(true); } EntityManager.TryGetComponent(user, out MetaDataComponent? meta); var userName = meta?.EntityName ?? string.Empty; _popupSystem.PopupEntity(Loc.GetString("food-system-force-feed", ("user", userName)), user, Filter.Entities(target)); food.CancelToken = new(); _doAfterSystem.DoAfter(new DoAfterEventArgs(user, food.ForceFeedDelay, food.CancelToken.Token, target) { BreakOnUserMove = true, BreakOnDamage = true, BreakOnStun = true, BreakOnTargetMove = true, MovementThreshold = 1.0f, TargetFinishedEvent = new ForceFeedEvent(user, food, foodSolution, utensils), BroadcastCancelledEvent = new ForceFeedCancelledEvent(food) }); // logging _logSystem.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(user):user} is forcing {ToPrettyString(target):target} to eat {ToPrettyString(uid):food} {SolutionContainerSystem.ToPrettyString(foodSolution):solution}"); return(true); }
/// <summary> /// Tries to eat some food /// </summary> /// <param name="uid">Food entity.</param> /// <param name="user">Feeding initiator.</param> /// <returns>True if an interaction occurred (i.e., food was consumed, or a pop-up message was created)</returns> public bool TryUseFood(EntityUid uid, EntityUid user, FoodComponent?food = null) { if (!Resolve(uid, ref food)) { return(false); } // if currently being used to force-feed, cancel that action. if (food.CancelToken != null) { food.CancelToken.Cancel(); food.CancelToken = null; return(true); } if (uid == user || //Suppresses self-eating EntityManager.TryGetComponent <MobStateComponent>(uid, out var mobState) && mobState.IsAlive()) // Suppresses eating alive mobs { return(false); } if (!_solutionContainerSystem.TryGetSolution(uid, food.SolutionName, out var solution)) { return(false); } if (food.UsesRemaining <= 0) { _popupSystem.PopupEntity(Loc.GetString("food-system-try-use-food-is-empty", ("entity", uid)), user, Filter.Entities(user)); DeleteAndSpawnTrash(food, user); return(true); } if (!EntityManager.TryGetComponent(user, out SharedBodyComponent ? body) || !_bodySystem.TryGetComponentsOnMechanisms <StomachComponent>(user, out var stomachs, body)) { return(false); } if (IsMouthBlocked(user, user)) { return(true); } var usedUtensils = new List <UtensilComponent>(); if (!TryGetRequiredUtensils(user, food, out var utensils)) { return(true); } if (!user.InRangeUnobstructed(uid, popup: true)) { return(true); } var transferAmount = food.TransferAmount != null?FixedPoint2.Min((FixedPoint2)food.TransferAmount, solution.CurrentVolume) : solution.CurrentVolume; var split = _solutionContainerSystem.SplitSolution(uid, solution, transferAmount); var firstStomach = stomachs.FirstOrNull( stomach => _stomachSystem.CanTransferSolution((stomach.Comp).Owner, split)); if (firstStomach == null) { _solutionContainerSystem.TryAddSolution(uid, solution, split); _popupSystem.PopupEntity(Loc.GetString("food-system-you-cannot-eat-any-more"), user, Filter.Entities(user)); return(true); } // TODO: Account for partial transfer. split.DoEntityReaction(user, ReactionMethod.Ingestion); _stomachSystem.TryTransferSolution((firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp); SoundSystem.Play(Filter.Pvs(user), food.UseSound.GetSound(), user, AudioParams.Default.WithVolume(-1f)); _popupSystem.PopupEntity(Loc.GetString(food.EatMessage, ("food", food.Owner)), user, Filter.Entities(user)); // Try to break all used utensils foreach (var utensil in usedUtensils) { _utensilSystem.TryBreak((utensil).Owner, user); } if (food.UsesRemaining > 0) { return(true); } if (string.IsNullOrEmpty(food.TrashPrototype)) { EntityManager.QueueDeleteEntity((food).Owner); } else { DeleteAndSpawnTrash(food, user); } return(true); }
protected override void CreamedEntity(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args) { creamPied.Owner.PopupMessage(Loc.GetString("cream-pied-component-on-hit-by-message", ("thrower", args.Thrown))); creamPied.Owner.PopupMessageOtherClients(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", creamPied.Owner), ("thrower", args.Thrown))); }
public virtual bool TryUseFood(IEntity?user, IEntity?target, UtensilComponent?utensilUsed = null) { if (!Owner.TryGetComponent(out SolutionContainerComponent? solution)) { return(false); } if (user == null) { return(false); } if (UsesRemaining <= 0) { user.PopupMessage(Loc.GetString("{0:TheName} is empty!", Owner)); return(false); } var trueTarget = target ?? user; if (!trueTarget.TryGetComponent(out IBody? body) || !body.TryGetMechanismBehaviors <StomachBehavior>(out var stomachs)) { return(false); } var utensils = utensilUsed != null ? new List <UtensilComponent> { utensilUsed } : null; if (_utensilsNeeded != UtensilType.None) { utensils = new List <UtensilComponent>(); var types = UtensilType.None; if (user.TryGetComponent(out HandsComponent? hands)) { foreach (var item in hands.GetAllHeldItems()) { if (!item.Owner.TryGetComponent(out UtensilComponent? utensil)) { continue; } utensils.Add(utensil); types |= utensil.Types; } } if (!types.HasFlag(_utensilsNeeded)) { trueTarget.PopupMessage(user, Loc.GetString("You need to be holding a {0} to eat that!", _utensilsNeeded)); return(false); } } if (!user.InRangeUnobstructed(trueTarget, popup: true)) { return(false); } var transferAmount = ReagentUnit.Min(_transferAmount, solution.CurrentVolume); var split = solution.SplitSolution(transferAmount); var firstStomach = stomachs.FirstOrDefault(stomach => stomach.CanTransferSolution(split)); if (firstStomach == null) { trueTarget.PopupMessage(user, Loc.GetString("You can't eat any more!")); return(false); } // TODO: Account for partial transfer. split.DoEntityReaction(trueTarget, ReactionMethod.Ingestion); firstStomach.TryTransferSolution(split); _entitySystem.GetEntitySystem <AudioSystem>() .PlayFromEntity(_useSound, trueTarget, AudioParams.Default.WithVolume(-1f)); trueTarget.PopupMessage(user, Loc.GetString("Nom")); // If utensils were used if (utensils != null) { foreach (var utensil in utensils) { utensil.TryBreak(user); } } if (UsesRemaining > 0) { return(true); } if (string.IsNullOrEmpty(_trashPrototype)) { Owner.Delete(); return(true); } //We're empty. Become trash. var position = Owner.Transform.Coordinates; var finisher = Owner.EntityManager.SpawnEntity(_trashPrototype, position); // If the user is holding the item if (user.TryGetComponent(out HandsComponent? handsComponent) && handsComponent.IsHolding(Owner)) { Owner.Delete(); // Put the trash in the user's hand if (finisher.TryGetComponent(out ItemComponent? item) && handsComponent.CanPutInHand(item)) { handsComponent.PutInHand(item); } }
async Task <bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { var user = eventArgs.User; var usingItem = eventArgs.Using; if (usingItem == null || usingItem.Deleted || !EntitySystem.Get <ActionBlockerSystem>().CanInteract(user)) { return(false); } if (usingItem.TryGetComponent(out SeedComponent? seeds)) { if (Seed == null) { if (seeds.Seed == null) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-empty-seed-packet-message")); usingItem.QueueDelete(); return(false); } user.PopupMessageCursor(Loc.GetString("plant-holder-component-plant-success-message", ("seedName", seeds.Seed.SeedName), ("seedNoun", seeds.Seed.SeedNoun))); Seed = seeds.Seed; Dead = false; Age = 1; Health = Seed.Endurance; _lastCycle = _gameTiming.CurTime; usingItem.QueueDelete(); CheckLevelSanity(); UpdateSprite(); return(true); } user.PopupMessageCursor(Loc.GetString("plant-holder-component-already-seeded-message", ("name", Owner.Name))); return(false); } if (usingItem.HasTag("Hoe")) { if (WeedLevel > 0) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-remove-weeds-message", ("name", Owner.Name))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-weeds-others-message", ("otherName", user.Name))); WeedLevel = 0; UpdateSprite(); } else { user.PopupMessageCursor(Loc.GetString("plant-holder-component-no-weeds-message")); } return(true); } if (usingItem.HasTag("Shovel")) { if (Seed != null) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-remove-plant-message", ("name", Owner.Name))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-plant-others-message", ("name", user.Name))); RemovePlant(); } else { user.PopupMessageCursor(Loc.GetString("plant-holder-component-no-plant-message")); } return(true); } if (usingItem.TryGetComponent(out ISolutionInteractionsComponent? solution) && solution.CanDrain) { var amount = ReagentUnit.New(5); var sprayed = false; if (usingItem.TryGetComponent(out SprayComponent? spray)) { sprayed = true; amount = ReagentUnit.New(1); if (!string.IsNullOrEmpty(spray.SpraySound)) { SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound, usingItem, AudioHelpers.WithVariation(0.125f)); } } var split = solution.Drain(amount); if (split.TotalVolume == 0) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-empty-message", ("owner", usingItem))); return(true); } user.PopupMessageCursor(Loc.GetString(sprayed ? "plant-holder-component-spray-message" : "plant-holder-component-transfer-message", ("owner", Owner), ("amount", split.TotalVolume))); _solutionContainer?.TryAddSolution(split); ForceUpdateByExternalCause(); return(true); } if (usingItem.HasTag("PlantSampleTaker")) { if (Seed == null) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-nothing-to-sample-message")); return(false); } if (Sampled) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-already-sampled-message")); return(false); } if (Dead) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-dead-plant-message")); return(false); } var seed = Seed.SpawnSeedPacket(user.Transform.Coordinates); seed.RandomOffset(0.25f); user.PopupMessageCursor(Loc.GetString("plant-holder-component-take-sample-message", ("seedName", Seed.DisplayName))); Health -= (_random.Next(3, 5) * 10); if (_random.Prob(0.3f)) { Sampled = true; } // Just in case. CheckLevelSanity(); ForceUpdateByExternalCause(); return(true); } if (usingItem.HasTag("BotanySharp")) { return(DoHarvest(user)); } if (usingItem.HasComponent <ProduceComponent>()) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-compost-message", ("owner", Owner), ("usingItem", usingItem))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-compost-others-message", ("user", user), ("usingItem", usingItem), ("owner", Owner))); if (usingItem.TryGetComponent(out SolutionContainerComponent? solution2)) { // This deliberately discards overfill. _solutionContainer?.TryAddSolution(solution2.SplitSolution(solution2.Solution.TotalVolume)); ForceUpdateByExternalCause(); } usingItem.QueueDelete(); return(true); } return(false); }
public override string CureText() { return(Loc.GetString("diagnoser-cure-wait", ("time", MaxLength))); }
public void Examine(FormattedMessage message, bool inDetailsRange) { if (!inDetailsRange) { return; } if (Seed == null) { message.AddMarkup(Loc.GetString("plant-holder-component-nothing-planted-message") + "\n"); } else if (!Dead) { message.AddMarkup(Loc.GetString("plant-holder-component-something-already-growing-message", ("seedName", Seed.DisplayName), ("toBeForm", Seed.DisplayName.EndsWith('s') ? "are" : "is")) + "\n"); if (Health <= Seed.Endurance / 2) { message.AddMarkup(Loc.GetString("plant-holder-component-something-already-growing-low-health-message", ("healthState", Loc.GetString(Age > Seed.Lifespan ? "plant-holder-component-plant-old-adjective" : "plant-holder-component-plant-unhealthy-adjective"))) + "\n"); } } else { message.AddMarkup(Loc.GetString("plant-holder-component-dead-plant-matter-message") + "\n"); } if (WeedLevel >= 5) { message.AddMarkup(Loc.GetString("plant-holder-component-weed-high-level-message") + "\n"); } if (PestLevel >= 5) { message.AddMarkup(Loc.GetString("plant-holder-component-pest-high-level-message") + "\n"); } message.AddMarkup(Loc.GetString($"plant-holder-component-water-level-message", ("waterLevel", (int)WaterLevel)) + "\n"); message.AddMarkup(Loc.GetString($"plant-holder-component-nutrient-level-message", ("nutritionLevel", (int)NutritionLevel)) + "\n"); if (DrawWarnings) { if (Toxins > 40f) { message.AddMarkup(Loc.GetString("plant-holder-component-toxins-high-warning") + "\n"); } if (ImproperLight) { message.AddMarkup(Loc.GetString("plant-holder-component-light-improper-warning") + "\n"); } if (ImproperHeat) { message.AddMarkup(Loc.GetString("plant-holder-component-heat-improper-warning") + "\n"); } if (ImproperPressure) { message.AddMarkup(Loc.GetString("plant-holder-component-pressure-improper-warning") + "\n"); } if (_missingGas > 0) { message.AddMarkup(Loc.GetString("plant-holder-component-gas-missing-warning") + "\n"); } } }
private void ConnectFailReasonChanged(string?reason) { ConnectFailReason.Text = reason == null ? null : Loc.GetString("connecting-fail-reason", ("reason", reason)); }
private void OnDoAfterCancelled(EntityUid uid, ResistLockerComponent component, ResistDoAfterCancelled ev) { component.IsResisting = false; component.CancelToken = null; _popupSystem.PopupEntity(Loc.GetString("resist-locker-component-resist-interrupted"), ev.User, Filter.Entities(ev.User)); }
public ParticleAcceleratorControlMenu(ParticleAcceleratorBoundUserInterface owner) { _greyScaleShader = IoCManager.Resolve <IPrototypeManager>().Index <ShaderPrototype>("Greyscale").Instance(); Owner = owner; _drawNoiseGenerator = new NoiseGenerator(NoiseGenerator.NoiseType.Fbm); _drawNoiseGenerator.SetFrequency(0.5f); var resourceCache = IoCManager.Resolve <IResourceCache>(); var font = resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13); var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png"); MouseFilter = MouseFilterMode.Stop; _alarmControlAnimation = new Animation { Length = TimeSpan.FromSeconds(1), AnimationTracks = { new AnimationTrackControlProperty { Property = nameof(Control.Visible), KeyFrames = { new AnimationTrackProperty.KeyFrame(true, 0), new AnimationTrackProperty.KeyFrame(false, 0.75f), } } } }; var back = new StyleBoxTexture { Texture = panelTex, Modulate = Color.FromHex("#25252A"), }; back.SetPatchMargin(StyleBox.Margin.All, 10); var back2 = new StyleBoxTexture(back) { Modulate = Color.FromHex("#202023") }; AddChild(new PanelContainer { PanelOverride = back, MouseFilter = MouseFilterMode.Pass }); _stateSpinBox = new SpinBox { Value = 0, }; _stateSpinBox.IsValid = StrengthSpinBoxValid; _stateSpinBox.InitDefaultButtons(); _stateSpinBox.ValueChanged += PowerStateChanged; _stateSpinBox.LineEditDisabled = true; _offButton = new Button { ToggleMode = false, Text = "Off", StyleClasses = { StyleBase.ButtonOpenRight }, }; _offButton.OnPressed += args => owner.SendEnableMessage(false); _onButton = new Button { ToggleMode = false, Text = "On", StyleClasses = { StyleBase.ButtonOpenLeft }, }; _onButton.OnPressed += args => owner.SendEnableMessage(true); var closeButton = new TextureButton { StyleClasses = { "windowCloseButton" }, SizeFlagsHorizontal = SizeFlags.ShrinkEnd }; closeButton.OnPressed += args => Close(); var serviceManual = new Label { SizeFlagsHorizontal = SizeFlags.ShrinkCenter, StyleClasses = { StyleBase.StyleClassLabelSubText }, Text = Loc.GetString("Refer to p.132 of service manual") }; _drawLabel = new Label(); var imgSize = new Vector2(32, 32); AddChild(new VBoxContainer { Children = { new MarginContainer { MarginLeftOverride = 2, MarginTopOverride = 2, Children = { new Label { Text = Loc.GetString("Mark 2 Particle Accelerator"), FontOverride = font, FontColorOverride = StyleNano.NanoGold, }, new MarginContainer { MarginRightOverride = 8, Children = { closeButton } } } }, new PanelContainer { PanelOverride = new StyleBoxFlat { BackgroundColor = StyleNano.NanoGold }, CustomMinimumSize = (0, 2), },
public virtual bool TryUseFood(IEntity user, IEntity target, UtensilComponent utensilUsed = null) { if (user == null) { return(false); } if (UsesRemaining <= 0) { user.PopupMessage(user, Loc.GetString("{0:TheName} is empty!", Owner)); return(false); } var trueTarget = target ?? user; if (!trueTarget.TryGetComponent(out StomachComponent stomach)) { return(false); } var utensils = utensilUsed != null ? new List <UtensilComponent> { utensilUsed } : null; if (_utensilsNeeded != UtensilType.None) { utensils = new List <UtensilComponent>(); var types = UtensilType.None; if (user.TryGetComponent(out HandsComponent hands)) { foreach (var item in hands.GetAllHeldItems()) { if (!item.Owner.TryGetComponent(out UtensilComponent utensil)) { continue; } utensils.Add(utensil); types |= utensil.Types; } } if (!types.HasFlag(_utensilsNeeded)) { trueTarget.PopupMessage(user, Loc.GetString("You need to be holding a {0} to eat that!", _utensilsNeeded)); 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); } _entitySystem.GetEntitySystem <AudioSystem>() .PlayFromEntity(_useSound, trueTarget, AudioParams.Default.WithVolume(-1f)); trueTarget.PopupMessage(user, Loc.GetString("Nom")); // If utensils were used if (utensils != null) { foreach (var utensil in utensils) { utensil.TryBreak(user); } } if (UsesRemaining > 0) { return(true); } if (string.IsNullOrEmpty(_trashPrototype)) { Owner.Delete(); return(true); } //We're empty. Become trash. var position = Owner.Transform.GridPosition; var finisher = Owner.EntityManager.SpawnEntity(_trashPrototype, position); // If the user is holding the item if (user.TryGetComponent(out HandsComponent handsComponent) && handsComponent.IsHolding(Owner)) { Owner.Delete(); // Put the trash in the user's hand if (finisher.TryGetComponent(out ItemComponent item) && handsComponent.CanPutInHand(item)) { handsComponent.PutInHand(item); } }
private Button[] _gameButtons = new Button[3]; //used to disable/enable all game buttons public SpaceVillainArcadeMenu(SpaceVillainArcadeBoundUserInterface owner) { Title = Loc.GetString("Space Villain"); Owner = owner; var grid = new GridContainer { Columns = 1 }; var infoGrid = new GridContainer { Columns = 3 }; infoGrid.AddChild(new Label { Text = Loc.GetString("Player"), Align = Label.AlignMode.Center }); infoGrid.AddChild(new Label { Text = "|", Align = Label.AlignMode.Center }); _enemyNameLabel = new Label { Align = Label.AlignMode.Center }; infoGrid.AddChild(_enemyNameLabel); _playerInfoLabel = new Label { Align = Label.AlignMode.Center }; infoGrid.AddChild(_playerInfoLabel); infoGrid.AddChild(new Label { Text = "|", Align = Label.AlignMode.Center }); _enemyInfoLabel = new Label { Align = Label.AlignMode.Center }; infoGrid.AddChild(_enemyInfoLabel); var centerContainer = new CenterContainer(); centerContainer.AddChild(infoGrid); grid.AddChild(centerContainer); _playerActionLabel = new Label { Align = Label.AlignMode.Center }; grid.AddChild(_playerActionLabel); _enemyActionLabel = new Label { Align = Label.AlignMode.Center }; grid.AddChild(_enemyActionLabel); var buttonGrid = new GridContainer { Columns = 3 }; _gameButtons[0] = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.Attack) { Text = Loc.GetString("ATTACK") }; buttonGrid.AddChild(_gameButtons[0]); _gameButtons[1] = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.Heal) { Text = Loc.GetString("HEAL") }; buttonGrid.AddChild(_gameButtons[1]); _gameButtons[2] = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.Recharge) { Text = Loc.GetString("RECHARGE") }; buttonGrid.AddChild(_gameButtons[2]); centerContainer = new CenterContainer(); centerContainer.AddChild(buttonGrid); grid.AddChild(centerContainer); var newGame = new ActionButton(Owner, SharedSpaceVillainArcadeComponent.PlayerAction.NewGame) { Text = Loc.GetString("New Game") }; grid.AddChild(newGame); centerContainer = new CenterContainer(); centerContainer.AddChild(grid); Contents.AddChild(centerContainer); }
private static ILocValue FormatLoc(LocArgs args) { var id = ((LocValueString)args.Args[0]).Value; return(new LocValueString(Loc.GetString(id))); }
/// <summary> /// Updates the entry displaying the current specific heat, heat capacity, temperature, and thermal energy /// of the selected solution. /// </summary> /// <param name="solution">The selected solution.</param> private void UpdateThermalBox(Solution solution) { ThermalBox.DisposeAllChildren(); var specificHeatLabel = new Label(); specificHeatLabel.HorizontalExpand = true; specificHeatLabel.Margin = new Thickness(0, 1); specificHeatLabel.Text = Loc.GetString("admin-solutions-window-specific-heat-label", ("specificHeat", solution.SpecificHeat.ToString("G3"))); var heatCapacityLabel = new Label(); heatCapacityLabel.HorizontalExpand = true; heatCapacityLabel.Margin = new Thickness(0, 1); heatCapacityLabel.Text = Loc.GetString("admin-solutions-window-heat-capacity-label", ("heatCapacity", solution.HeatCapacity.ToString("G3"))); // Temperature entry: var temperatureBox = new BoxContainer(); temperatureBox.Orientation = BoxContainer.LayoutOrientation.Horizontal; temperatureBox.HorizontalExpand = true; temperatureBox.Margin = new Thickness(0, 1); var temperatureLabel = new Label(); temperatureLabel.HorizontalExpand = true; temperatureLabel.Margin = new Thickness(0, 1); temperatureLabel.Text = Loc.GetString("admin-solutions-window-temperature-label"); var temperatureSpin = new FloatSpinBox(1, 2); temperatureSpin.HorizontalExpand = true; temperatureSpin.Margin = new Thickness(0, 1); temperatureSpin.Value = solution.Temperature; temperatureSpin.OnValueChanged += SetTemperature; temperatureBox.AddChild(temperatureLabel); temperatureBox.AddChild(temperatureSpin); // Thermal energy entry: var thermalEnergyBox = new BoxContainer(); thermalEnergyBox.Orientation = BoxContainer.LayoutOrientation.Horizontal; thermalEnergyBox.HorizontalExpand = true; thermalEnergyBox.Margin = new Thickness(0, 1); var thermalEnergyLabel = new Label(); thermalEnergyLabel.HorizontalExpand = true; thermalEnergyLabel.Margin = new Thickness(0, 1); thermalEnergyLabel.Text = Loc.GetString("admin-solutions-window-thermal-energy-label"); var thermalEnergySpin = new FloatSpinBox(1, 2); thermalEnergySpin.HorizontalExpand = true; thermalEnergySpin.Margin = new Thickness(0, 1); thermalEnergySpin.Value = solution.ThermalEnergy; thermalEnergySpin.OnValueChanged += SetThermalEnergy; thermalEnergyBox.AddChild(thermalEnergyLabel); thermalEnergyBox.AddChild(thermalEnergySpin); ThermalBox.AddChild(specificHeatLabel); ThermalBox.AddChild(heatCapacityLabel); ThermalBox.AddChild(temperatureBox); ThermalBox.AddChild(thermalEnergyBox); }
private bool TryBuckle(IEntity user, IEntity to) { if (user == null || user == to) { return(false); } if (!ActionBlockerSystem.CanInteract(user)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't do that!")); return(false); } var strapPosition = Owner.Transform.MapPosition; var range = SharedInteractionSystem.InteractionRange / 2; if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't reach there!")); return(false); } if (!user.TryGetComponent(out HandsComponent hands)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You don't have hands!")); return(false); } if (hands.GetActiveHand != null) { _notifyManager.PopupMessage(user, user, Loc.GetString("Your hand isn't free!")); return(false); } if (BuckledTo != null) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You are already buckled in!" : "{0:They} are already buckled in!", Owner)); return(false); } if (!to.TryGetComponent(out StrapComponent strap)) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't buckle yourself there!" : "You can't buckle {0:them} there!", Owner)); return(false); } var parent = to.Transform.Parent; while (parent != null) { if (parent == user.Transform) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't buckle yourself there!" : "You can't buckle {0:them} there!", Owner)); return(false); } parent = parent.Parent; } if (!strap.HasSpace(this)) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't fit there!" : "{0:They} can't fit there!", Owner)); return(false); } _entitySystem.GetEntitySystem <AudioSystem>() .PlayFromEntity(strap.BuckleSound, Owner); if (!strap.TryAdd(this)) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't buckle yourself there!" : "You can't buckle {0:them} there!", Owner)); return(false); } BuckledTo = strap; if (Owner.TryGetComponent(out AppearanceComponent appearance)) { appearance.SetData(BuckleVisuals.Buckled, true); } var ownTransform = Owner.Transform; var strapTransform = strap.Owner.Transform; ownTransform.GridPosition = strapTransform.GridPosition; ownTransform.AttachParent(strapTransform); switch (strap.Position) { case StrapPosition.None: ownTransform.WorldRotation = strapTransform.WorldRotation; break; case StrapPosition.Stand: StandingStateHelper.Standing(Owner); ownTransform.WorldRotation = strapTransform.WorldRotation; break; case StrapPosition.Down: StandingStateHelper.Down(Owner); ownTransform.WorldRotation = Angle.South; break; } BuckleStatus(); return(true); }
async Task <bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { var user = eventArgs.User; var usingItem = eventArgs.Using; if (usingItem == null || usingItem.Deleted || !ActionBlockerSystem.CanInteract(user)) { return(false); } if (usingItem.TryGetComponent(out SeedComponent? seeds)) { if (Seed == null) { if (seeds.Seed == null) { user.PopupMessageCursor(Loc.GetString("The packet seems to be empty. You throw it away.")); usingItem.Delete(); return(false); } user.PopupMessageCursor(Loc.GetString("You plant the {0} {1}.", seeds.Seed.SeedName, seeds.Seed.SeedNoun)); Seed = seeds.Seed; Dead = false; Age = 1; Health = Seed.Endurance; _lastCycle = _gameTiming.CurTime; usingItem.Delete(); CheckLevelSanity(); UpdateSprite(); return(true); } user.PopupMessageCursor(Loc.GetString("The {0} already has seeds in it!", Owner.Name)); return(false); } if (usingItem.HasComponent <HoeComponent>()) { if (WeedLevel > 0) { user.PopupMessageCursor(Loc.GetString("You remove the weeds from the {0}.", Owner.Name)); user.PopupMessageOtherClients(Loc.GetString("{0} starts uprooting the weeds.", user.Name)); WeedLevel = 0; UpdateSprite(); } else { user.PopupMessageCursor(Loc.GetString("This plot is devoid of weeds! It doesn't need uprooting.")); } return(true); } if (usingItem.HasComponent <ShovelComponent>()) { if (Seed != null) { user.PopupMessageCursor(Loc.GetString("You remove the plant from the {0}.", Owner.Name)); user.PopupMessageOtherClients(Loc.GetString("{0} removes the plant.", user.Name)); RemovePlant(); } else { user.PopupMessageCursor(Loc.GetString("There is no plant to remove.")); } return(true); } if (usingItem.TryGetComponent(out ISolutionInteractionsComponent? solution) && solution.CanDrain) { var amount = ReagentUnit.New(5); var sprayed = false; if (usingItem.TryGetComponent(out SprayComponent? spray)) { sprayed = true; amount = ReagentUnit.New(1); EntitySystem.Get <AudioSystem>().PlayFromEntity(spray.SpraySound, usingItem, AudioHelpers.WithVariation(0.125f)); } var split = solution.Drain(amount); if (split.TotalVolume == 0) { user.PopupMessageCursor(Loc.GetString("{0:TheName} is empty!", usingItem)); return(true); } user.PopupMessageCursor(Loc.GetString( sprayed ? "You spray {0:TheName}" : "You transfer {1}u to {0:TheName}", Owner, split.TotalVolume)); _solutionContainer?.TryAddSolution(split); ForceUpdateByExternalCause(); return(true); } if (usingItem.HasComponent <PlantSampleTakerComponent>()) { if (Seed == null) { user.PopupMessageCursor(Loc.GetString("There is nothing to take a sample of!")); return(false); } if (Sampled) { user.PopupMessageCursor(Loc.GetString("This plant has already been sampled.")); return(false); } if (Dead) { user.PopupMessageCursor(Loc.GetString("This plant is dead.")); return(false); } var seed = Seed.SpawnSeedPacket(user.Transform.Coordinates); seed.RandomOffset(0.25f); user.PopupMessageCursor(Loc.GetString($"You take a sample from the {Seed.DisplayName}.")); Health -= (_random.Next(3, 5) * 10); if (_random.Prob(0.3f)) { Sampled = true; } // Just in case. CheckLevelSanity(); ForceUpdateByExternalCause(); return(true); } if (usingItem.HasComponent <BotanySharpComponent>()) { return(DoHarvest(user)); } if (usingItem.HasComponent <ProduceComponent>()) { user.PopupMessageCursor(Loc.GetString("You compost {1:theName} into {0:theName}.", Owner, usingItem)); user.PopupMessageOtherClients(Loc.GetString("{0:TheName} composts {1:theName} into {2:theName}.", user, usingItem, Owner)); if (usingItem.TryGetComponent(out SolutionContainerComponent? solution2)) { // This deliberately discards overfill. _solutionContainer?.TryAddSolution(solution2.SplitSolution(solution2.Solution.TotalVolume)); ForceUpdateByExternalCause(); } usingItem.Delete(); return(true); } return(false); }
protected override void Activate(IEntity user, RevolverBarrelComponent component) { component.Spin(); component.Owner.PopupMessage(user, Loc.GetString("Spun the cylinder")); }
public void Examine(FormattedMessage message, bool inDetailsRange) { if (!inDetailsRange) { return; } if (Seed == null) { message.AddMarkup(Loc.GetString("It has nothing planted in it.\n")); } else if (!Dead) { message.AddMarkup(Loc.GetString($"[color=green]{Seed.DisplayName}[/color] {(Seed.DisplayName.EndsWith('s') ? "are" : "is")} growing here.\n")); if (Health <= Seed.Endurance / 2) { message.AddMarkup(Loc.GetString($"The plant looks [color=red]{(Age > Seed.Lifespan ? "old and wilting" : "unhealthy")}[/color].\n")); } } else { message.AddMarkup(Loc.GetString("It is full of [color=red]dead plant matter[/color].\n")); } if (WeedLevel >= 5) { message.AddMarkup(Loc.GetString("It is filled with [color=green]weeds[/color]!\n")); } if (PestLevel >= 5) { message.AddMarkup(Loc.GetString("It is filled with [color=gray]tiny worms[/color]!\n")); } message.AddMarkup(Loc.GetString($"Water: [color=cyan]{(int)WaterLevel}[/color]\n")); message.AddMarkup(Loc.GetString($"Nutrient: [color=orange]{(int)NutritionLevel}[/color]\n")); if (DrawWarnings) { if (Toxins > 40f) { message.AddMarkup(Loc.GetString("The [color=red]toxicity level alert[/color] is flashing red.\n")); } if (ImproperLight) { message.AddMarkup(Loc.GetString("The [color=yellow]improper light level alert[/color] is blinking.\n")); } if (ImproperHeat) { message.AddMarkup(Loc.GetString("The [color=orange]improper temperature level alert[/color] is blinking.\n")); } if (ImproperPressure) { message.AddMarkup(Loc.GetString("The [color=lightblue]improper environment pressure alert[/color] is blinking.\n")); } if (_missingGas > 0) { message.AddMarkup(Loc.GetString("The [color=cyan]improper gas environment alert[/color] is blinking.\n")); } } }
public void UpdateButton() { Status.Text = Loc.GetString("Current Status: " + (Owner.IsOn ? "On" : "Off")); Status.FontColorOverride = Owner.IsOn ? Color.ForestGreen : Color.Red; Switch.Text = Loc.GetString(Owner.IsOn ? "Turn Off" : "Turn On"); }