Skip to content

Commit

Permalink
Update vomit organ smite to not use Component.owner (space-wizards#29926
Browse files Browse the repository at this point in the history
)

* Update vomit organ smite to not use Component.owner

* is this what you want...?

* am I winning, dad?

* update the comment

* we love entity<t>

---------

Co-authored-by: plykiya <[email protected]>
  • Loading branch information
Plykiya and plykiya committed Jul 25, 2024
1 parent 7388b91 commit 2a7883b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,18 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
{
Text = "admin-smite-remove-hands-name",
Category = VerbCategory.Smite,
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Fluids/vomit_toxin.rsi"), "vomit_toxin-1"),
Icon = new SpriteSpecifier.Rsi(new("/Textures/Fluids/vomit_toxin.rsi"), "vomit_toxin-1"),
Act = () =>
{
_vomitSystem.Vomit(args.Target, -1000, -1000); // You feel hollow!
var organs = _bodySystem.GetBodyOrganComponents<TransformComponent>(args.Target, body);
var organs = _bodySystem.GetBodyOrganEntityComps<TransformComponent>((args.Target, body));
var baseXform = Transform(args.Target);
foreach (var (xform, organ) in organs)
foreach (var organ in organs)
{
if (HasComp<BrainComponent>(xform.Owner) || HasComp<EyeComponent>(xform.Owner))
if (HasComp<BrainComponent>(organ.Owner) || HasComp<EyeComponent>(organ.Owner))
continue;
_transformSystem.AttachToGridOrMap(organ.Owner);
_transformSystem.PlaceNextTo((organ.Owner, organ.Comp1), (args.Target, baseXform));
}
_popupSystem.PopupEntity(Loc.GetString("admin-smite-vomit-organs-self"), args.Target,
Expand Down
24 changes: 24 additions & 0 deletions Content.Shared/Body/Systems/SharedBodySystem.Organs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,30 @@ public bool AddOrganToFirstValidSlot(
return list;
}

/// <summary>
/// Returns a list of Entity<<see cref="T"/>, <see cref="OrganComponent"/>>
/// for each organ of the body
/// </summary>
/// <typeparam name="T">The component that we want to return</typeparam>
/// <param name="entity">The body to check the organs of</param>
public List<Entity<T, OrganComponent>> GetBodyOrganEntityComps<T>(
Entity<BodyComponent?> entity)
where T : IComponent
{
if (!Resolve(entity, ref entity.Comp))
return new List<Entity<T, OrganComponent>>();

var query = GetEntityQuery<T>();
var list = new List<Entity<T, OrganComponent>>(3);
foreach (var organ in GetBodyOrgans(entity.Owner, entity.Comp))
{
if (query.TryGetComponent(organ.Id, out var comp))
list.Add((organ.Id, comp, organ.Component));
}

return list;
}

/// <summary>
/// Tries to get a list of ValueTuples of <see cref="T"/> and OrganComponent on each organs
/// in the given body.
Expand Down

0 comments on commit 2a7883b

Please sign in to comment.