mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
Predict borgs (#41600)
* predict borgs * small fix * fix MMI item slot serialization * fix movement speed for mothership core * review and minor improvement * fix resolve * review
This commit is contained in:
committed by
BarryNorfolk
parent
43832b5d5a
commit
da88db8775
@@ -8,6 +8,23 @@ namespace Content.Shared.PowerCell;
|
||||
|
||||
public sealed partial class PowerCellSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a power cell slot has a battery inside.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public bool HasBattery(Entity<PowerCellSlotComponent?> ent)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp, false))
|
||||
return false;
|
||||
|
||||
if (!_itemSlots.TryGetSlot(ent.Owner, ent.Comp.CellSlotId, out var slot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return slot.Item != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the power cell battery inside a power cell slot.
|
||||
/// </summary>
|
||||
@@ -22,7 +39,7 @@ public sealed partial class PowerCellSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_itemSlots.TryGetSlot(ent.Owner, ent.Comp.CellSlotId, out ItemSlot? slot))
|
||||
if (!_itemSlots.TryGetSlot(ent.Owner, ent.Comp.CellSlotId, out var slot))
|
||||
{
|
||||
battery = null;
|
||||
return false;
|
||||
@@ -97,10 +114,39 @@ public sealed partial class PowerCellSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to eject the power cell battery inside a power cell slot.
|
||||
/// This checks if the user has a free hand to do the ejection and if the slot is locked.
|
||||
/// </summary>
|
||||
/// <param name="ent">The entity with the power cell slot.</param>
|
||||
/// <param name="battery">The power cell that was ejected.</param>
|
||||
/// <param name="user">The player trying to eject the power cell from the slot.</param>
|
||||
/// <returns>If a power cell was sucessfully ejected.</returns>
|
||||
[PublicAPI]
|
||||
public bool TryEjectBatteryFromSlot(
|
||||
Entity<PowerCellSlotComponent?> ent,
|
||||
[NotNullWhen(true)] out EntityUid? battery,
|
||||
EntityUid? user = null)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp, false))
|
||||
{
|
||||
battery = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_itemSlots.TryEject(ent.Owner, ent.Comp.CellSlotId, user, out battery, excludeUserAudio: true))
|
||||
{
|
||||
battery = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the entity has a slotted battery and charge for the requested action.
|
||||
/// </summary>
|
||||
/// <param name="ent">The power cell.</param>
|
||||
/// <param name="ent">The entity with the power cell slot.</param>
|
||||
/// <param name="charge">The charge that is needed.</param>
|
||||
/// <param name="user">Show a popup to this user with the relevant details if specified.</param>
|
||||
/// <param name="predicted">Whether to predict the popup or not.</param>
|
||||
@@ -139,7 +185,7 @@ public sealed partial class PowerCellSystem
|
||||
/// <summary>
|
||||
/// Tries to use charge from a slotted battery.
|
||||
/// </summary>
|
||||
/// <param name="ent">The power cell.</param>
|
||||
/// <param name="ent">The entity with the power cell slot.</param>
|
||||
/// <param name="charge">The charge that is needed.</param>
|
||||
/// <param name="user">Show a popup to this user with the relevant details if specified.</param>
|
||||
/// <param name="predicted">Whether to predict the popup or not.</param>
|
||||
@@ -177,7 +223,7 @@ public sealed partial class PowerCellSystem
|
||||
/// <summary>
|
||||
/// Gets number of remaining uses for the given charge cost.
|
||||
/// </summary>
|
||||
/// <param name="ent">The power cell.</param>
|
||||
/// <param name="ent">The entity with the power cell slot.</param>
|
||||
/// <param name="cost">The cost per use.</param>
|
||||
[PublicAPI]
|
||||
public int GetRemainingUses(Entity<PowerCellSlotComponent?> ent, float cost)
|
||||
@@ -191,7 +237,7 @@ public sealed partial class PowerCellSystem
|
||||
/// <summary>
|
||||
/// Gets number of maximum uses at full charge for the given charge cost.
|
||||
/// </summary>
|
||||
/// <param name="ent">The power cell.</param>
|
||||
/// <param name="ent">The entity with the power cell slot.</param>
|
||||
/// <param name="cost">The cost per use.</param>
|
||||
[PublicAPI]
|
||||
public int GetMaxUses(Entity<PowerCellSlotComponent?> ent, float cost)
|
||||
|
||||
Reference in New Issue
Block a user