if (ev is not OnTemperatureChangeEvent)
break;
+ // Some things, like microwaves, might need to block the temperature construction step from kicking in, or override it entirely.
+ var tempEvent = new OnConstructionTemperatureEvent();
+ RaiseLocalEvent(uid, tempEvent, true);
+
+ if (tempEvent.Result is not null)
+ return tempEvent.Result.Value;
+
// prefer using InternalTemperature since that's more accurate for cooking.
float temp;
if (TryComp<InternalTemperatureComponent>(uid, out var internalTemp))
/// </summary>
Completed
}
+ }
+ /// <summary>
+ /// Specifies the result after attempting to handle a specific step with an event.
+ /// </summary>
+ public enum HandleResult : byte
+ {
/// <summary>
- /// Specifies the result after attempting to handle a specific step with an event.
+ /// The interaction wasn't handled or validated.
/// </summary>
- private enum HandleResult : byte
- {
- /// <summary>
- /// The interaction wasn't handled or validated.
- /// </summary>
- False,
+ False,
- /// <summary>
- /// The interaction would be handled successfully. Nothing was modified.
- /// </summary>
- Validated,
+ /// <summary>
+ /// The interaction would be handled successfully. Nothing was modified.
+ /// </summary>
+ Validated,
- /// <summary>
- /// The interaction was handled successfully.
- /// </summary>
- True,
+ /// <summary>
+ /// The interaction was handled successfully.
+ /// </summary>
+ True,
- /// <summary>
- /// The interaction is waiting on a DoAfter now.
- /// This means the interaction started the DoAfter.
- /// </summary>
- DoAfter,
- }
+ /// <summary>
+ /// The interaction is waiting on a DoAfter now.
+ /// This means the interaction started the DoAfter.
+ /// </summary>
+ DoAfter,
+ }
- #endregion
+ #endregion
+
+ public sealed class OnConstructionTemperatureEvent : HandledEntityEventArgs
+ {
+ public HandleResult? Result;
}
}
SubscribeLocalEvent<MicrowaveComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<MicrowaveComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<MicrowaveComponent, SolutionContainerChangedEvent>(OnSolutionChange);
+ SubscribeLocalEvent<MicrowaveComponent, EntInsertedIntoContainerMessage>(OnContentUpdate);
+ SubscribeLocalEvent<MicrowaveComponent, EntRemovedFromContainerMessage>(OnContentUpdate);
SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(AnchorableSystem) });
SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak);
SubscribeLocalEvent<MicrowaveComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<ActiveMicrowaveComponent, ComponentStartup>(OnCookStart);
SubscribeLocalEvent<ActiveMicrowaveComponent, ComponentShutdown>(OnCookStop);
+ SubscribeLocalEvent<ActiveMicrowaveComponent, EntInsertedIntoContainerMessage>(OnActiveMicrowaveInsert);
+ SubscribeLocalEvent<ActiveMicrowaveComponent, EntRemovedFromContainerMessage>(OnActiveMicrowaveRemove);
+
+ SubscribeLocalEvent<ActivelyMicrowavedComponent, OnConstructionTemperatureEvent>(OnConstructionTemp);
}
private void OnCookStart(Entity<ActiveMicrowaveComponent> ent, ref ComponentStartup args)
microwaveComponent.PlayingStream = _audio.Stop(microwaveComponent.PlayingStream);
}
+ private void OnActiveMicrowaveInsert(Entity<ActiveMicrowaveComponent> ent, ref EntInsertedIntoContainerMessage args)
+ {
+ AddComp<ActivelyMicrowavedComponent>(args.Entity);
+ }
+
+ private void OnActiveMicrowaveRemove(Entity<ActiveMicrowaveComponent> ent, ref EntRemovedFromContainerMessage args)
+ {
+ EntityManager.RemoveComponentDeferred<ActivelyMicrowavedComponent>(args.Entity);
+ }
+
+ private void OnConstructionTemp(Entity<ActivelyMicrowavedComponent> ent, ref OnConstructionTemperatureEvent args)
+ {
+ args.Result = HandleResult.False;
+ return;
+ }
+
/// <summary>
/// Adds temperature to every item in the microwave,
/// based on the time it took to microwave.
UpdateUserInterfaceState(ent, ent.Comp);
}
+ private void OnContentUpdate(EntityUid uid, MicrowaveComponent component, ContainerModifiedMessage args) // For some reason ContainerModifiedMessage just can't be used at all with Entity<T>. TODO: replace with Entity<T> syntax once that's possible
+ {
+ UpdateUserInterfaceState(uid, component);
+ }
+
private void OnInteractUsing(Entity<MicrowaveComponent> ent, ref InteractUsingEvent args)
{
if (args.Handled)
QueueDel(item);
}
+ AddComp<ActivelyMicrowavedComponent>(item);
+
var metaData = MetaData(item); //this simply begs for cooking refactor
if (metaData.EntityPrototype == null)
continue;
//this means the microwave has finished cooking.
AddTemperature(microwave, Math.Max(frameTime + active.CookTimeRemaining, 0)); //Though there's still a little bit more heat to pump out
+ foreach (var solid in microwave.Storage.ContainedEntities)
+ EntityManager.RemoveComponentDeferred<ActivelyMicrowavedComponent>(solid);
+
if (active.PortionedRecipe.Item1 != null)
{
var coords = Transform(uid).Coordinates;