Fix error when manually adding ChasingWalkComponent to an entity (#30207)
This commit is contained in:
@@ -65,7 +65,7 @@ public sealed partial class ChasingWalkComponent : Component
|
|||||||
/// The component that the entity is chasing
|
/// The component that the entity is chasing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField(required: true)]
|
[DataField(required: true)]
|
||||||
public ComponentRegistry ChasingComponent = default!;
|
public ComponentRegistry ChasingComponent = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum radius in which the entity chooses the target component to follow
|
/// The maximum radius in which the entity chooses the target component to follow
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ public sealed class ChasingWalkSystem : VirtualController
|
|||||||
|
|
||||||
private void ChangeTarget(EntityUid uid, ChasingWalkComponent component)
|
private void ChangeTarget(EntityUid uid, ChasingWalkComponent component)
|
||||||
{
|
{
|
||||||
|
if (component.ChasingComponent.Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
//We find our coordinates and calculate the radius of the target search.
|
//We find our coordinates and calculate the radius of the target search.
|
||||||
var xform = Transform(uid);
|
var xform = Transform(uid);
|
||||||
var range = component.MaxChaseRadius;
|
var range = component.MaxChaseRadius;
|
||||||
|
|||||||
Reference in New Issue
Block a user