-
Notifications
You must be signed in to change notification settings - Fork 453
DeltaV/DS14 IPC Port #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
DeltaV/DS14 IPC Port #744
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
2ce54df
Complete IPC overhaul (#31)
Day-OS 5f01431
Updated old conventions
Timemaster99 228df04
Fixed IPC guidebook locale
Timemaster99 898306e
Fixed color for markings and IPC
Timemaster99 fee3e9e
IPCs can no longer eject their own battery, in congruence with borgs
Timemaster99 86ff7b4
IPCs no longer lose charge when SSD or ghosted
Timemaster99 2dab6e9
Refactored IPC alerts to use borg health and battery instead
Timemaster99 858d906
Updated markings
Timemaster99 f5cbe6f
Marked, moved, and commented changes to base files
Timemaster99 8451c84
IPCs are now alerted when another person tries to toggle their lock
Timemaster99 1cba5b3
Added missing comment in BatterySlotRequiresLockSystem
Timemaster99 c9dfe0c
Readded markings locale
Timemaster99 529fd4f
Removed ChargeBuffer so IPCs can be recharged instantly. Fixed indefi…
Timemaster99 67ec515
Removed duplicate markings and emotes
Timemaster99 b6eec41
Merge branch 'master' into dv-ipc
DangerRevolution 138522f
Removed mentions of old charge alert
Timemaster99 1410bd2
Merge branch 'dv-ipc' of https://github.com/Timemaster99/Einstein-Eng…
Timemaster99 baca54c
Moved namespaces to generic
Timemaster99 a05399d
Removed codebase comments
Timemaster99 f27e27d
Migrated audio files to generic dir, adjusted references
Timemaster99 9babf74
Migrated ftl files to generic dir
Timemaster99 f6d001f
Migrate textures to generic dir
Timemaster99 cbe851a
Migrated yml files to generic dir
Timemaster99 04528c8
Migrated guidebook to generic dir
Timemaster99 2c6ef82
Removed unused fields from emote prototype
Timemaster99 78cd087
Merge branch 'master' into dv-ipc
Timemaster99 2ed5d93
Removed old head marking
Timemaster99 277457a
Blacklisted certain traits from IPCs
Timemaster99 7d1f58f
Fixed species requirements yaml
Timemaster99 8f7bb68
Added missing if statement to charge update system
Timemaster99 0cf5275
Added mood to IPCs
Timemaster99 bc2aeda
Readded nyano comments
Timemaster99 db4934b
Apply suggestions from code review
Timemaster99 8f0783a
Update Content.Server/Power/Components/SiliconEmitSoundOnDrainedCompo…
VMSolidus 1ca1df8
Update Content.Server/Power/Components/SiliconEmitSoundOnDrainedCompo…
VMSolidus c747183
Added extra info on npc silicon state
Timemaster99 475411d
Apply suggestions from code review
Timemaster99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Content.Server/Power/Components/BatteryDrinkerComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| namespace Content.Server.Power; | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class BatteryDrinkerComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// Is this drinker allowed to drink batteries not tagged as <see cref="BatteryDrinkSource"/>? | ||
| /// </summary> | ||
| [DataField("drinkAll"), ViewVariables(VVAccess.ReadWrite)] | ||
| public bool DrinkAll = false; | ||
|
|
||
| /// <summary> | ||
| /// How long it takes to drink from a battery, in seconds. | ||
| /// Is multiplied by the source. | ||
| /// </summary> | ||
| [DataField("drinkSpeed"), ViewVariables(VVAccess.ReadWrite)] | ||
| public float DrinkSpeed = 1.5f; | ||
|
|
||
| /// <summary> | ||
| /// The multiplier for the amount of power to attempt to drink. | ||
| /// Default amount is 1000 | ||
| /// </summary> | ||
| [DataField("drinkMultiplier"), ViewVariables(VVAccess.ReadWrite)] | ||
| public float DrinkMultiplier = 5f; | ||
|
|
||
| /// <summary> | ||
| /// The multiplier for how long it takes to drink a non-source battery, if <see cref="DrinkAll"/> is true. | ||
| /// </summary> | ||
| [DataField("drinkAllMultiplier"), ViewVariables(VVAccess.ReadWrite)] | ||
| public float DrinkAllMultiplier = 2.5f; | ||
|
Timemaster99 marked this conversation as resolved.
|
||
| } | ||
26 changes: 26 additions & 0 deletions
26
Content.Server/Power/Components/RandomBatteryChargeComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using System.Numerics; | ||
|
|
||
| namespace Content.Server.Power.Components; | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class RandomBatteryChargeComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// The minimum and maximum max charge the battery can have. | ||
| /// </summary> | ||
| [DataField("batteryMaxMinMax")] | ||
| public Vector2 BatteryMaxMinMax = new(0.85f, 1.15f); | ||
|
|
||
| /// <summary> | ||
| /// The minimum and maximum current charge the battery can have. | ||
| /// </summary> | ||
| [DataField("batteryChargeMinMax")] | ||
| public Vector2 BatteryChargeMinMax = new(1f, 1f); | ||
|
|
||
| /// <summary> | ||
| /// False if the randomized charge of the battery should be a multiple of the preexisting current charge of the battery. | ||
| /// True if the randomized charge of the battery should be a multiple of the max charge of the battery post max charge randomization. | ||
| /// </summary> | ||
| [DataField("basedOnMaxCharge")] | ||
| public bool BasedOnMaxCharge = true; | ||
|
Timemaster99 marked this conversation as resolved.
|
||
| } | ||
27 changes: 27 additions & 0 deletions
27
Content.Server/Power/Components/SiliconEmitSoundOnDrainedComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
| using Robust.Shared.Audio; | ||
| using Content.Server.Sound.Components; | ||
|
|
||
| namespace Content.Server.Silicon; | ||
|
|
||
| /// <summary> | ||
| /// Applies a <see cref="SpamEmitSoundComponent"/> to a Silicon when its battery is drained, and removes it when it's not. | ||
| /// </summary> | ||
| [RegisterComponent] | ||
| public sealed partial class SiliconEmitSoundOnDrainedComponent : Component | ||
| { | ||
| [DataField("sound"), Required] | ||
| public SoundSpecifier Sound = default!; | ||
|
|
||
| [DataField("minInterval")] | ||
| public TimeSpan Interval = TimeSpan.FromSeconds(8); | ||
|
|
||
| [DataField("maxInterval")] | ||
| public TimeSpan MaxInterval = TimeSpan.FromSeconds(15); | ||
|
|
||
| [DataField("playChance")] | ||
| public float PlayChance = 1f; | ||
|
|
||
| [DataField("popUp")] | ||
| public string? PopUp; | ||
|
Timemaster99 marked this conversation as resolved.
Outdated
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Linq; | ||
| using Content.Server.Power.Components; | ||
| using Content.Shared.Containers.ItemSlots; | ||
| using Content.Shared.DoAfter; | ||
| using Content.Shared.PowerCell.Components; | ||
| using Content.Shared.Silicon; | ||
| using Content.Shared.Verbs; | ||
| using Robust.Shared.Utility; | ||
| using Content.Server.Silicon.Charge; | ||
| using Content.Server.Power.EntitySystems; | ||
| using Content.Server.Popups; | ||
| using Content.Server.PowerCell; | ||
| using Content.Shared.Popups; | ||
| using Content.Shared.Silicon.Components; | ||
| using FastAccessors; | ||
| using Robust.Shared.Audio.Systems; | ||
| using Robust.Shared.Containers; | ||
|
|
||
| namespace Content.Server.Power; | ||
|
|
||
| public sealed class BatteryDrinkerSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly ItemSlotsSystem _slots = default!; | ||
| [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; | ||
| [Dependency] private readonly SharedAudioSystem _audio = default!; | ||
| [Dependency] private readonly BatterySystem _battery = default!; | ||
| [Dependency] private readonly SiliconChargeSystem _silicon = default!; | ||
| [Dependency] private readonly PopupSystem _popup = default!; | ||
| [Dependency] private readonly PowerCellSystem _powerCell = default!; | ||
| [Dependency] private readonly SharedContainerSystem _container = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<BatteryComponent, GetVerbsEvent<AlternativeVerb>>(AddAltVerb); | ||
|
|
||
| SubscribeLocalEvent<BatteryDrinkerComponent, BatteryDrinkerDoAfterEvent>(OnDoAfter); | ||
| } | ||
|
|
||
| private void AddAltVerb(EntityUid uid, BatteryComponent batteryComponent, GetVerbsEvent<AlternativeVerb> args) | ||
| { | ||
| if (!args.CanAccess || !args.CanInteract) | ||
| return; | ||
|
|
||
| if (!TryComp<BatteryDrinkerComponent>(args.User, out var drinkerComp) || | ||
| !TestDrinkableBattery(uid, drinkerComp) || | ||
| !_silicon.TryGetSiliconBattery(args.User, out var drinkerBattery)) | ||
| return; | ||
|
|
||
| AlternativeVerb verb = new() | ||
| { | ||
| Act = () => DrinkBattery(uid, args.User, drinkerComp), | ||
| Text = Loc.GetString("battery-drinker-verb-drink"), | ||
| Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/smite.svg.192dpi.png")), | ||
| }; | ||
|
|
||
| args.Verbs.Add(verb); | ||
| } | ||
|
|
||
| private bool TestDrinkableBattery(EntityUid target, BatteryDrinkerComponent drinkerComp) | ||
| { | ||
| if (!drinkerComp.DrinkAll && !HasComp<BatteryDrinkerSourceComponent>(target)) | ||
| return false; | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| private void DrinkBattery(EntityUid target, EntityUid user, BatteryDrinkerComponent drinkerComp) | ||
| { | ||
| var doAfterTime = drinkerComp.DrinkSpeed; | ||
|
|
||
| if (TryComp<BatteryDrinkerSourceComponent>(target, out var sourceComp)) | ||
| doAfterTime *= sourceComp.DrinkSpeedMulti; | ||
| else | ||
| doAfterTime *= drinkerComp.DrinkAllMultiplier; | ||
|
|
||
| var args = new DoAfterArgs(EntityManager, user, doAfterTime, new BatteryDrinkerDoAfterEvent(), user, target) // TODO: Make this doafter loop, once we merge Upstream. | ||
| { | ||
| BreakOnDamage = true, | ||
| BreakOnTargetMove = true, | ||
| Broadcast = false, | ||
| DistanceThreshold = 1.35f, | ||
| RequireCanInteract = true, | ||
| CancelDuplicate = false | ||
| }; | ||
|
|
||
| _doAfter.TryStartDoAfter(args); | ||
| } | ||
|
|
||
| private void OnDoAfter(EntityUid uid, BatteryDrinkerComponent drinkerComp, DoAfterEvent args) | ||
| { | ||
| if (args.Cancelled || args.Target == null) | ||
| return; | ||
|
|
||
| var source = args.Target.Value; | ||
| var drinker = uid; | ||
| var sourceBattery = Comp<BatteryComponent>(source); | ||
|
|
||
| _silicon.TryGetSiliconBattery(drinker, out var drinkerBatteryComponent); | ||
|
|
||
| if (!TryComp(uid, out PowerCellSlotComponent? batterySlot)) | ||
| return; | ||
|
|
||
| var container = _container.GetContainer(uid, batterySlot.CellSlotId); | ||
| var drinkerBattery = container.ContainedEntities.First(); | ||
|
|
||
| TryComp<BatteryDrinkerSourceComponent>(source, out var sourceComp); | ||
|
|
||
| DebugTools.AssertNotNull(drinkerBattery); | ||
|
|
||
| if (drinkerBattery == null) | ||
| return; | ||
|
|
||
| var amountToDrink = drinkerComp.DrinkMultiplier * 1000; | ||
|
|
||
| amountToDrink = MathF.Min(amountToDrink, sourceBattery.CurrentCharge); | ||
| amountToDrink = MathF.Min(amountToDrink, drinkerBatteryComponent!.MaxCharge - drinkerBatteryComponent.CurrentCharge); | ||
|
|
||
| if (sourceComp != null && sourceComp.MaxAmount > 0) | ||
| amountToDrink = MathF.Min(amountToDrink, (float) sourceComp.MaxAmount); | ||
|
|
||
| if (amountToDrink <= 0) | ||
| { | ||
| _popup.PopupEntity(Loc.GetString("battery-drinker-empty", ("target", source)), drinker, drinker); | ||
| return; | ||
| } | ||
|
|
||
| if (_battery.TryUseCharge(source, amountToDrink)) | ||
| _battery.SetCharge(drinkerBattery, drinkerBatteryComponent.CurrentCharge + amountToDrink, drinkerBatteryComponent); | ||
| else | ||
| { | ||
| _battery.SetCharge(drinkerBattery, sourceBattery.CurrentCharge + drinkerBatteryComponent.CurrentCharge, drinkerBatteryComponent); | ||
| _battery.SetCharge(source, 0); | ||
| } | ||
|
|
||
| if (sourceComp != null && sourceComp.DrinkSound != null){ | ||
| _popup.PopupEntity(Loc.GetString("ipc-recharge-tip"), drinker, drinker, PopupType.SmallCaution); | ||
| _audio.PlayPvs(sourceComp.DrinkSound, source); | ||
| Spawn("EffectSparks", Transform(source).Coordinates); | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
Content.Server/Power/Systems/BatteryElectrocuteChargeSystem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using Content.Server.Electrocution; | ||
| using Content.Server.Popups; | ||
| using Content.Server.Power.Components; | ||
| using Content.Server.Power.EntitySystems; | ||
| using Content.Shared.Electrocution; | ||
| using Robust.Shared.Random; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Server.Power.Systems; | ||
|
|
||
| public sealed class BatteryElectrocuteChargeSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly IRobustRandom _random = default!; | ||
| [Dependency] private readonly PopupSystem _popup = default!; | ||
| [Dependency] private readonly BatterySystem _battery = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<BatteryComponent, ElectrocutedEvent>(OnElectrocuted); | ||
| } | ||
|
|
||
| private void OnElectrocuted(EntityUid uid, BatteryComponent battery, ElectrocutedEvent args) | ||
| { | ||
| if (args.ShockDamage == null || args.ShockDamage <= 0) | ||
| return; | ||
|
|
||
| var damagePerWatt = ElectrocutionSystem.ElectrifiedDamagePerWatt * 2; | ||
|
|
||
| var damage = args.ShockDamage.Value * args.SiemensCoefficient; | ||
| var charge = Math.Min(damage / damagePerWatt, battery.MaxCharge * 0.25f) * _random.NextFloat(0.75f, 1.25f); | ||
|
|
||
| _battery.SetCharge(uid, battery.CurrentCharge + charge); | ||
|
|
||
| _popup.PopupEntity(Loc.GetString("battery-electrocute-charge"), uid, uid); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.