Portable Generator Rework (#19302)
This commit is contained in:
committed by
GitHub
parent
50828363fe
commit
bf16698efa
@@ -183,6 +183,29 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to set the amount of material in the storage to a specific value.
|
||||
/// Still respects the filters in place.
|
||||
/// </summary>
|
||||
/// <param name="uid">The entity to change the material storage on.</param>
|
||||
/// <param name="materialId">The ID of the material to change.</param>
|
||||
/// <param name="volume">The stored material volume to set the storage to.</param>
|
||||
/// <param name="component">The storage component on <paramref name="uid"/>. Resolved automatically if not given.</param>
|
||||
/// <returns>True if it was successful (enough space etc).</returns>
|
||||
public bool TrySetMaterialAmount(
|
||||
EntityUid uid,
|
||||
string materialId,
|
||||
int volume,
|
||||
MaterialStorageComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
|
||||
var curAmount = GetMaterialAmount(uid, materialId, component);
|
||||
var delta = volume - curAmount;
|
||||
return TryChangeMaterialAmount(uid, materialId, delta, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to insert an entity into the material storage.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user