AI Wander & Barker (#286)

* Retrofit the AI system with new IoC features.
Fixed bug with turret rotation.

* Added new AI WanderProcessor, and it works.

* RNG walking directions are a bit more random now.

* Wander now actually uses the MoverSystem to move.
Wander now talks when he reaches his destination.

* Adds a new Static Barker AI for vending machines, so that they periodically advertise their brand.

* Barker now says some generic slogans.
Misc bug cleanup.

* Removed useless UsedImplicitly attribute from AI dependencies, suppressed unused variable warnings instead.
This commit is contained in:
Acruid
2019-08-10 05:19:52 -07:00
committed by Pieter-Jan Briers
parent 4b30c7e710
commit 8b593d28c6
8 changed files with 464 additions and 26 deletions

View File

@@ -1,11 +1,15 @@
using Content.Server.Interfaces.GameObjects.Components.Movement;
using Robust.Server.AI;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Movement
{
[RegisterComponent]
[RegisterComponent, ComponentReference(typeof(IMoverComponent))]
public class AiControllerComponent : Component, IMoverComponent
{
private string _logicName;
@@ -13,15 +17,37 @@ namespace Content.Server.GameObjects.Components.Movement
public override string Name => "AiController";
public string LogicName => _logicName;
[ViewVariables(VVAccess.ReadWrite)]
public string LogicName
{
get => _logicName;
set
{
_logicName = value;
Processor = null;
}
}
public AiLogicProcessor Processor { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public float VisionRadius
{
get => _visionRadius;
set => _visionRadius = value;
}
/// <inheritdoc />
public override void Initialize()
{
base.Initialize();
// This component requires a physics component.
if (!Owner.HasComponent<PhysicsComponent>())
Owner.AddComponent<PhysicsComponent>();
}
/// <inheritdoc />
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
@@ -29,5 +55,34 @@ namespace Content.Server.GameObjects.Components.Movement
serializer.DataField(ref _logicName, "logic", null);
serializer.DataField(ref _visionRadius, "vision", 8.0f);
}
/// <summary>
/// Movement speed (m/s) that the entity walks.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float WalkMoveSpeed { get; set; } = 4.0f;
/// <summary>
/// Movement speed (m/s) that the entity sprints.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float SprintMoveSpeed { get; set; } = 10.0f;
/// <summary>
/// Is the entity Sprinting (running)?
/// </summary>
[ViewVariables]
public bool Sprinting { get; set; }
/// <summary>
/// Calculated linear velocity direction of the entity.
/// </summary>
[ViewVariables]
public Vector2 VelocityDir { get; set; }
public GridCoordinates LastPosition { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public float StepSoundDistance { get; set; }
}
}