mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 08:37:26 +00:00
Entity Table Probabilities API (#41920)
* push * fix * push * abstract and more accurate * new abstract method I guess * that table does not explode * webedit major * Update Content.Shared/EntityTable/ValueSelector/BinomialNumberSelector.cs Co-authored-by: SnappingOpossum <snappingopossum@outlook.com> * big ass merge conflicts * sadas * review --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: SnappingOpossum <snappingopossum@outlook.com>
This commit is contained in:
committed by
Coryler
co-authored by
SnappingOpossum
Princess Cheeseballs
Tayrtahn
parent
ccff0117bb
commit
ce7f99fbfb
@@ -27,15 +27,44 @@ public sealed class EntityTableSystem : EntitySystem
|
||||
return table.GetSpawns(rand, EntityManager, _prototypeManager, ctx);
|
||||
}
|
||||
|
||||
// TODO: Have this method be much better for entity tables
|
||||
public IEnumerable<EntProtoId> ListSpawns(EntityTableSelector? table, System.Random? rand = null, EntityTableContext? ctx = null)
|
||||
public IEnumerable<(EntProtoId spawn, double)> ListSpawns(EntityTablePrototype entTableProto, EntityTableContext? ctx = null)
|
||||
{
|
||||
return ListSpawns(entTableProto.Table, ctx);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a list of all the spawns in an EntityTable as keys, and their modified weights as values.
|
||||
/// </summary>
|
||||
/// <param name="table">Table we're examining</param>
|
||||
/// <param name="ctx">Optional extra context</param>
|
||||
public IEnumerable<(EntProtoId spawn, double)> ListSpawns(EntityTableSelector? table, EntityTableContext? ctx = null)
|
||||
{
|
||||
if (table == null)
|
||||
return new List<EntProtoId>();
|
||||
return new List<(EntProtoId spawn, double)>();
|
||||
|
||||
rand ??= _random.GetRandom();
|
||||
ctx ??= new EntityTableContext();
|
||||
return table.ListSpawns(rand, EntityManager, _prototypeManager, ctx);
|
||||
return table.ListSpawns(EntityManager, _prototypeManager, ctx);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="AverageSpawns(EntityTableSelector?,EntityTableContext?)"/>
|
||||
public IEnumerable<(EntProtoId spawn, double)> AverageSpawns(EntityTablePrototype entTableProto, EntityTableContext? ctx = null)
|
||||
{
|
||||
return AverageSpawns(entTableProto.Table, ctx);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the average expected spawns of a specific entity table.
|
||||
/// </summary>
|
||||
/// <param name="table">The entity table we want the spawns of</param>
|
||||
/// <param name="ctx">Optional EntityTableContext</param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<(EntProtoId spawn, double)> AverageSpawns(EntityTableSelector? table, EntityTableContext? ctx = null)
|
||||
{
|
||||
if (table == null)
|
||||
return new List<(EntProtoId spawn, double)>();
|
||||
|
||||
ctx ??= new EntityTableContext();
|
||||
return table.AverageSpawns(EntityManager, _prototypeManager, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user