Files
crystall-punk-14/Content.Server/Kitchen/Components/MicrowaveComponent.cs

565 lines
19 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
2021-06-09 22:19:39 +02:00
using Content.Server.Act;
using Content.Server.Chat.Managers;
using Content.Server.Chemistry.Components;
using Content.Server.Hands.Components;
using Content.Server.Items;
2021-09-26 15:18:45 +02:00
using Content.Server.Popups;
2021-06-09 22:19:39 +02:00
using Content.Server.Power.Components;
using Content.Server.UserInterface;
using Content.Shared.Acts;
2021-06-09 22:19:39 +02:00
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
2021-06-09 22:19:39 +02:00
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Interaction;
using Content.Shared.Kitchen;
2021-06-09 22:19:39 +02:00
using Content.Shared.Kitchen.Components;
2021-09-26 15:18:45 +02:00
using Content.Shared.Popups;
2021-06-09 22:19:39 +02:00
using Content.Shared.Power;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
Serialization v3 content PR (#3491) * serv3 in shared pt 1 * beginning of deepclone api * progress in implementing ideepclone & serv3 in content * adds target * its cant hurt you it cant hurt you * more changes to content.server * adds dataclasses * almost there * renamed & edited entry * finishes refactoring content to use serv3 * gasmixture runtimes, next: reagentunit * fucin hell that was an annoying one * adds flags * fixes some yaml errors * removes comment * fixes generic components for now * removes todo actually clones values my god paul fixes bug involving resolving custom data classes from other proj renames dataclass fixes spritecomp adds WithFormat.Constants support * adds deepclone to ResistanceSet * adds a bunch of deepclone implementations adds a deepclone analyzer (TODO) adds a deep clone fallback for classes & structs * fixes a bunch of runtimes * adds deepclone to entityuid * adds generator to sln * gets rid of warnings * fixes * argh * componentdata refactors * more deepclone impl * heck me i reworked all of content deepclone * renames custom dataclasstarget * misc * reworks prototypes * deepclone nuke * renamed customdataclass attribute * fixes everything * misc fixed * the killcommit * getting there * changed yamlfieldattribute namespace * adds back iselfserialize * renames everything to data(field/definition) * ouch * Fix most errors on content * Fix more errors in content * Fix some components * work on tests * fixes some customdataclasses * fuggin shit * yes * yeas * Remove data classes * Data field naming fixes * arg * Git resetti RobustToolbox * Merge fixes * General fixes * Fix startup serialization errors * Fix DamageContainerPrototype when supported classes or types are null * Implement construction graph step type serializer * Fix up construction serialization * Fix up construction serialization part 2 * Fix null list in technology database component * Fix body serialization * Fix entity storage serialization * Fix actions serialization * Fix AI serialization * Fix reaction serialization * Fix body serialization * Fix grid atmosphere serialization * Rename IServ3Manager to ISerializationManager * Convert every non generic serializer to the new format, general fixes * Serialization and body system fix * pushinheritance fix * Update all prototypes to have a parent and have consistent id/parent properties * Merge fixes * smh my head * cuddling slaps * Content commit for engine PR * stuff * more fixes * argh * yes even you are fixed * changelog fixes * fixes seeds * argh * Test fixes * Add writing for alert order prototype * Fix alert order writing * FIX * its been alot ok * Fix the rest of the visualizers * Fix server alerts component tests * Fix alert prototype tests not using the read value * Fix alert prototype tests initializing serialization multiple times * THIS IS AN AMERICAN CODEBASE GOD BLESS THE USA * Add ImplicitDataDefinitionForInheritors to IMechanismBehavior Fixes the behaviors not being found * Fix NRE in strap component Good night to the 1 buckle optimization * Fix clothing component slot flags serialization tag * Fix body component in all components test * Merge fixes * ffs * Make construction graph prototype use serialization hooks * human yaml linted * a * Do the thing for construction * stuff * a * monke see yaml linter * LINT HARDER * Remove redundant todo * yes * Add skip hook argument to readers and copiers * we gamin * test/datafield fixes * adds more verbose validation * moves linter to action * Improve construction graph step type serializer error message * Fix ammo box component NRE * gamin * some updates to the linter * yes * removes that test * misc fixes * array fix priority fix misc fixes * adds proper info the validation * adds alwaysrelevant usa * Make yaml linter take half as long to run (~50% less) * Make yaml linter 5 times faster (~80% less execution time) * based vera being based * fixes mapsaving * warning cleanup & moves surpressor * removes old msbuild targets * Revert "Make yaml linter 5 times faster (~80% less execution time)" This reverts commit 3e6091359a26252c3e98828199553de668031c63. * Add -nowarn to yaml linter run configuration * Improve yaml linter message feedback * Make dependencies an argument instead of a property on the serialization manager * yamllinting slaps * Clean up type serializers * Move yaml linter code to its own method * Fix yaml errors * Change yaml linter action name and remove -nowarn * yaml linter please shut * Git resetti robust toolbox Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
2021-03-05 01:08:38 +01:00
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
2021-06-09 22:19:39 +02:00
namespace Content.Server.Kitchen.Components
{
[RegisterComponent]
[ComponentReference(typeof(IActivate))]
public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISuicideAct, IBreakAct
{
[Dependency] private readonly RecipeManager _recipeManager = default!;
#region YAMLSERIALIZE
[DataField("cookTime")] private uint _cookTimeDefault = 5;
[DataField("cookTimeMultiplier")] private int _cookTimeMultiplier = 1000; //For upgrades and stuff I guess?
[DataField("failureResult")] private string _badRecipeName = "FoodBadRecipe";
[DataField("beginCookingSound")] private SoundSpecifier _startCookingSound =
new SoundPathSpecifier("/Audio/Machines/microwave_start_beep.ogg");
[DataField("foodDoneSound")] private SoundSpecifier _cookingCompleteSound =
new SoundPathSpecifier("/Audio/Machines/microwave_done_beep.ogg");
[DataField("clickSound")]
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
#endregion YAMLSERIALIZE
[ViewVariables] private bool _busy = false;
private bool _broken;
/// <summary>
/// This is a fixed offset of 5.
/// The cook times for all recipes should be divisible by 5,with a minimum of 1 second.
/// For right now, I don't think any recipe cook time should be greater than 60 seconds.
/// </summary>
[ViewVariables] private uint _currentCookTimerTime = 1;
private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
private bool HasContents => EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(Owner, SolutionName, out var solution) &&
(solution.Contents.Count > 0 || _storage.ContainedEntities.Count > 0);
private bool _uiDirty = true;
private bool _lostPower;
private int _currentCookTimeButtonIndex;
public void DirtyUi()
{
_uiDirty = true;
}
private Container _storage = default!;
private const string SolutionName = "microwave";
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MicrowaveUiKey.Key);
protected override void Initialize()
{
base.Initialize();
_currentCookTimerTime = _cookTimeDefault;
EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName);
_storage = ContainerHelpers.EnsureContainer<Container>(Owner, "microwave_entity_container",
out _);
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
}
}
2020-05-01 23:34:04 -05:00
private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message)
{
if (!Powered || _busy)
{
return;
}
2020-05-01 23:34:04 -05:00
switch (message.Message)
{
case MicrowaveStartCookMessage:
Wzhzhzh();
2020-05-01 23:34:04 -05:00
break;
case MicrowaveEjectMessage:
if (HasContents)
{
VaporizeReagents();
EjectSolids();
ClickSound();
_uiDirty = true;
}
2020-05-01 23:34:04 -05:00
break;
2020-05-03 01:34:00 -05:00
case MicrowaveEjectSolidIndexedMessage msg:
if (HasContents)
{
EjectSolid(msg.EntityID);
ClickSound();
_uiDirty = true;
}
break;
case MicrowaveVaporizeReagentIndexedMessage msg:
if (HasContents)
{
VaporizeReagentQuantity(msg.ReagentQuantity);
ClickSound();
_uiDirty = true;
}
break;
case MicrowaveSelectCookTimeMessage msg:
_currentCookTimeButtonIndex = msg.ButtonIndex;
_currentCookTimerTime = msg.NewCookTime;
ClickSound();
_uiDirty = true;
2020-05-03 01:34:00 -05:00
break;
}
2020-05-01 23:34:04 -05:00
}
public void OnUpdate()
2020-05-03 01:34:00 -05:00
{
if (!Powered)
{
//TODO:If someone cuts power currently, microwave magically keeps going. FIX IT!
SetAppearance(MicrowaveVisualState.Idle);
}
if (_busy && !Powered)
{
//we lost power while we were cooking/busy!
_lostPower = true;
VaporizeReagents();
EjectSolids();
_busy = false;
_uiDirty = true;
}
if (_busy && _broken)
{
SetAppearance(MicrowaveVisualState.Broken);
//we broke while we were cooking/busy!
_lostPower = true;
VaporizeReagents();
EjectSolids();
_busy = false;
_uiDirty = true;
}
if (_uiDirty && EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(Owner, SolutionName, out var solution))
{
UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState
(
solution.Contents.ToArray(),
_storage.ContainedEntities.Select(item => item.Uid).ToArray(),
_busy,
_currentCookTimeButtonIndex,
_currentCookTimerTime
));
_uiDirty = false;
}
2020-05-03 01:34:00 -05:00
}
private void SetAppearance(MicrowaveVisualState state)
2020-05-03 01:34:00 -05:00
{
var finalState = state;
if (_broken)
{
finalState = MicrowaveVisualState.Broken;
}
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
2020-05-03 01:34:00 -05:00
{
appearance.SetData(PowerDeviceVisuals.VisualState, finalState);
2020-05-03 01:34:00 -05:00
}
}
2020-05-01 23:34:04 -05:00
public void OnBreak(BreakageEventArgs eventArgs)
{
_broken = true;
SetAppearance(MicrowaveVisualState.Broken);
}
2020-05-01 23:34:04 -05:00
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor) || !Powered)
{
2020-05-01 23:34:04 -05:00
return;
}
_uiDirty = true;
UserInterface?.Toggle(actor.PlayerSession);
}
2021-02-04 17:44:49 +01:00
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
if (!Powered)
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-no-power"));
return false;
}
if (_broken)
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-broken"));
return false;
}
Add changing the amount of hands on the GUI depending on your body parts (#1406) * Multiple hands in gui first pass * Remove IHandsComponent interface * Create hand class and more hand textures * Refactor ServerHandsComponent to use a single list of hands * Seal SharedHand * Fix picked up items not showing on top of the hand buttons * Remove HandsGui buttons and panels dictionaries * Fix items in hands rendering * Fix wrong hand container comparison * Fix not updating the location of duplicate hands * Change ClientHandsComponent to use a SortedList instead of a dictionary * More merge conflict fixes * Change SortedList to List * Fix hand button order * Add item tooltip for more than 2 hands and updating when removing hands * Add add hand and remove hand command * Merge conflict fixes * Remove nullable reference type from ContainerSlot * Fix texture errors * Fix error when reaching 0 hands * Fix error when swapping hands with no hands * Merged remove hand methods * Fix item panel texture errors * Merge conflict fixes * Fix addhand and removehand command descriptions * Add properly displaying tooltips for 2 hands * Make hand indexes and locations consistent across the client and server * Add dropping held entity if a hand is removed * Change hand location to be calculated by index * Made different hand gui updates more consistent * Remove human body yml testing changes * Sanitize addhand and removehand commands * Merge conflict fixes * Remove testing changes * Revert body system changes * Add missing imports * Remove obsolete hands parameter in yml files * Fix broken import * Fix startup error and adding and removing hands on the same tick * Make hand container id use an uint In case someone gets more than 2 billion hands * Rename hand component files * Make hands state use an array
2020-07-25 15:11:16 +02:00
var itemEntity = eventArgs.User.GetComponent<HandsComponent>().GetActiveHand?.Owner;
if (itemEntity == null)
{
eventArgs.User.PopupMessage(Loc.GetString("microwave-component-interact-using-no-active-hand"));
Add changing the amount of hands on the GUI depending on your body parts (#1406) * Multiple hands in gui first pass * Remove IHandsComponent interface * Create hand class and more hand textures * Refactor ServerHandsComponent to use a single list of hands * Seal SharedHand * Fix picked up items not showing on top of the hand buttons * Remove HandsGui buttons and panels dictionaries * Fix items in hands rendering * Fix wrong hand container comparison * Fix not updating the location of duplicate hands * Change ClientHandsComponent to use a SortedList instead of a dictionary * More merge conflict fixes * Change SortedList to List * Fix hand button order * Add item tooltip for more than 2 hands and updating when removing hands * Add add hand and remove hand command * Merge conflict fixes * Remove nullable reference type from ContainerSlot * Fix texture errors * Fix error when reaching 0 hands * Fix error when swapping hands with no hands * Merged remove hand methods * Fix item panel texture errors * Merge conflict fixes * Fix addhand and removehand command descriptions * Add properly displaying tooltips for 2 hands * Make hand indexes and locations consistent across the client and server * Add dropping held entity if a hand is removed * Change hand location to be calculated by index * Made different hand gui updates more consistent * Remove human body yml testing changes * Sanitize addhand and removehand commands * Merge conflict fixes * Remove testing changes * Revert body system changes * Add missing imports * Remove obsolete hands parameter in yml files * Fix broken import * Fix startup error and adding and removing hands on the same tick * Make hand container id use an uint In case someone gets more than 2 billion hands * Rename hand component files * Make hands state use an array
2020-07-25 15:11:16 +02:00
return false;
}
2020-05-03 01:34:00 -05:00
A big hecking chemistry-related refactor. (#3055) * A big hecking chemistry-related refactor. Changed SolutionContainerCaps. It now describes "stock" behavior for interacting with solutions that is pre-implemented by SolutionContainerComponent. As such things like syringes do not check it anymore (on themselves) to see "can we remove reagent from ourselves". That's assumed by it... being a syringe. SolutionContainerCaps now has different flags more accurately describing possible reagent interaction behaviors. ISolutionInteractionsComponent is the interface that describes the common behaviors like "what happens when injected with a syringe". This is implemented by SolutionContainerComponent but could be implemented by other classes. One notable example that drove me to making this interface was the /vg/station circuit imprinter which splits reagent poured in into its two reservoir beakers. Having this interface allows us to do this "proxying" behavior hack-free. (the hacks in /vg/ code were somewhat dirty...). PourableComponent has been replaced SolutionTransferComponent. It now describes both give-and-take behavior for the common reagent containers. This is in line with /vg/'s /obj/item/weapon/reagent_containers architecture. "Taking" in this context is ONLY from reagent tanks like fuel tanks. Oh, should I mention that fuel tanks and such have a proper component now? They do. Because of this behavioral change, reagent tanks DO NOT have Pourable anymore. Removing from reagent tanks is now in the hands of the item used on them. Welders and fire extinguishers now have code for removing from them. This sounds bad at first but remember that all have quite unique behavior related to this: Welders cause explosions if lit and can ONLY be fueled at fuel tanks. Extinguishers can be filled at any tank, etc... The code for this is also simpler due to ISolutionInteractionsComponent now so... IAfterInteract now works like IInteractUsing with the Priority levels and "return true to block further handlers" behavior. This was necessary to make extinguishers prioritize taking from tanks over spraying. Explicitly coded interactions like welders refueling also means they refuse instantly to full now, which they didn't before. And it plays the sound. Etc... Probably more stuff I'm forgetting. * Review improvements.
2021-02-03 14:05:31 +01:00
if (itemEntity.TryGetComponent<SolutionTransferComponent>(out var attackPourable))
{
var solutionsSystem = EntitySystem.Get<SolutionContainerSystem>();
if (!solutionsSystem.TryGetDrainableSolution(itemEntity.Uid, out var attackSolution))
{
2020-05-03 01:34:00 -05:00
return false;
}
if (!solutionsSystem.TryGetSolution(Owner, SolutionName, out var solution))
{
return false;
}
2020-05-03 01:34:00 -05:00
//Get transfer amount. May be smaller than _transferAmount if not enough room
var realTransferAmount = ReagentUnit.Min(attackPourable.TransferAmount, solution.AvailableVolume);
2020-05-03 01:34:00 -05:00
if (realTransferAmount <= 0) //Special message if container is full
{
Owner.PopupMessage(eventArgs.User,
Loc.GetString("microwave-component-interact-using-container-full"));
2020-05-03 01:34:00 -05:00
return false;
}
//Move units from attackSolution to targetSolution
var removedSolution = EntitySystem.Get<SolutionContainerSystem>()
.Drain(itemEntity.Uid, attackSolution, realTransferAmount);
if (!EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(Owner.Uid, solution, removedSolution))
{
2020-05-03 01:34:00 -05:00
return false;
}
2020-05-03 01:34:00 -05:00
Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-transfer-success",
("amount", removedSolution.TotalVolume)));
return true;
}
if (!itemEntity.TryGetComponent(typeof(ItemComponent), out var food))
{
Owner.PopupMessage(eventArgs.User, "microwave-component-interact-using-transfer-fail");
return false;
}
var ent = food.Owner; //Get the entity of the ItemComponent.
_storage.Insert(ent);
_uiDirty = true;
return true;
}
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private void Wzhzhzh()
{
if (!HasContents)
{
return;
}
2020-05-01 23:34:04 -05:00
_busy = true;
2020-05-03 01:34:00 -05:00
// Convert storage into Dictionary of ingredients
var solidsDict = new Dictionary<string, int>();
foreach (var item in _storage.ContainedEntities)
2020-05-03 01:34:00 -05:00
{
if (item.Prototype == null)
{
continue;
}
if (solidsDict.ContainsKey(item.Prototype.ID))
2020-05-03 01:34:00 -05:00
{
solidsDict[item.Prototype.ID]++;
2020-05-03 01:34:00 -05:00
}
else
{
solidsDict.Add(item.Prototype.ID, 1);
2020-05-03 01:34:00 -05:00
}
}
var failState = MicrowaveSuccessState.RecipeFail;
foreach (var id in solidsDict.Keys)
{
if (_recipeManager.SolidAppears(id))
{
continue;
}
failState = MicrowaveSuccessState.UnwantedForeignObject;
break;
}
2020-05-03 01:34:00 -05:00
// Check recipes
FoodRecipePrototype? recipeToCook = null;
foreach (var r in _recipeManager.Recipes.Where(r =>
CanSatisfyRecipe(r, solidsDict) == MicrowaveSuccessState.RecipePass))
{
recipeToCook = r;
}
SetAppearance(MicrowaveVisualState.Cooking);
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default);
Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), () =>
2021-08-10 15:39:24 -07:00
{
if (_lostPower)
{
return;
}
if (failState == MicrowaveSuccessState.UnwantedForeignObject)
{
VaporizeReagents();
EjectSolids();
}
else
{
if (recipeToCook != null)
{
SubtractContents(recipeToCook);
Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates);
}
else
{
VaporizeReagents();
VaporizeSolids();
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
}
}
SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner,
AudioParams.Default.WithVolume(-1f));
SetAppearance(MicrowaveVisualState.Idle);
_busy = false;
_uiDirty = true;
});
_lostPower = false;
_uiDirty = true;
}
2020-05-01 23:34:04 -05:00
2020-05-03 01:34:00 -05:00
private void VaporizeReagents()
2020-05-01 23:34:04 -05:00
{
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
{
EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(Owner.Uid, solution);
}
}
2020-05-03 01:34:00 -05:00
private void VaporizeReagentQuantity(Solution.ReagentQuantity reagentQuantity)
{
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
{
EntitySystem.Get<SolutionContainerSystem>()
.TryRemoveReagent(Owner.Uid, solution, reagentQuantity.ReagentId, reagentQuantity.Quantity);
}
2020-05-03 01:34:00 -05:00
}
private void VaporizeSolids()
{
for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--)
2020-05-03 01:34:00 -05:00
{
var item = _storage.ContainedEntities.ElementAt(i);
_storage.Remove(item);
2020-05-03 01:34:00 -05:00
item.Delete();
}
2020-05-01 23:34:04 -05:00
}
private void EjectSolids()
{
for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--)
{
_storage.Remove(_storage.ContainedEntities.ElementAt(i));
}
2020-05-03 01:34:00 -05:00
}
private void EjectSolid(EntityUid entityId)
2020-05-03 01:34:00 -05:00
{
if (Owner.EntityManager.EntityExists(entityId))
{
_storage.Remove(Owner.EntityManager.GetEntity(entityId));
}
2020-05-03 01:34:00 -05:00
}
private void SubtractContents(FoodRecipePrototype recipe)
{
var solutionUid = Owner.Uid;
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
{
return;
}
foreach (var recipeReagent in recipe.IngredientsReagents)
2020-05-03 01:34:00 -05:00
{
EntitySystem.Get<SolutionContainerSystem>()
.TryRemoveReagent(solutionUid, solution, recipeReagent.Key, ReagentUnit.New(recipeReagent.Value));
}
foreach (var recipeSolid in recipe.IngredientsSolids)
2020-05-03 01:34:00 -05:00
{
for (var i = 0; i < recipeSolid.Value; i++)
{
foreach (var item in _storage.ContainedEntities)
{
if (item.Prototype == null)
{
continue;
}
if (item.Prototype.ID == recipeSolid.Key)
{
_storage.Remove(item);
item.Delete();
break;
}
}
}
2020-05-03 01:34:00 -05:00
}
}
2020-05-03 01:34:00 -05:00
private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string, int> solids)
{
if (_currentCookTimerTime != (uint) recipe.CookTime)
{
return MicrowaveSuccessState.RecipeFail;
}
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
{
return MicrowaveSuccessState.RecipeFail;
}
2020-05-03 01:34:00 -05:00
foreach (var reagent in recipe.IngredientsReagents)
{
if (!solution.ContainsReagent(reagent.Key, out var amount))
{
return MicrowaveSuccessState.RecipeFail;
}
if (amount.Int() < reagent.Value)
{
return MicrowaveSuccessState.RecipeFail;
}
}
2020-05-03 01:34:00 -05:00
foreach (var solid in recipe.IngredientsSolids)
{
if (!solids.ContainsKey(solid.Key))
{
return MicrowaveSuccessState.RecipeFail;
}
if (solids[solid.Key] < solid.Value)
2020-04-30 23:07:27 -05:00
{
return MicrowaveSuccessState.RecipeFail;
2020-04-30 23:07:27 -05:00
}
}
return MicrowaveSuccessState.RecipePass;
}
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
2021-02-04 17:44:49 +01:00
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
{
Bodysystem and damagesystem rework (#1544) * Things and stuff with grids, unfinished w/ code debug changes. * Updated submodule and also lost some progress cause I fucked it up xd * First unfinished draft of the BodySystem. Doesn't compile. * More changes to make it compile, but still just a framework. Doesn't do anything at the moment. * Many cleanup changes. * Revert "Merge branch 'master' of https://github.com/GlassEclipse/space-station-14 into body_system" This reverts commit ddd4aebbc76cf2a0b7b102f72b93d55a0816c88c, reversing changes made to 12d0dd752706bdda8879393bd8191a1199a0c978. * Commit human.yml * Updated a lot of things to be more classy, more progress overall, etc. etc. * Latest update with many changes * Minor changes * Fixed Travis build bug * Adds first draft of Body Scanner console, apparently I also forgot to tie Mechanisms into body parts so now a heart just sits in the Torso like a good boy :) * Commit rest of stuff * Latest changes * Latest changes again * 14 naked cowboys * Yay! * Latest changes (probably doesnt compile) * Surgery!!!!!!!!!~1116y * Cleaned some stuff up * More cleanup * Refactoring of code. Basic surgery path now done. * Removed readme, has been added to HackMD * Fixes typo (and thus test errors) * WIP changes, committing so I can pull latest master changes * Still working on that god awful merge * Latest changes * Latest changes!! * Beginning of refactor to BoundUserInterface * Surgery! * Latest changes - fixes pr change requests and random fixes * oops * Fixes bodypart recursion * Beginning of work on revamping the damage system. * More latest changes * Latest changes * Finished merge * Commit before removing old healthcode * Almost done with removing speciescomponent... * It compiles!!! * yahoo more work * Fixes to make it work * Merge conflict fixes * Deleting species visualizer was a mistake * IDE warnings are VERBOTEN * makes the server not kill itself on startup, some cleanup (#1) * Namespaces, comments and exception fixes * Fix conveyor and conveyor switch serialization SS14 in reactive when * Move damage, acts and body to shared Damage cleanup Comment cleanup * Rename SpeciesComponent to RotationComponent and cleanup Damage cleanup Comment cleanup * Fix nullable warnings * Address old reviews Fix off welder suicide damage type, deathmatch and suspicion * Fix new test fail with units being able to accept items when unpowered * Remove RotationComponent, change references to IBodyManagerComponent * Add a bloodstream to humans * More cleanups * Add body conduits, connections, connectors substances and valves * Revert "Add body conduits, connections, connectors substances and valves" This reverts commit 9ab0b50e6b15fe98852d7b0836c0cdbf4bd76d20. * Implement the heart mechanism behavior with the circulatory network * Added network property to mechanism behaviors * Changed human organ sprites and added missing ones * Fix tests * Add individual body part sprite rendering * Fix error where dropped mechanisms are not initialized * Implement client/server body damage * Make DamageContainer take care of raising events * Reimplement medical scanner with the new body system * Improve the medical scanner ui * Merge conflict fixes * Fix crash when colliding with something * Fix microwave suicides and eyes sprite rendering * Fix nullable reference error * Fix up surgery client side * Fix missing using from merge conflict * Add breathing *inhale * Merge conflict fixes * Fix accumulatedframetime being reset to 0 instead of decreased by the threshold https://github.com/space-wizards/space-station-14/pull/1617 * Use and add to the new AtmosHelpers * Fix feet * Add proper coloring to dropped body parts * Fix Urist's lungs being too strong * Merge conflict fixes * Merge conflict fixes * Merge conflict fixes Co-authored-by: GlassEclipse <tsymall5@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
2020-08-17 01:42:42 +02:00
var headCount = 0;
if (victim.TryGetComponent<SharedBodyComponent>(out var body))
{
var headSlots = body.GetSlotsOfType(BodyPartType.Head);
foreach (var slot in headSlots)
{
var part = slot.Part;
if (part == null ||
!body.TryDropPart(slot, out var dropped))
Bodysystem and damagesystem rework (#1544) * Things and stuff with grids, unfinished w/ code debug changes. * Updated submodule and also lost some progress cause I fucked it up xd * First unfinished draft of the BodySystem. Doesn't compile. * More changes to make it compile, but still just a framework. Doesn't do anything at the moment. * Many cleanup changes. * Revert "Merge branch 'master' of https://github.com/GlassEclipse/space-station-14 into body_system" This reverts commit ddd4aebbc76cf2a0b7b102f72b93d55a0816c88c, reversing changes made to 12d0dd752706bdda8879393bd8191a1199a0c978. * Commit human.yml * Updated a lot of things to be more classy, more progress overall, etc. etc. * Latest update with many changes * Minor changes * Fixed Travis build bug * Adds first draft of Body Scanner console, apparently I also forgot to tie Mechanisms into body parts so now a heart just sits in the Torso like a good boy :) * Commit rest of stuff * Latest changes * Latest changes again * 14 naked cowboys * Yay! * Latest changes (probably doesnt compile) * Surgery!!!!!!!!!~1116y * Cleaned some stuff up * More cleanup * Refactoring of code. Basic surgery path now done. * Removed readme, has been added to HackMD * Fixes typo (and thus test errors) * WIP changes, committing so I can pull latest master changes * Still working on that god awful merge * Latest changes * Latest changes!! * Beginning of refactor to BoundUserInterface * Surgery! * Latest changes - fixes pr change requests and random fixes * oops * Fixes bodypart recursion * Beginning of work on revamping the damage system. * More latest changes * Latest changes * Finished merge * Commit before removing old healthcode * Almost done with removing speciescomponent... * It compiles!!! * yahoo more work * Fixes to make it work * Merge conflict fixes * Deleting species visualizer was a mistake * IDE warnings are VERBOTEN * makes the server not kill itself on startup, some cleanup (#1) * Namespaces, comments and exception fixes * Fix conveyor and conveyor switch serialization SS14 in reactive when * Move damage, acts and body to shared Damage cleanup Comment cleanup * Rename SpeciesComponent to RotationComponent and cleanup Damage cleanup Comment cleanup * Fix nullable warnings * Address old reviews Fix off welder suicide damage type, deathmatch and suspicion * Fix new test fail with units being able to accept items when unpowered * Remove RotationComponent, change references to IBodyManagerComponent * Add a bloodstream to humans * More cleanups * Add body conduits, connections, connectors substances and valves * Revert "Add body conduits, connections, connectors substances and valves" This reverts commit 9ab0b50e6b15fe98852d7b0836c0cdbf4bd76d20. * Implement the heart mechanism behavior with the circulatory network * Added network property to mechanism behaviors * Changed human organ sprites and added missing ones * Fix tests * Add individual body part sprite rendering * Fix error where dropped mechanisms are not initialized * Implement client/server body damage * Make DamageContainer take care of raising events * Reimplement medical scanner with the new body system * Improve the medical scanner ui * Merge conflict fixes * Fix crash when colliding with something * Fix microwave suicides and eyes sprite rendering * Fix nullable reference error * Fix up surgery client side * Fix missing using from merge conflict * Add breathing *inhale * Merge conflict fixes * Fix accumulatedframetime being reset to 0 instead of decreased by the threshold https://github.com/space-wizards/space-station-14/pull/1617 * Use and add to the new AtmosHelpers * Fix feet * Add proper coloring to dropped body parts * Fix Urist's lungs being too strong * Merge conflict fixes * Merge conflict fixes * Merge conflict fixes Co-authored-by: GlassEclipse <tsymall5@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
2020-08-17 01:42:42 +02:00
{
continue;
}
foreach (var droppedPart in dropped.Values)
{
if (droppedPart.PartType != BodyPartType.Head)
{
continue;
}
_storage.Insert(droppedPart.Owner);
headCount++;
}
}
}
var othersMessage = headCount > 1
? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim))
: Loc.GetString("microwave-component-suicide-others-message", ("victim", victim));
victim.PopupMessageOtherClients(othersMessage);
var selfMessage = headCount > 1
? Loc.GetString("microwave-component-suicide-multi-head-message")
: Loc.GetString("microwave-component-suicide-message");
victim.PopupMessage(selfMessage);
_currentCookTimerTime = 10;
ClickSound();
_uiDirty = true;
Wzhzhzh();
return SuicideKind.Heat;
}
}
}