Killer tomatoes (#26053)
* make tomatoes * many friends! many mommies * finish * renaming system * fix * Update miscellaneous.yml * Update Content.Server/NPC/Systems/NPCImpritingBehaviourSystem.cs Co-authored-by: faint <46868845+ficcialfaint@users.noreply.github.com> * N * deleete exception? * merge conflict fix * fix? * fuck you * sloth fixes * fixess? * fix --------- Co-authored-by: faint <46868845+ficcialfaint@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.NPC.Components;
|
||||
using Content.Shared.NPC.Systems;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Random;
|
||||
using NPCImprintingOnSpawnBehaviourComponent = Content.Server.NPC.Components.NPCImprintingOnSpawnBehaviourComponent;
|
||||
|
||||
namespace Content.Server.NPC.Systems;
|
||||
|
||||
public sealed partial class NPCImprintingOnSpawnBehaviourSystem : SharedNPCImprintingOnSpawnBehaviourSystem
|
||||
{
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly NPCSystem _npc = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<NPCImprintingOnSpawnBehaviourComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<NPCImprintingOnSpawnBehaviourComponent> imprinting, ref MapInitEvent args)
|
||||
{
|
||||
HashSet<EntityUid> friends = new();
|
||||
_lookup.GetEntitiesInRange(imprinting, imprinting.Comp.SpawnFriendsSearchRadius, friends);
|
||||
|
||||
foreach (var friend in friends)
|
||||
{
|
||||
if (imprinting.Comp.Whitelist?.IsValid(friend) != false)
|
||||
{
|
||||
AddImprintingTarget(imprinting, friend, imprinting.Comp);
|
||||
}
|
||||
}
|
||||
|
||||
if (imprinting.Comp.Follow && imprinting.Comp.Friends.Count > 0)
|
||||
{
|
||||
var mommy = _random.Pick(imprinting.Comp.Friends);
|
||||
_npc.SetBlackboard(imprinting, NPCBlackboard.FollowTarget, new EntityCoordinates(mommy, Vector2.Zero));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddImprintingTarget(EntityUid entity, EntityUid friend, NPCImprintingOnSpawnBehaviourComponent component)
|
||||
{
|
||||
component.Friends.Add(friend);
|
||||
var exception = EnsureComp<FactionExceptionComponent>(entity);
|
||||
exception.Ignored.Add(friend);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user