Files
OldThink/Content.Server/Kitchen/Components/MicrowaveComponent.cs

551 lines
19 KiB
C#
Raw Normal View History

using System.Linq;
using System.Threading.Tasks;
2021-06-09 22:19:39 +02:00
using Content.Server.Act;
using Content.Server.Chat.Managers;
2022-02-12 17:53:54 -07:00
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
2021-06-09 22:19:39 +02:00
using Content.Server.Hands.Components;
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;
2022-02-12 17:53:54 -07:00
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
2021-06-09 22:19:39 +02:00
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.FixedPoint;
2021-06-09 22:19:39 +02:00
using Content.Shared.Interaction;
get that crap outta here (completely rewrites inventorysystem) (#5807) * some work * equip: done unequip: todo * unequipping done & refactored events * workin * movin * reee namespaces * stun * mobstate * fixes * some work on events * removes serverside itemcomp & misc fixes * work * smol merge fix * ports template to prototype & finishes ui * moves relay & adds containerenumerator * actions & cuffs * my god what is actioncode * more fixes * im loosing my grasp on reality * more fixes * more work * explosions * yes * more work * more fixes * merge master & misc fixed because i forgot to commit before merging master * more fixes * fixes * moar * more work * moar fixes * suffixmap * more work on client * motivation low * no. no containers * mirroring client to server * fixes * move serverinvcomp * serverinventorycomponent is dead * gaming * only strippable & ai left... * only ai and richtext left * fixes ai * fixes * fixes sprite layers * more fixes * resolves optional * yes * stable:tm: * fixes * moar fixes * moar * fix some tests * lmao * no comment * good to merge:tm: * fixes build but for real * adresses some reviews * adresses some more reviews * nullables, yo * fixes lobbyscreen * timid refactor to differentiate actor & target * adresses more reviews * more * my god what a mess * removed the rest of duplicates * removed duplicate slotflags and renamed shoes to feet * removes another unused one * yes * fixes lobby & makes tryunequip return unequipped item * fixes * some funny renames * fixes * misc improvements to attemptevents * fixes * merge fixes Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
2021-12-30 22:56:10 +01:00
using Content.Shared.Item;
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;
2022-02-12 17:53:54 -07:00
using Content.Shared.Tag;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Player;
2021-06-09 22:19:39 +02:00
namespace Content.Server.Kitchen.Components
{
[RegisterComponent]
public sealed class MicrowaveComponent : SharedMicrowaveComponent, IInteractUsing, ISuicideAct, IBreakAct
{
2021-12-05 21:02:04 +01:00
[Dependency] private readonly IEntityManager _entities = default!;
[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");
2022-02-12 17:53:54 -07:00
public SoundSpecifier ItemBreakSound = new SoundPathSpecifier("/Audio/Effects/clang.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;
2022-02-12 17:53:54 -07:00
/// <summary>
/// The max temperature that this microwave can heat objects to.
/// </summary>
[DataField("temperatureUpperThreshold")]
public float TemperatureUpperThreshold = 373.15f;
2021-12-05 21:02:04 +01:00
private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
2022-02-12 17:53:54 -07:00
private bool HasContents => _storage.ContainedEntities.Count > 0;
public bool UIDirty = true;
private bool _lostPower;
private int _currentCookTimeButtonIndex;
public void DirtyUi()
{
UIDirty = true;
}
private Container _storage = default!;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MicrowaveUiKey.Key);
protected override void Initialize()
{
base.Initialize();
_currentCookTimerTime = _cookTimeDefault;
_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)
{
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 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;
EjectSolids();
_busy = false;
UIDirty = true;
}
if (_busy && _broken)
{
SetAppearance(MicrowaveVisualState.Broken);
//we broke while we were cooking/busy!
_lostPower = true;
EjectSolids();
_busy = false;
UIDirty = true;
}
if (UIDirty)
{
UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState
(
2021-12-05 18:09:01 +01:00
_storage.ContainedEntities.Select(item => item).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;
}
2021-12-05 21:02:04 +01:00
if (_entities.TryGetComponent(Owner, 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);
}
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;
}
2022-03-17 20:13:31 +13:00
if (_entities.GetComponent<HandsComponent>(eventArgs.User).ActiveHandEntity is not {Valid: true} itemEntity)
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
{
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
get that crap outta here (completely rewrites inventorysystem) (#5807) * some work * equip: done unequip: todo * unequipping done & refactored events * workin * movin * reee namespaces * stun * mobstate * fixes * some work on events * removes serverside itemcomp & misc fixes * work * smol merge fix * ports template to prototype & finishes ui * moves relay & adds containerenumerator * actions & cuffs * my god what is actioncode * more fixes * im loosing my grasp on reality * more fixes * more work * explosions * yes * more work * more fixes * merge master & misc fixed because i forgot to commit before merging master * more fixes * fixes * moar * more work * moar fixes * suffixmap * more work on client * motivation low * no. no containers * mirroring client to server * fixes * move serverinvcomp * serverinventorycomponent is dead * gaming * only strippable & ai left... * only ai and richtext left * fixes ai * fixes * fixes sprite layers * more fixes * resolves optional * yes * stable:tm: * fixes * moar fixes * moar * fix some tests * lmao * no comment * good to merge:tm: * fixes build but for real * adresses some reviews * adresses some more reviews * nullables, yo * fixes lobbyscreen * timid refactor to differentiate actor & target * adresses more reviews * more * my god what a mess * removed the rest of duplicates * removed duplicate slotflags and renamed shoes to feet * removes another unused one * yes * fixes lobby & makes tryunequip return unequipped item * fixes * some funny renames * fixes * misc improvements to attemptevents * fixes * merge fixes Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
2021-12-30 22:56:10 +01:00
if (!_entities.TryGetComponent(itemEntity, typeof(SharedItemComponent), 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>();
2022-02-12 17:53:54 -07:00
var reagentDict = new Dictionary<string, FixedPoint2>();
foreach (var item in _storage.ContainedEntities)
2020-05-03 01:34:00 -05:00
{
2022-02-12 17:53:54 -07:00
// special behavior when being microwaved ;)
var ev = new BeingMicrowavedEvent(Owner);
_entities.EventBus.RaiseLocalEvent(item, ev, false);
if (ev.Handled)
return;
var tagSys = EntitySystem.Get<TagSystem>();
if (tagSys.HasTag(item, "MicrowaveMachineUnsafe")
|| tagSys.HasTag(item, "Metal"))
{
// destroy microwave
_broken = true;
SetAppearance(MicrowaveVisualState.Broken);
SoundSystem.Play(Filter.Pvs(Owner), ItemBreakSound.GetSound(), Owner);
return;
}
if (tagSys.HasTag(item, "MicrowaveSelfUnsafe")
|| tagSys.HasTag(item, "Plastic"))
{
_entities.SpawnEntity(_badRecipeName,
_entities.GetComponent<TransformComponent>(Owner).Coordinates);
_entities.QueueDeleteEntity(item);
}
2021-12-05 21:02:04 +01:00
var metaData = _entities.GetComponent<MetaDataComponent>(item);
if (metaData.EntityPrototype == null)
{
continue;
}
2021-12-05 21:02:04 +01:00
if (solidsDict.ContainsKey(metaData.EntityPrototype.ID))
2020-05-03 01:34:00 -05:00
{
2021-12-05 21:02:04 +01:00
solidsDict[metaData.EntityPrototype.ID]++;
2020-05-03 01:34:00 -05:00
}
else
{
2021-12-05 21:02:04 +01:00
solidsDict.Add(metaData.EntityPrototype.ID, 1);
2020-05-03 01:34:00 -05:00
}
2022-02-12 17:53:54 -07:00
if (!_entities.TryGetComponent<SolutionContainerManagerComponent>(item, out var solMan))
continue;
2022-02-12 17:53:54 -07:00
foreach (var (_, solution) in solMan.Solutions)
{
foreach (var reagent in solution.Contents)
{
if (reagentDict.ContainsKey(reagent.ReagentId))
reagentDict[reagent.ReagentId] += reagent.Quantity;
else
reagentDict.Add(reagent.ReagentId, reagent.Quantity);
}
}
}
2020-05-03 01:34:00 -05:00
// Check recipes
FoodRecipePrototype? recipeToCook = null;
foreach (var r in _recipeManager.Recipes.Where(r =>
2022-02-12 17:53:54 -07:00
CanSatisfyRecipe(r, solidsDict, reagentDict)))
{
recipeToCook = r;
}
SetAppearance(MicrowaveVisualState.Cooking);
2022-02-12 17:53:54 -07:00
var time = _currentCookTimerTime * _cookTimeMultiplier;
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;
}
2022-02-12 17:53:54 -07:00
AddTemperature(time);
if (recipeToCook != null)
2021-08-10 15:39:24 -07:00
{
2022-02-12 17:53:54 -07:00
SubtractContents(recipeToCook);
_entities.SpawnEntity(recipeToCook.Result,
_entities.GetComponent<TransformComponent>(Owner).Coordinates);
2021-08-10 15:39:24 -07:00
}
2022-02-12 17:53:54 -07:00
EjectSolids();
2021-08-10 15:39:24 -07:00
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
2022-02-12 17:53:54 -07:00
/// <summary>
/// Adds temperature to every item in the microwave,
/// based on the time it took to microwave.
/// </summary>
/// <param name="time">The time on the microwave, in seconds.</param>
public void AddTemperature(float time)
2020-05-01 23:34:04 -05:00
{
2022-02-12 17:53:54 -07:00
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
foreach (var entity in _storage.ContainedEntities)
{
2022-02-12 17:53:54 -07:00
if (_entities.TryGetComponent(entity, out TemperatureComponent? temp))
{
EntitySystem.Get<TemperatureSystem>().ChangeHeat(entity, time / 10, false, temp);
}
2020-05-03 01:34:00 -05:00
2022-02-12 17:53:54 -07:00
if (_entities.TryGetComponent(entity, out SolutionContainerManagerComponent? solutions))
{
foreach (var (_, solution) in solutions.Solutions)
{
if (solution.Temperature > TemperatureUpperThreshold)
continue;
2020-05-03 01:34:00 -05:00
2022-02-12 17:53:54 -07:00
solutionContainerSystem.AddThermalEnergy(entity, solution, time / 10);
}
}
2020-05-03 01:34:00 -05:00
}
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
{
2021-12-05 21:02:04 +01:00
if (_entities.EntityExists(entityId))
{
2021-12-05 21:02:04 +01:00
_storage.Remove(entityId);
}
2020-05-03 01:34:00 -05:00
}
private void SubtractContents(FoodRecipePrototype recipe)
{
2022-02-12 17:53:54 -07:00
var totalReagentsToRemove = new Dictionary<string, FixedPoint2>(recipe.IngredientsReagents);
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
2022-02-12 17:53:54 -07:00
// this is spaghetti ngl
foreach (var item in _storage.ContainedEntities)
2020-05-03 01:34:00 -05:00
{
2022-02-12 17:53:54 -07:00
if (!_entities.TryGetComponent<SolutionContainerManagerComponent>(item, out var solMan))
continue;
// go over every solution
foreach (var (_, solution) in solMan.Solutions)
{
foreach (var (reagent, _) in recipe.IngredientsReagents)
{
// removed everything
if (!totalReagentsToRemove.ContainsKey(reagent))
continue;
if (!solution.ContainsReagent(reagent))
continue;
var quant = solution.GetReagentQuantity(reagent);
if (quant >= totalReagentsToRemove[reagent])
{
quant = totalReagentsToRemove[reagent];
totalReagentsToRemove.Remove(reagent);
}
else
{
totalReagentsToRemove[reagent] -= quant;
}
solutionContainerSystem.TryRemoveReagent(item, solution, reagent, quant);
}
}
}
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)
{
2021-12-05 21:02:04 +01:00
var metaData = _entities.GetComponent<MetaDataComponent>(item);
if (metaData.EntityPrototype == null)
{
continue;
}
2021-12-05 21:02:04 +01:00
if (metaData.EntityPrototype.ID == recipeSolid.Key)
{
_storage.Remove(item);
2021-12-05 21:02:04 +01:00
_entities.DeleteEntity(item);
break;
}
}
}
2020-05-03 01:34:00 -05:00
}
}
2020-05-03 01:34:00 -05:00
2022-02-12 17:53:54 -07:00
private bool CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string, int> solids, Dictionary<string, FixedPoint2> reagents)
{
2021-12-05 18:09:01 +01:00
if (_currentCookTimerTime != recipe.CookTime)
{
2022-02-12 17:53:54 -07:00
return false;
}
2022-02-12 17:53:54 -07:00
foreach (var solid in recipe.IngredientsSolids)
{
2022-02-12 17:53:54 -07:00
if (!solids.ContainsKey(solid.Key))
return false;
2022-02-12 17:53:54 -07:00
if (solids[solid.Key] < solid.Value)
return false;
}
2022-02-12 17:53:54 -07:00
foreach (var reagent in recipe.IngredientsReagents)
{
2022-02-12 17:53:54 -07:00
if (!reagents.ContainsKey(reagent.Key))
return false;
2022-02-12 17:53:54 -07:00
if (reagents[reagent.Key] < reagent.Value)
return false;
}
2022-02-12 17:53:54 -07:00
return true;
}
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
2021-12-05 18:09:01 +01:00
SuicideKind ISuicideAct.Suicide(EntityUid 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;
2021-12-05 21:02:04 +01:00
if (_entities.TryGetComponent<SharedBodyComponent?>(victim, 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;
}
}
2022-02-12 17:53:54 -07:00
public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
2022-02-12 17:53:54 -07:00
{
public EntityUid Microwave;
public BeingMicrowavedEvent(EntityUid microwave)
{
Microwave = microwave;
}
}
}