Add support for contextual information in EntityTables (#37737)
* Add context support for entityTables * fix build fail * comments * Update Content.Shared/EntityTable/EntityTableSystem.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -42,9 +42,10 @@ public abstract partial class EntityTableSelector
|
||||
|
||||
public IEnumerable<EntProtoId> GetSpawns(System.Random rand,
|
||||
IEntityManager entMan,
|
||||
IPrototypeManager proto)
|
||||
IPrototypeManager proto,
|
||||
EntityTableContext ctx)
|
||||
{
|
||||
if (!CheckConditions(entMan, proto))
|
||||
if (!CheckConditions(entMan, proto, ctx))
|
||||
yield break;
|
||||
|
||||
var rolls = Rolls.Get(rand);
|
||||
@@ -53,14 +54,14 @@ public abstract partial class EntityTableSelector
|
||||
if (!rand.Prob(Prob))
|
||||
continue;
|
||||
|
||||
foreach (var spawn in GetSpawnsImplementation(rand, entMan, proto))
|
||||
foreach (var spawn in GetSpawnsImplementation(rand, entMan, proto, ctx))
|
||||
{
|
||||
yield return spawn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckConditions(IEntityManager entMan, IPrototypeManager proto)
|
||||
public bool CheckConditions(IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
|
||||
{
|
||||
if (Conditions.Count == 0)
|
||||
return true;
|
||||
@@ -68,7 +69,7 @@ public abstract partial class EntityTableSelector
|
||||
var success = false;
|
||||
foreach (var condition in Conditions)
|
||||
{
|
||||
var res = condition.Evaluate(entMan, proto);
|
||||
var res = condition.Evaluate(this, entMan, proto, ctx);
|
||||
|
||||
if (RequireAll && !res)
|
||||
return false; // intentional break out of loop and function
|
||||
@@ -84,5 +85,6 @@ public abstract partial class EntityTableSelector
|
||||
|
||||
protected abstract IEnumerable<EntProtoId> GetSpawnsImplementation(System.Random rand,
|
||||
IEntityManager entMan,
|
||||
IPrototypeManager proto);
|
||||
IPrototypeManager proto,
|
||||
EntityTableContext ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user