Update vomit organ smite to not use Component.owner (#29926)
* 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 <plykiya@protonmail.com>
This commit is contained in:
@@ -285,18 +285,18 @@ public sealed partial class AdminVerbSystem
|
||||
{
|
||||
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,
|
||||
|
||||
@@ -183,6 +183,30 @@ public partial class SharedBodySystem
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user