2019-04-05 19:22:38 +02:00
|
|
|
|
using System;
|
2020-08-18 14:39:08 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2020-07-25 15:11:16 +02:00
|
|
|
|
using Content.Server.GameObjects.Components.GUI;
|
2020-08-13 14:40:27 +02:00
|
|
|
|
using Content.Server.GameObjects.Components.Items.Storage;
|
|
|
|
|
|
using Content.Server.GameObjects.Components.Mobs;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
2020-07-02 14:50:57 -07:00
|
|
|
|
using Content.Server.Interfaces;
|
2020-08-13 14:40:27 +02:00
|
|
|
|
using Content.Shared.GameObjects.Components.Damage;
|
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
|
|
|
|
using Content.Shared.Damage;
|
2020-07-18 22:51:56 -07:00
|
|
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
|
using Robust.Server.GameObjects.Components.Container;
|
2020-02-22 17:39:00 -06:00
|
|
|
|
using Robust.Server.GameObjects.EntitySystems;
|
2020-07-30 23:59:40 +02:00
|
|
|
|
using Robust.Server.Interfaces.GameObjects;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-05-31 12:40:36 -05:00
|
|
|
|
using Robust.Shared.GameObjects.Systems;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
|
|
|
|
using Robust.Shared.Interfaces.Timing;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
2018-05-27 16:44:50 +02:00
|
|
|
|
|
2020-08-13 14:40:27 +02:00
|
|
|
|
namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerReceiverUsers
|
2018-05-27 16:44:50 +02:00
|
|
|
|
{
|
2019-03-22 23:59:13 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Component that represents a wall light. It has a light bulb that can be replaced when broken.
|
|
|
|
|
|
/// </summary>
|
2019-07-31 15:02:36 +02:00
|
|
|
|
[RegisterComponent]
|
2020-07-30 23:59:40 +02:00
|
|
|
|
public class PoweredLightComponent : Component, IInteractHand, IInteractUsing, IMapInit
|
2018-05-27 16:44:50 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override string Name => "PoweredLight";
|
|
|
|
|
|
|
2019-03-20 01:12:38 +01:00
|
|
|
|
private static readonly TimeSpan _thunkDelay = TimeSpan.FromSeconds(2);
|
|
|
|
|
|
|
|
|
|
|
|
private TimeSpan _lastThunk;
|
|
|
|
|
|
|
2020-02-22 17:39:00 -06:00
|
|
|
|
|
2019-03-22 23:59:13 +01:00
|
|
|
|
private LightBulbType BulbType = LightBulbType.Tube;
|
|
|
|
|
|
|
2019-03-23 22:30:05 +01:00
|
|
|
|
[ViewVariables] private ContainerSlot _lightBulbContainer;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
|
private LightBulbComponent LightBulb
|
2018-05-27 16:44:50 +02:00
|
|
|
|
{
|
2019-03-22 23:59:13 +01:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2019-03-23 22:30:05 +01:00
|
|
|
|
if (_lightBulbContainer.ContainedEntity == null) return null;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
|
2019-03-23 22:30:05 +01:00
|
|
|
|
_lightBulbContainer.ContainedEntity.TryGetComponent(out LightBulbComponent bulb);
|
2019-03-22 23:59:13 +01:00
|
|
|
|
|
|
|
|
|
|
return bulb;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-02 14:50:57 -07:00
|
|
|
|
public override void HandleMessage(ComponentMessage message, IComponent component)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.HandleMessage(message, component);
|
|
|
|
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
|
|
{
|
|
|
|
|
|
case BeginDeconstructCompMsg msg:
|
|
|
|
|
|
if (!msg.BlockDeconstruct && !(_lightBulbContainer.ContainedEntity is null))
|
|
|
|
|
|
{
|
|
|
|
|
|
var notifyManager = IoCManager.Resolve<IServerNotifyManager>();
|
|
|
|
|
|
notifyManager.PopupMessage(Owner, msg.User, "Remove the bulb.");
|
|
|
|
|
|
msg.BlockDeconstruct = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-18 14:39:08 +02:00
|
|
|
|
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
2019-03-22 23:59:13 +01:00
|
|
|
|
{
|
2020-05-23 17:23:25 +02:00
|
|
|
|
return InsertBulb(eventArgs.Using);
|
2019-03-22 23:59:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-23 17:23:25 +02:00
|
|
|
|
public bool InteractHand(InteractHandEventArgs eventArgs)
|
2019-03-22 23:59:13 +01:00
|
|
|
|
{
|
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
|
|
|
|
if (!eventArgs.User.TryGetComponent(out IDamageableComponent damageableComponent))
|
2019-04-06 17:11:51 +02:00
|
|
|
|
{
|
|
|
|
|
|
Eject();
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(eventArgs.User.TryGetComponent(out HeatResistanceComponent heatResistanceComponent))
|
|
|
|
|
|
{
|
|
|
|
|
|
if(CanBurn(heatResistanceComponent.GetHeatResistance()))
|
|
|
|
|
|
{
|
|
|
|
|
|
Burn();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Eject();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
bool CanBurn(int heatResistance)
|
|
|
|
|
|
{
|
2019-07-30 13:31:46 +02:00
|
|
|
|
return _lightState && heatResistance < LightBulb.BurningTemperature;
|
2019-04-06 17:11:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Burn()
|
|
|
|
|
|
{
|
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
|
|
|
|
damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner);
|
2020-05-31 12:40:36 -05:00
|
|
|
|
var audioSystem = EntitySystem.Get<AudioSystem>();
|
2020-07-07 13:19:00 -04:00
|
|
|
|
audioSystem.PlayFromEntity("/Audio/Effects/lightburn.ogg", Owner);
|
2019-04-06 17:11:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Eject()
|
2019-03-22 23:59:13 +01:00
|
|
|
|
{
|
2019-04-05 19:27:39 +02:00
|
|
|
|
EjectBulb(eventArgs.User);
|
2019-03-22 23:59:13 +01:00
|
|
|
|
UpdateLight();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-23 22:30:05 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Inserts the bulb if possible.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>True if it could insert it, false if it couldn't.</returns>
|
|
|
|
|
|
private bool InsertBulb(IEntity bulb)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LightBulb != null) return false;
|
|
|
|
|
|
if (!bulb.TryGetComponent(out LightBulbComponent lightBulb)) return false;
|
|
|
|
|
|
if (lightBulb.Type != BulbType) return false;
|
|
|
|
|
|
|
|
|
|
|
|
var inserted = _lightBulbContainer.Insert(bulb);
|
|
|
|
|
|
|
|
|
|
|
|
lightBulb.OnLightBulbStateChange += UpdateLight;
|
|
|
|
|
|
lightBulb.OnLightColorChange += UpdateLight;
|
|
|
|
|
|
|
|
|
|
|
|
UpdateLight();
|
|
|
|
|
|
|
|
|
|
|
|
return inserted;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-22 23:59:13 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Ejects the bulb to a mob's hand if possible.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void EjectBulb(IEntity user)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LightBulb == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
var bulb = LightBulb;
|
2018-05-27 16:44:50 +02:00
|
|
|
|
|
2019-03-23 22:30:05 +01:00
|
|
|
|
bulb.OnLightBulbStateChange -= UpdateLight;
|
|
|
|
|
|
bulb.OnLightColorChange -= UpdateLight;
|
|
|
|
|
|
|
|
|
|
|
|
if (!_lightBulbContainer.Remove(bulb.Owner)) return;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
|
|
|
|
|
|
if (!user.TryGetComponent(out HandsComponent hands)
|
|
|
|
|
|
|| !hands.PutInHand(bulb.Owner.GetComponent<ItemComponent>()))
|
|
|
|
|
|
bulb.Owner.Transform.GridPosition = user.Transform.GridPosition;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
|
|
|
|
{
|
|
|
|
|
|
serializer.DataField(ref BulbType, "bulb", LightBulbType.Tube);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// For attaching UpdateLight() to events.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void UpdateLight(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateLight();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-07-30 13:31:46 +02:00
|
|
|
|
private bool _lightState => Owner.GetComponent<PointLightComponent>().Enabled;
|
|
|
|
|
|
|
2019-03-22 23:59:13 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Updates the light's power drain, sprite and actual light state.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void UpdateLight()
|
|
|
|
|
|
{
|
2020-06-28 09:23:26 -06:00
|
|
|
|
var powerReceiver = Owner.GetComponent<PowerReceiverComponent>();
|
2018-05-27 16:44:50 +02:00
|
|
|
|
var sprite = Owner.GetComponent<SpriteComponent>();
|
|
|
|
|
|
var light = Owner.GetComponent<PointLightComponent>();
|
2019-03-22 23:59:13 +01:00
|
|
|
|
if (LightBulb == null) // No light bulb.
|
2018-05-27 16:44:50 +02:00
|
|
|
|
{
|
2020-06-28 09:23:26 -06:00
|
|
|
|
powerReceiver.Load = 0;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
sprite.LayerSetState(0, "empty");
|
2019-07-30 13:31:46 +02:00
|
|
|
|
light.Enabled = false;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (LightBulb.State)
|
|
|
|
|
|
{
|
|
|
|
|
|
case LightBulbState.Normal:
|
2020-06-28 09:23:26 -06:00
|
|
|
|
powerReceiver.Load = LightBulb.PowerUse;
|
|
|
|
|
|
if (powerReceiver.Powered)
|
2019-03-22 23:59:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
sprite.LayerSetState(0, "on");
|
2019-07-30 13:31:46 +02:00
|
|
|
|
light.Enabled = true;
|
2019-03-23 22:30:05 +01:00
|
|
|
|
light.Color = LightBulb.Color;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
var time = IoCManager.Resolve<IGameTiming>().CurTime;
|
|
|
|
|
|
if (time > _lastThunk + _thunkDelay)
|
|
|
|
|
|
{
|
2019-03-25 13:01:03 +01:00
|
|
|
|
_lastThunk = time;
|
2020-07-07 13:19:00 -04:00
|
|
|
|
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Machines/light_tube_on.ogg", Owner, AudioParams.Default.WithVolume(-10f));
|
2019-03-22 23:59:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2019-03-20 01:12:38 +01:00
|
|
|
|
{
|
2019-03-22 23:59:13 +01:00
|
|
|
|
sprite.LayerSetState(0, "off");
|
2019-07-30 13:31:46 +02:00
|
|
|
|
light.Enabled = false;
|
2019-03-20 01:12:38 +01:00
|
|
|
|
}
|
2019-03-22 23:59:13 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case LightBulbState.Broken:
|
2020-06-28 09:23:26 -06:00
|
|
|
|
powerReceiver.Load = 0;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
sprite.LayerSetState(0, "broken");
|
2019-07-30 13:31:46 +02:00
|
|
|
|
light.Enabled = false;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case LightBulbState.Burned:
|
2020-06-28 09:23:26 -06:00
|
|
|
|
powerReceiver.Load = 0;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
sprite.LayerSetState(0, "burned");
|
2019-07-30 13:31:46 +02:00
|
|
|
|
light.Enabled = false;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
2020-06-28 09:23:26 -06:00
|
|
|
|
Owner.GetComponent<PowerReceiverComponent>().OnPowerStateChanged += UpdateLight;
|
2019-03-22 23:59:13 +01:00
|
|
|
|
|
2020-07-30 23:59:40 +02:00
|
|
|
|
_lightBulbContainer = ContainerManagerComponent.Ensure<ContainerSlot>("light_bulb", Owner);
|
2018-05-27 16:44:50 +02:00
|
|
|
|
}
|
2020-06-28 09:23:26 -06:00
|
|
|
|
|
|
|
|
|
|
public override void OnRemove()
|
|
|
|
|
|
{
|
|
|
|
|
|
Owner.GetComponent<PowerReceiverComponent>().OnPowerStateChanged -= UpdateLight;
|
|
|
|
|
|
base.OnRemove();
|
|
|
|
|
|
}
|
2020-07-30 23:59:40 +02:00
|
|
|
|
|
|
|
|
|
|
void IMapInit.MapInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
var prototype = BulbType switch
|
|
|
|
|
|
{
|
|
|
|
|
|
LightBulbType.Bulb => "LightBulb",
|
|
|
|
|
|
LightBulbType.Tube => "LightTube",
|
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var entity = Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition);
|
|
|
|
|
|
_lightBulbContainer.Insert(entity);
|
|
|
|
|
|
}
|
2018-05-27 16:44:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|