@@ -59,6 +59,8 @@ public override void Initialize()
5959 SubscribeLocalEvent < MicrowaveComponent , ComponentInit > ( OnInit ) ;
6060 SubscribeLocalEvent < MicrowaveComponent , MapInitEvent > ( OnMapInit ) ;
6161 SubscribeLocalEvent < MicrowaveComponent , SolutionContainerChangedEvent > ( OnSolutionChange ) ;
62+ SubscribeLocalEvent < MicrowaveComponent , EntInsertedIntoContainerMessage > ( OnContentUpdate ) ;
63+ SubscribeLocalEvent < MicrowaveComponent , EntRemovedFromContainerMessage > ( OnContentUpdate ) ;
6264 SubscribeLocalEvent < MicrowaveComponent , InteractUsingEvent > ( OnInteractUsing , after : new [ ] { typeof ( AnchorableSystem ) } ) ;
6365 SubscribeLocalEvent < MicrowaveComponent , BreakageEventArgs > ( OnBreak ) ;
6466 SubscribeLocalEvent < MicrowaveComponent , PowerChangedEvent > ( OnPowerChanged ) ;
@@ -76,6 +78,10 @@ public override void Initialize()
7678
7779 SubscribeLocalEvent < ActiveMicrowaveComponent , ComponentStartup > ( OnCookStart ) ;
7880 SubscribeLocalEvent < ActiveMicrowaveComponent , ComponentShutdown > ( OnCookStop ) ;
81+ SubscribeLocalEvent < ActiveMicrowaveComponent , EntInsertedIntoContainerMessage > ( OnActiveMicrowaveInsert ) ;
82+ SubscribeLocalEvent < ActiveMicrowaveComponent , EntRemovedFromContainerMessage > ( OnActiveMicrowaveRemove ) ;
83+
84+ SubscribeLocalEvent < ActivelyMicrowavedComponent , OnConstructionTemperatureEvent > ( OnConstructionTemp ) ;
7985 }
8086
8187 private void OnCookStart ( Entity < ActiveMicrowaveComponent > ent , ref ComponentStartup args )
@@ -97,6 +103,22 @@ private void OnCookStop(Entity<ActiveMicrowaveComponent> ent, ref ComponentShutd
97103 microwaveComponent . PlayingStream = _audio . Stop ( microwaveComponent . PlayingStream ) ;
98104 }
99105
106+ private void OnActiveMicrowaveInsert ( Entity < ActiveMicrowaveComponent > ent , ref EntInsertedIntoContainerMessage args )
107+ {
108+ AddComp < ActivelyMicrowavedComponent > ( args . Entity ) ;
109+ }
110+
111+ private void OnActiveMicrowaveRemove ( Entity < ActiveMicrowaveComponent > ent , ref EntRemovedFromContainerMessage args )
112+ {
113+ EntityManager . RemoveComponentDeferred < ActivelyMicrowavedComponent > ( args . Entity ) ;
114+ }
115+
116+ private void OnConstructionTemp ( Entity < ActivelyMicrowavedComponent > ent , ref OnConstructionTemperatureEvent args )
117+ {
118+ args . Result = HandleResult . False ;
119+ return ;
120+ }
121+
100122 /// <summary>
101123 /// Adds temperature to every item in the microwave,
102124 /// based on the time it took to microwave.
@@ -239,6 +261,11 @@ private void OnSolutionChange(Entity<MicrowaveComponent> ent, ref SolutionContai
239261 UpdateUserInterfaceState ( ent , ent . Comp ) ;
240262 }
241263
264+ 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
265+ {
266+ UpdateUserInterfaceState ( uid , component ) ;
267+ }
268+
242269 private void OnInteractUsing ( Entity < MicrowaveComponent > ent , ref InteractUsingEvent args )
243270 {
244271 if ( args . Handled )
@@ -390,6 +417,8 @@ public void Wzhzhzh(EntityUid uid, MicrowaveComponent component, EntityUid? user
390417 QueueDel ( item ) ;
391418 }
392419
420+ AddComp < ActivelyMicrowavedComponent > ( item ) ;
421+
393422 var metaData = MetaData ( item ) ; //this simply begs for cooking refactor
394423 if ( metaData . EntityPrototype == null )
395424 continue ;
@@ -490,6 +519,9 @@ public override void Update(float frameTime)
490519 //this means the microwave has finished cooking.
491520 AddTemperature ( microwave , Math . Max ( frameTime + active . CookTimeRemaining , 0 ) ) ; //Though there's still a little bit more heat to pump out
492521
522+ foreach ( var solid in microwave . Storage . ContainedEntities )
523+ EntityManager . RemoveComponentDeferred < ActivelyMicrowavedComponent > ( solid ) ;
524+
493525 if ( active . PortionedRecipe . Item1 != null )
494526 {
495527 var coords = Transform ( uid ) . Coordinates ;
0 commit comments