Add utility AI (#806)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -38,7 +38,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
private float _arcWidth;
|
||||
private string _arc;
|
||||
private string _hitSound;
|
||||
private float _cooldownTime;
|
||||
public float CooldownTime => _cooldownTime;
|
||||
private float _cooldownTime = 1f;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string Arc
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
|
||||
|
||||
[ViewVariables] private string _defaultMagazine;
|
||||
|
||||
public ContainerSlot MagazineSlot => _magazineSlot;
|
||||
[ViewVariables] private ContainerSlot _magazineSlot;
|
||||
private List<BallisticMagazineType> _magazineTypes;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
|
||||
FireAtCoord(user, clickLocation, ammo.ProjectileID, total_stdev, ammo.ProjectilesFired, final_evenspread, final_velocity);
|
||||
}
|
||||
|
||||
protected IEntity GetChambered(int chamber) => _chambers[chamber].Slot.ContainedEntity;
|
||||
public IEntity GetChambered(int chamber) => _chambers[chamber].Slot.ContainedEntity;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the next ammo casing into the chamber.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -60,6 +61,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
|
||||
}
|
||||
}
|
||||
|
||||
// Probably shouldn't be a separate method but don't want anything except NPCs calling this,
|
||||
// and currently ranged combat is handled via player only messages
|
||||
public void AiFire(IEntity entity, GridCoordinates coordinates)
|
||||
{
|
||||
if (!entity.HasComponent<AiControllerComponent>())
|
||||
{
|
||||
throw new InvalidOperationException("Only AIs should call AiFire");
|
||||
}
|
||||
|
||||
_tryFire(entity, coordinates);
|
||||
}
|
||||
|
||||
private void _tryFire(IEntity user, GridCoordinates coordinates)
|
||||
{
|
||||
if (!user.TryGetComponent(out HandsComponent hands) || hands.GetActiveHand?.Owner != Owner)
|
||||
@@ -75,11 +88,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Firing delays are quite complicated.
|
||||
// Sometimes the client's fire messages come in just too early.
|
||||
// Generally this is a frame or two of being early.
|
||||
// In that case we try them a few times the next frames to avoid having to drop them.
|
||||
|
||||
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
var span = curTime - _lastFireTime;
|
||||
if (span.TotalSeconds < 1 / FireRate)
|
||||
|
||||
Reference in New Issue
Block a user