/// <summary> /// Creates a sidebar action for an entity to be able to polymorph at will /// </summary> /// <param name="id">The string of the id of the polymorph action</param> /// <param name="target">The entity that will be gaining the action</param> public void CreatePolymorphAction(string id, EntityUid target) { if (!_proto.TryIndex <PolymorphPrototype>(id, out var polyproto)) { _saw.Error("Invalid polymorph prototype"); return; } if (!TryComp <PolymorphableComponent>(target, out var polycomp)) { return; } var entproto = _proto.Index <EntityPrototype>(polyproto.Entity); var act = new InstantAction() { Event = new PolymorphActionEvent(polyproto), Name = Loc.GetString("polymorph-self-action-name", ("target", entproto.Name)), Description = Loc.GetString("polymorph-self-action-description", ("target", entproto.Name)), Icon = new SpriteSpecifier.EntityPrototype(polyproto.Entity), ItemIconStyle = ItemActionIconStyle.NoItem, }; if (polycomp.PolymorphActions == null) { polycomp.PolymorphActions = new(); } polycomp.PolymorphActions.Add(id, act); _actions.AddAction(target, act, target); }
private void OnPolymorphActionEvent(EntityUid uid, PolymorphableComponent component, PolymorphActionEvent args) { PolymorphEntity(uid, args.Prototype); }