# Conflicts: # .github/workflows/validate-rgas.yml # .github/workflows/validate-rsis.yml # Content.Client/Changelog/ChangelogTab.xaml.cs # Content.Client/Humanoid/HumanoidAppearanceSystem.cs # Content.Client/Options/UI/OptionsMenu.xaml.cs # Content.Client/SubFloor/SubFloorHideSystem.cs # Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs # Content.Server/Advertise/EntitySystems/SpeakOnUIClosedSystem.cs # Content.Server/Antag/AntagSelectionSystem.cs # Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeSystem.cs # Content.Server/Explosion/EntitySystems/TriggerSystem.cs # Content.Server/Mindshield/MindShieldSystem.cs # Content.Server/Objectives/Systems/KillPersonConditionSystem.cs # Content.Server/Standing/StandingStateSystem.cs # Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs # Content.Server/VendingMachines/VendingMachineSystem.cs # Content.Server/Zombies/ZombieSystem.Transform.cs # Content.Server/Zombies/ZombieSystem.cs # Content.Shared/Damage/Systems/DamageableSystem.cs # Content.Shared/Humanoid/HumanoidAppearanceComponent.cs # Content.Shared/Humanoid/Markings/MarkingManager.cs # Content.Shared/Humanoid/NamingSystem.cs # Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs # Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs # Content.Shared/Implants/Components/SubdermalImplantComponent.cs # Content.Shared/Standing/StandingStateSystem.cs # Content.Shared/VendingMachines/SharedVendingMachineSystem.cs # Content.Shared/VendingMachines/VendingMachineComponent.cs # Resources/Audio/Lobby/attributions.yml # Resources/Locale/en-US/_strings/administration/commands/forceghost.ftl # Resources/Locale/en-US/_strings/clothing/components/fire-protection-component.ftl # Resources/Locale/en-US/_strings/components/storage-voice-control-component.ftl # Resources/Locale/en-US/_strings/prototypes/roles/antags.ftl # Resources/Locale/en-US/_strings/reagents/meta/physical-desc.ftl # Resources/Locale/en-US/lathe/lathe-categories.ftl # Resources/Prototypes/Access/command.yml # Resources/Prototypes/Catalog/Fills/Books/bookshelf.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Catalog/Fills/Lockers/misc.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/chemvend.yml # Resources/Prototypes/Catalog/thief_toolbox_sets.yml # Resources/Prototypes/Datasets/Names/Operation_prefix.yml # Resources/Prototypes/Datasets/Names/Operation_suffix.yml # Resources/Prototypes/Datasets/Names/arachnid_first.yml # Resources/Prototypes/Datasets/Names/arachnid_last.yml # Resources/Prototypes/Datasets/Names/borg.yml # Resources/Prototypes/Datasets/Names/cargo_shuttle.yml # Resources/Prototypes/Datasets/Names/clown.yml # Resources/Prototypes/Datasets/Names/diona.yml # Resources/Prototypes/Datasets/Names/fake_human_first.yml # Resources/Prototypes/Datasets/Names/fake_human_last.yml # Resources/Prototypes/Datasets/Names/first.yml # Resources/Prototypes/Datasets/Names/first_female.yml # Resources/Prototypes/Datasets/Names/first_male.yml # Resources/Prototypes/Datasets/Names/fortunes.yml # Resources/Prototypes/Datasets/Names/hologram.yml # Resources/Prototypes/Datasets/Names/last.yml # Resources/Prototypes/Datasets/Names/military.yml # Resources/Prototypes/Datasets/Names/moth_first_female.yml # Resources/Prototypes/Datasets/Names/moth_first_male.yml # Resources/Prototypes/Datasets/Names/moth_last.yml # Resources/Prototypes/Datasets/Names/mushman_first.yml # Resources/Prototypes/Datasets/Names/mushman_last.yml # Resources/Prototypes/Datasets/Names/ninja.yml # Resources/Prototypes/Datasets/Names/ninja_title.yml # Resources/Prototypes/Datasets/Names/regalrat.yml # Resources/Prototypes/Datasets/Names/reptilian_female.yml # Resources/Prototypes/Datasets/Names/reptilian_male.yml # Resources/Prototypes/Datasets/Names/revenant.yml # Resources/Prototypes/Datasets/Names/skeleton_first.yml # Resources/Prototypes/Datasets/Names/syndicate.yml # Resources/Prototypes/Datasets/Names/vox.yml # Resources/Prototypes/Datasets/Names/wizard_first.yml # Resources/Prototypes/Datasets/Names/wizard_last.yml # Resources/Prototypes/Datasets/adjectives.yml # Resources/Prototypes/Datasets/corporations.yml # Resources/Prototypes/Datasets/criminal_records.yml # Resources/Prototypes/Datasets/rat_king_commands.yml # Resources/Prototypes/Datasets/verbs.yml # Resources/Prototypes/Entities/Clothing/Head/specific.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/coats.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/specific.yml # Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml # Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml # Resources/Prototypes/Entities/Mobs/Player/human.yml # Resources/Prototypes/Entities/Mobs/Player/humanoid.yml # Resources/Prototypes/Entities/Mobs/Species/arachnid.yml # Resources/Prototypes/Entities/Mobs/Species/base.yml # Resources/Prototypes/Entities/Mobs/Species/moth.yml # Resources/Prototypes/Entities/Mobs/Species/vox.yml # Resources/Prototypes/Entities/Objects/Devices/pda.yml # Resources/Prototypes/Entities/Objects/Misc/paper.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml # Resources/Prototypes/Entities/Stations/nanotrasen.yml # Resources/Prototypes/Entities/Structures/Furniture/carpets.yml # Resources/Prototypes/Entities/Structures/Storage/Closets/wall_lockers.yml # Resources/Prototypes/GameRules/roundstart.yml # Resources/Prototypes/Procedural/salvage_loot.yml # Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml # Resources/Prototypes/Recipes/Lathes/biogen.yml # Resources/Prototypes/Recipes/Lathes/categories.yml # Resources/Prototypes/Roles/Jobs/Security/warden.yml # Resources/Prototypes/Species/arachnid.yml # Resources/Prototypes/Species/diona.yml # Resources/Prototypes/Species/moth.yml # Resources/Prototypes/ai_factions.yml # Resources/Prototypes/game_presets.yml # Resources/ServerInfo/Guidebook/Mobs/SlimePerson.xml # Resources/ServerInfo/Guidebook/ServerRules/SpaceLaw/SpaceLaw.xml # Resources/ServerInfo/Guidebook/Service/Botany.xml # Resources/Textures/Clothing/Eyes/Glasses/glasses.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/jamjar.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/mercglasses.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/meson.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/ninjavisor.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/outlawglasses.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/science.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/secglasses.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/sunglasses.rsi/meta.json # Resources/Textures/Clothing/Eyes/Glasses/thermal.rsi/meta.json # Resources/Textures/Clothing/Eyes/Hud/beergoggles.rsi/inhand-left.png # Resources/Textures/Clothing/Eyes/Hud/beergoggles.rsi/inhand-right.png # Resources/Textures/Clothing/Eyes/Hud/beergoggles.rsi/meta.json # Resources/Textures/Clothing/Eyes/Hud/synd.rsi/meta.json # Resources/Textures/Clothing/Eyes/Hud/syndagent.rsi/meta.json # Resources/Textures/Clothing/Head/Hats/capcap.rsi/inhand-left.png # Resources/Textures/Clothing/Head/Hats/capcap.rsi/inhand-right.png # Resources/Textures/Clothing/Head/Hats/capcap.rsi/meta.json # Resources/Textures/Interface/Misc/program_icons.rsi/meta.json # Resources/Textures/Objects/Misc/Lights/lights.rsi/meta.json # Resources/Textures/Objects/Misc/bureaucracy.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/aloe.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/apple.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/carrot.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/chanterelle.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/chili.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/eggplant.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/gatfruit.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/lemon.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/onion_red.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/potato.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/sugarcane.rsi/meta.json # Resources/Textures/Objects/Specific/Hydroponics/tomato.rsi/meta.json # Resources/Textures/Objects/Specific/Robotics/borgmodule.rsi/meta.json # Resources/Textures/Objects/Specific/Robotics/cyborg_parts.rsi/meta.json # Resources/Textures/Objects/Tools/spray_painter.rsi/meta.json # Resources/Textures/Objects/Weapons/Grenades/flashbang.rsi/meta.json # Resources/Textures/Objects/Weapons/Grenades/grenade.rsi/meta.json # Resources/Textures/Objects/Weapons/Grenades/nukenade.rsi/meta.json # Resources/migration.yml # Tools/actions_changelogs_since_last_run.py
319 lines
14 KiB
C#
319 lines
14 KiB
C#
using Content.Server.Physics.Components;
|
|
using Content.Server.Singularity.Components;
|
|
using Content.Server.Singularity.Events;
|
|
using Content.Shared.Singularity.Components;
|
|
using Content.Shared.Singularity.EntitySystems;
|
|
using Content.Shared.Singularity.Events;
|
|
using Content.Server.Supermatter.Components;
|
|
using Robust.Server.GameStates;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server.Singularity.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// The server-side version of <see cref="SharedSingularitySystem"/>.
|
|
/// Primarily responsible for managing <see cref="SingularityComponent"/>s.
|
|
/// Handles their accumulation of energy upon consuming entities (see <see cref="EventHorizonComponent"/>) and gradual dissipation.
|
|
/// Also handles synchronizing server-side components with the singuarities level.
|
|
/// </summary>
|
|
public sealed class SingularitySystem : SharedSingularitySystem
|
|
{
|
|
#region Dependencies
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly PvsOverrideSystem _pvs = default!;
|
|
#endregion Dependencies
|
|
|
|
/// <summary>
|
|
/// The amount of energy singulos accumulate when they eat a tile.
|
|
/// </summary>
|
|
public const float BaseTileEnergy = 1f;
|
|
|
|
/// <summary>
|
|
/// The amount of energy singulos accumulate when they eat an entity.
|
|
/// </summary>
|
|
public const float BaseEntityEnergy = 1f;
|
|
|
|
/// <summary>
|
|
/// Whether or not the singuloo has eaten the supermatter crystal
|
|
/// </summary>
|
|
public bool HasEatenSM = false;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<SingularityDistortionComponent, ComponentStartup>(OnDistortionStartup);
|
|
SubscribeLocalEvent<SingularityComponent, ComponentShutdown>(OnSingularityShutdown);
|
|
SubscribeLocalEvent<SingularityComponent, EventHorizonConsumedEntityEvent>(OnConsumed);
|
|
SubscribeLocalEvent<SinguloFoodComponent, EventHorizonConsumedEntityEvent>(OnConsumed);
|
|
SubscribeLocalEvent<SingularityComponent, EntityConsumedByEventHorizonEvent>(OnConsumedEntity);
|
|
SubscribeLocalEvent<SingularityComponent, TilesConsumedByEventHorizonEvent>(OnConsumedTiles);
|
|
SubscribeLocalEvent<SingularityComponent, SingularityLevelChangedEvent>(UpdateEnergyDrain);
|
|
SubscribeLocalEvent<SingularityComponent, ComponentGetState>(HandleSingularityState);
|
|
|
|
// TODO: Figure out where all this coupling should be handled.
|
|
SubscribeLocalEvent<RandomWalkComponent, SingularityLevelChangedEvent>(UpdateRandomWalk);
|
|
SubscribeLocalEvent<GravityWellComponent, SingularityLevelChangedEvent>(UpdateGravityWell);
|
|
|
|
var vvHandle = Vvm.GetTypeHandler<SingularityComponent>();
|
|
vvHandle.AddPath(nameof(SingularityComponent.Energy), (_, comp) => comp.Energy, SetEnergy);
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
var vvHandle = Vvm.GetTypeHandler<SingularityComponent>();
|
|
vvHandle.RemovePath(nameof(SingularityComponent.Energy));
|
|
base.Shutdown();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles the gradual dissipation of all singularities.
|
|
/// </summary>
|
|
/// <param name="frameTime">The amount of time since the last set of updates.</param>
|
|
public override void Update(float frameTime)
|
|
{
|
|
if(!_timing.IsFirstTimePredicted)
|
|
return;
|
|
|
|
var query = EntityQueryEnumerator<SingularityComponent>();
|
|
while (query.MoveNext(out var uid, out var singularity))
|
|
{
|
|
AdjustEnergy(uid, -singularity.EnergyDrain * frameTime, singularity: singularity);
|
|
}
|
|
}
|
|
|
|
#region Getters/Setters
|
|
|
|
/// <summary>
|
|
/// Setter for <see cref="SingularityComponent.Energy"/>.
|
|
/// Also updates the level of the singularity accordingly.
|
|
/// </summary>
|
|
/// <param name="uid">The uid of the singularity to set the energy of.</param>
|
|
/// <param name="value">The amount of energy for the singularity to have.</param>
|
|
/// <param name="singularity">The state of the singularity to set the energy of.</param>
|
|
public void SetEnergy(EntityUid uid, float value, SingularityComponent? singularity = null)
|
|
{
|
|
if(!Resolve(uid, ref singularity))
|
|
return;
|
|
|
|
var oldValue = singularity.Energy;
|
|
if (oldValue == value)
|
|
return;
|
|
|
|
singularity.Energy = value;
|
|
SetLevel(uid, value switch
|
|
{
|
|
// Normally, a level 6 singularity requires the supermatter + 3000 energy.
|
|
// The required amount of energy has been bumped up to compensate for the lack of the supermatter.
|
|
>= 5000 when HasEatenSM => 6,
|
|
>= 2000 => 5,
|
|
>= 1000 => 4,
|
|
>= 500 => 3,
|
|
>= 200 => 2,
|
|
> 0 => 1,
|
|
_ => 0
|
|
}, singularity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adjusts the amount of energy the singularity has accumulated.
|
|
/// </summary>
|
|
/// <param name="uid">The uid of the singularity to adjust the energy of.</param>
|
|
/// <param name="delta">The amount to adjust the energy of the singuarity.</param>
|
|
/// <param name="min">The minimum amount of energy for the singularity to be adjusted to.</param>
|
|
/// <param name="max">The maximum amount of energy for the singularity to be adjusted to.</param>
|
|
/// <param name="snapMin">Whether the amount of energy in the singularity should be forced to within the specified range if it already is below it.</param>
|
|
/// <param name="snapMax">Whether the amount of energy in the singularity should be forced to within the specified range if it already is above it.</param>
|
|
/// <param name="singularity">The state of the singularity to adjust the energy of.</param>
|
|
public void AdjustEnergy(EntityUid uid, float delta, float min = float.MinValue, float max = float.MaxValue, bool snapMin = true, bool snapMax = true, SingularityComponent? singularity = null)
|
|
{
|
|
if(!Resolve(uid, ref singularity))
|
|
return;
|
|
|
|
var newValue = singularity.Energy + delta;
|
|
if((!snapMin && newValue < min)
|
|
|| (!snapMax && newValue > max))
|
|
return;
|
|
SetEnergy(uid, MathHelper.Clamp(newValue, min, max), singularity);
|
|
}
|
|
|
|
|
|
#endregion Getters/Setters
|
|
|
|
#region Event Handlers
|
|
|
|
/// <summary>
|
|
/// Handles playing the startup sounds when a singulo forms.
|
|
/// Always sets up the ambient singularity rumble.
|
|
/// The formation sound only plays if the singularity is being created.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity that is forming.</param>
|
|
/// <param name="comp">The component of the singularity that is forming.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
protected override void OnSingularityStartup(EntityUid uid, SingularityComponent comp, ComponentStartup args)
|
|
{
|
|
MetaDataComponent? metaData = null;
|
|
if (Resolve(uid, ref metaData) && metaData.EntityLifeStage <= EntityLifeStage.Initializing)
|
|
_audio.PlayPvs(comp.FormationSound, uid);
|
|
|
|
comp.AmbientSoundStream = _audio.PlayPvs(comp.AmbientSound, uid)?.Entity;
|
|
UpdateSingularityLevel(uid, comp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Makes entities that have the singularity distortion visual warping always get their state shared with the client.
|
|
/// This prevents some major popin with large distortion ranges.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the entity that is gaining the shader.</param>
|
|
/// <param name="comp">The component of the shader that the entity is gaining.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
public void OnDistortionStartup(EntityUid uid, SingularityDistortionComponent comp, ComponentStartup args)
|
|
{
|
|
_pvs.AddGlobalOverride(uid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles playing the shutdown sounds when a singulo dissipates.
|
|
/// Always stops the ambient singularity rumble.
|
|
/// The dissipations sound only plays if the singularity is being destroyed.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity that is dissipating.</param>
|
|
/// <param name="comp">The component of the singularity that is dissipating.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
public void OnSingularityShutdown(EntityUid uid, SingularityComponent comp, ComponentShutdown args)
|
|
{
|
|
comp.AmbientSoundStream = _audio.Stop(comp.AmbientSoundStream);
|
|
|
|
MetaDataComponent? metaData = null;
|
|
if (Resolve(uid, ref metaData) && metaData.EntityLifeStage >= EntityLifeStage.Terminating)
|
|
{
|
|
var xform = Transform(uid);
|
|
var coordinates = xform.Coordinates;
|
|
|
|
// I feel like IsValid should be checking this or something idk.
|
|
if (!TerminatingOrDeleted(coordinates.EntityId))
|
|
_audio.PlayPvs(comp.DissipationSound, coordinates);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles wrapping the state of a singularity for server-client syncing.
|
|
/// </summary>
|
|
/// <param name="uid">The uid of the singularity that is being synced.</param>
|
|
/// <param name="comp">The state of the singularity that is being synced.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
private void HandleSingularityState(EntityUid uid, SingularityComponent comp, ref ComponentGetState args)
|
|
{
|
|
args.State = new SingularityComponentState(comp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds the energy of any entities that are consumed to the singularity that consumed them.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity that is consuming the entity.</param>
|
|
/// <param name="comp">The component of the singularity that is consuming the entity.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
public void OnConsumedEntity(EntityUid uid, SingularityComponent comp, ref EntityConsumedByEventHorizonEvent args)
|
|
{
|
|
// Don't double count singulo food
|
|
if (HasComp<SinguloFoodComponent>(args.Entity))
|
|
return;
|
|
if (HasComp<SupermatterComponent>(uid))
|
|
HasEatenSM = true;
|
|
AdjustEnergy(uid, BaseEntityEnergy, singularity: comp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds the energy of any tiles that are consumed to the singularity that consumed them.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity that is consuming the tiles.</param>
|
|
/// <param name="comp">The component of the singularity that is consuming the tiles.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
public void OnConsumedTiles(EntityUid uid, SingularityComponent comp, ref TilesConsumedByEventHorizonEvent args)
|
|
{
|
|
AdjustEnergy(uid, args.Tiles.Count * BaseTileEnergy, singularity: comp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds the energy of this singularity to singularities that consume it.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity that is being consumed.</param>
|
|
/// <param name="comp">The component of the singularity that is being consumed.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
private void OnConsumed(EntityUid uid, SingularityComponent comp, ref EventHorizonConsumedEntityEvent args)
|
|
{
|
|
// Should be slightly more efficient than checking literally everything we consume for a singularity component and doing the reverse.
|
|
if (EntityManager.TryGetComponent<SingularityComponent>(args.EventHorizonUid, out var singulo))
|
|
{
|
|
AdjustEnergy(args.EventHorizonUid, comp.Energy, singularity: singulo);
|
|
SetEnergy(uid, 0.0f, comp);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds some bonus energy from any singularity food to the singularity that consumes it.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity food that is being consumed.</param>
|
|
/// <param name="comp">The component of the singularity food that is being consumed.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
public void OnConsumed(EntityUid uid, SinguloFoodComponent comp, ref EventHorizonConsumedEntityEvent args)
|
|
{
|
|
if (EntityManager.TryGetComponent<SingularityComponent>(args.EventHorizonUid, out var singulo))
|
|
{
|
|
// Calculate the percentage change (positive or negative)
|
|
var percentageChange = singulo.Energy * (comp.EnergyFactor - 1f);
|
|
// Apply both the flat and percentage changes
|
|
AdjustEnergy(args.EventHorizonUid, comp.Energy + percentageChange, singularity: singulo);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the rate at which the singularities energy drains at when its level changes.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity that changed in level.</param>
|
|
/// <param name="comp">The component of the singularity that changed in level.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
public void UpdateEnergyDrain(EntityUid uid, SingularityComponent comp, SingularityLevelChangedEvent args)
|
|
{
|
|
comp.EnergyDrain = args.NewValue switch
|
|
{
|
|
6 => 0,
|
|
5 => 0,
|
|
4 => 20,
|
|
3 => 10,
|
|
2 => 5,
|
|
1 => 1,
|
|
_ => 0
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the possible speeds of the singulos random walk when the singularities level changes.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity.</param>
|
|
/// <param name="comp">The random walk component component sharing the entity with the singulo component.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
private void UpdateRandomWalk(EntityUid uid, RandomWalkComponent comp, SingularityLevelChangedEvent args)
|
|
{
|
|
var scale = MathF.Max(args.NewValue, 4);
|
|
comp.MinSpeed = 7.5f / scale;
|
|
comp.MaxSpeed = 10f / scale;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the size and strength of the singularities gravity well when the singularities level changes.
|
|
/// </summary>
|
|
/// <param name="uid">The entity UID of the singularity.</param>
|
|
/// <param name="comp">The gravity well component sharing the entity with the singulo component.</param>
|
|
/// <param name="args">The event arguments.</param>
|
|
private void UpdateGravityWell(EntityUid uid, GravityWellComponent comp, SingularityLevelChangedEvent args)
|
|
{
|
|
var singulos = args.Singularity;
|
|
comp.MaxRange = GravPulseRange(singulos);
|
|
(comp.BaseRadialAcceleration, comp.BaseTangentialAcceleration) = GravPulseAcceleration(singulos);
|
|
}
|
|
|
|
#endregion Event Handlers
|
|
}
|