using Content.Server.AI.Utility; using Content.Server.AI.Utility.AiLogic; 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, ComponentReference(typeof(IMoverComponent))] public class AiControllerComponent : Component, IMoverComponent { private string _logicName; private float _visionRadius; public override string Name => "AiController"; [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; } /// public override void Initialize() { base.Initialize(); // This component requires a physics component. if (!Owner.HasComponent()) Owner.AddComponent(); } /// public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); serializer.DataField(ref _logicName, "logic", null); serializer.DataField(ref _visionRadius, "vision", 8.0f); } protected override void Shutdown() { base.Shutdown(); Processor?.Shutdown(); } /// /// Movement speed (m/s) that the entity walks, after modifiers /// [ViewVariables] public float CurrentWalkSpeed { get { if (Owner.TryGetComponent(out MovementSpeedModifierComponent component)) { return component.CurrentWalkSpeed; } return MovementSpeedModifierComponent.DefaultBaseWalkSpeed; } } /// /// Movement speed (m/s) that the entity walks, after modifiers /// [ViewVariables] public float CurrentSprintSpeed { get { if (Owner.TryGetComponent(out MovementSpeedModifierComponent component)) { return component.CurrentSprintSpeed; } return MovementSpeedModifierComponent.DefaultBaseSprintSpeed; } } /// [ViewVariables] public float CurrentPushSpeed => 5.0f; /// [ViewVariables] public float GrabRange => 0.2f; /// /// Is the entity Sprinting (running)? /// [ViewVariables] public bool Sprinting { get; set; } = true; /// /// Calculated linear velocity direction of the entity. /// [ViewVariables] public Vector2 VelocityDir { get; set; } public GridCoordinates LastPosition { get; set; } [ViewVariables(VVAccess.ReadWrite)] public float StepSoundDistance { get; set; } public void SetVelocityDirection(Direction direction, bool enabled) { } } }