Skip to content

Commit

Permalink
Fixed issue with IPC charge, and review suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pspritechologist committed Jun 24, 2023
1 parent 3420c0e commit 564258b
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class BatteryDrinkerComponent : Component

/// <summary>
/// How long it takes to drink from a battery, in seconds.
/// Is mutliplied by the source.
/// Is multiplied by the source.
/// </summary>
[DataField("drinkSpeed"), ViewVariables(VVAccess.ReadWrite)]
public float DrinkSpeed = 1.5f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public class RandomBatteryChargeComponent : Component
/// True if the current charge is based on the preexisting current charge, or false if it's based on the max charge.
/// </summary>
[DataField("basedOnMaxCharge")]
public bool BasedOnMaxCharge = false;
public bool BasedOnMaxCharge = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ private void OnDoAfter(EntityUid uid, BatteryDrinkerComponent drinkerComp, DoAft
amountToDrink = MathF.Min(amountToDrink, drinkerBattery.MaxCharge - drinkerBattery.CurrentCharge);

if (sourceComp != null && sourceComp.MaxAmount > 0)
{
amountToDrink = MathF.Min(amountToDrink, (float) sourceComp.MaxAmount);
}

if (amountToDrink <= 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ private void OnElectrocuted(EntityUid uid, BatteryComponent battery, Electrocute

battery.CurrentCharge += charge;

var message = Loc.GetString("battery-electrocute-charge");

_popup.PopupEntity(message, uid, uid);
_popup.PopupEntity(Loc.GetString("battery-electrocute-charge"), uid, uid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ private void OnSiliconChargeStateUpdate(EntityUid uid, SiliconDownOnDeadComponen
Logger.Debug($"Silicon battery: {batteryComp?.CurrentCharge}");

if (args.ChargeState == ChargeState.Dead && !siliconDeadComp.Dead)
{
SiliconDead(uid, siliconDeadComp, batteryComp);
}
else if (args.ChargeState != ChargeState.Dead && siliconDeadComp.Dead)
{
SiliconUnDead(uid, siliconDeadComp, batteryComp);
}
}

private void SiliconDead(EntityUid uid, SiliconDownOnDeadComponent siliconDeadComp, BatteryComponent? batteryComp)
Expand Down Expand Up @@ -65,7 +61,7 @@ private void SiliconUnDead(EntityUid uid, SiliconDownOnDeadComponent siliconDead
}

/// <summary>
/// A canellable event raised when a Silicon is about to go down due to charge.
/// A cancellable event raised when a Silicon is about to go down due to charge.
/// <summary>
public sealed class SiliconChargeDyingEvent : CancellableEntityEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public override void Update(float frameTime)

RaiseLocalEvent(silicon, new SiliconChargeStateUpdateEvent(currentState));

Logger.DebugS("silicon", $"Silicon {silicon} charge state updated to {currentState}.");

_moveMod.RefreshMovementSpeedModifiers(silicon);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public override void Update(float frameTime)

#region Entity Storage Chargers
// Check for any chargers with the EntityStorageComponent.
var entstorQuery = EntityQueryEnumerator<SiliconChargerComponent, EntityStorageComponent>();
while (entstorQuery.MoveNext(out var uid, out var chargerComp, out var entStorage))
var entityStorageQuery = EntityQueryEnumerator<SiliconChargerComponent, EntityStorageComponent>();
while (entityStorageQuery.MoveNext(out var uid, out var chargerComp, out var entStorage))
{
var wasActive = chargerComp.Active;
chargerComp.Active = false;
Expand All @@ -81,8 +81,6 @@ public override void Update(float frameTime)

var chargeRate = chargerComp.ChargeMulti * frameTime * 10;



HandleChargingEntity(entity, chargeRate, chargerComp, uid, frameTime);

// Heat up the air in the charger.
Expand Down Expand Up @@ -234,10 +232,8 @@ private List<EntityUid> SearchThroughEntities(EntityUid entity, bool burn = true
private void ChargeBattery(EntityUid entity, BatteryComponent batteryComp, float chargeRate, SiliconChargerComponent chargerComp, EntityUid chargerUid)
{
// Do some math so a charger never charges a battery from zero to full in less than 10 seconds, just for the effect of it.
if (chargerComp.ChargeMulti * 10 > batteryComp.MaxCharge / 10)
{
chargeRate /= chargerComp.ChargeMulti * 10 / (batteryComp.MaxCharge / 10);
}
if (chargerComp.ChargeMulti * 10 > batteryComp.MaxCharge / chargerComp.MinChargeTime)
chargeRate /= chargerComp.ChargeMulti * 10 / (batteryComp.MaxCharge / chargerComp.MinChargeTime);

if (batteryComp.CurrentCharge + chargeRate < batteryComp.MaxCharge)
_battery.SetCharge(entity, batteryComp.CurrentCharge + chargeRate, batteryComp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public sealed class SiliconChargerComponent : Component
/// The minimum amount of time it will take to charge a battery, in seconds.
/// </summary>
/// <remarks>
/// Note that this is from empty. A battery that is already half full will take half as long as this value to reach full, if it would've been faster from empty.
/// This is for the sake of feeling cooler- It's lame to just charge instantly.
/// </remarks>
[DataField("minChargeTime"), ViewVariables(VVAccess.ReadWrite)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Content.Shared.SimpleStation14.Silicon.Systems;


public sealed class SharedSiliconChargeSystem : EntitySystem
{
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ marking-ScreenEight = Eight
marking-ScreenGoggles = Goggles
marking-ScreenExclaim = Exclaim
marking-ScreenHeart = Heart
marking-ScreenMonoeye = Cylops
marking-ScreenMonoeye = Cyclops
marking-ScreenNature = Naturalist
marking-ScreenOrange = Orange
marking-ScreenPink = Pink
Expand Down
2 changes: 0 additions & 2 deletions Resources/Prototypes/SimpleStation14/Body/Parts/ipc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# TODO: Add descriptions (many)
# TODO BODY: Part damage
- type: entity
id: PartIPC
parent: BaseItem
Expand Down

0 comments on commit 564258b

Please sign in to comment.