* Add NPC faction tags Some stuff isn't easy to represent by the existence of components so tags are intended to provide that functionality for AI usage. I was 50/50 on having all tags in the 1 component or splitting it into 2. I'm leaning towards 2. This would be for stuff like say "CanMimic" so the mimic knows it's allowed to look like a specific prototype, or something like "smg" on a gun so it can say smg-specific barks for instance (as currently smgs and pistols look the same from a component perspective). This also means combat behaviors aren't hardcoded per faction, plus it makes it easy to update faction relations during events. * Factions command Update faction relationships via commands. * Remove command TODO * Woops Forgot to commit these items * Serializer writing and parsing * linq me up fam Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Content.Server.AI.Utility.Actions;
|
|
using Content.Server.AI.Utility.Actions.Combat.Melee;
|
|
using Content.Server.AI.Utility.Considerations;
|
|
using Content.Server.AI.Utility.Considerations.Combat.Melee;
|
|
using Content.Server.AI.Utils;
|
|
using Content.Server.AI.WorldState;
|
|
using Content.Server.AI.WorldState.States;
|
|
using Content.Server.GameObjects.Components.Movement;
|
|
using Content.Server.GameObjects.EntitySystems.AI;
|
|
using Content.Shared.GameObjects.Components.Body;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.GameObjects.Systems;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee
|
|
{
|
|
public sealed class UnarmedAttackNearbyPlayerExp : ExpandableUtilityAction
|
|
{
|
|
public override float Bonus => UtilityAction.CombatBonus;
|
|
|
|
protected override IEnumerable<Func<float>> GetCommonConsiderations(Blackboard context)
|
|
{
|
|
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
|
|
|
|
return new[]
|
|
{
|
|
considerationsManager.Get<CanUnarmedCombatCon>()
|
|
.BoolCurve(context),
|
|
};
|
|
}
|
|
|
|
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
|
{
|
|
var owner = context.GetState<SelfState>().GetValue();
|
|
if (!owner.TryGetComponent(out AiControllerComponent controller))
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
|
|
foreach (var target in EntitySystem.Get<AiFactionTagSystem>()
|
|
.GetNearbyHostiles(owner, controller.VisionRadius))
|
|
{
|
|
yield return new UnarmedAttackEntity(owner, target, Bonus);
|
|
}
|
|
}
|
|
}
|
|
}
|