pAIs Play Music (#5614)

* Disable check

* vehicle test

* Make PAI stop instrument when turning off (player leaves/ejected)

* Give pAI an instrument component with a custom soundfont

* Add pAI synth program to custom ss14 soundfont

* Add new PAIMidi action that pAIs use to open their instruments

* Changed instrument component to allow its player to be the actor of its parent item

* Oops. Readds instrumentcomponent.

* ECS Changes

* Changed soundfont to ringtone

* Revert "Disable check"

This reverts commit 86001d8b5e94ee38d0c9504cb19826327b04fb16.

* Remove action parameters from ghost placeholder

* Revert "vehicle test"

This reverts commit 8a8ecf41083e0d5c8d4363ff02981bdab04bcd1c.

* Fixes to whitespace

* Even more fixes to whitespace

* Removed paiSynth sample from spacestation14.sf2

* Yet another indentation touchup
This commit is contained in:
hubismal
2021-12-02 12:49:18 -06:00
committed by GitHub
parent 33be919b84
commit a04720fdda
7 changed files with 72 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
using System;
using System.Linq;
using Content.Server.Ghost;
using Content.Shared.Actions.Behaviors;
using Content.Shared.Actions.Components;
using Content.Shared.Cooldown;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Server.GameObjects;
using Content.Shared.Instruments;
namespace Content.Server.Actions.Actions
{
/// <summary>
/// Pull up MIDI instrument interface for PAIs to "play themselves"
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class PAIMidi : IInstantAction
{
public void DoInstantAction(InstantActionEventArgs args)
{
if (!args.Performer.TryGetComponent<ServerUserInterfaceComponent>(out var serverUi)) return;
if (!args.Performer.TryGetComponent<ActorComponent>(out var actor)) return;
if (!serverUi.TryGetBoundUserInterface(InstrumentUiKey.Key,out var bui)) return;
bui.Toggle(actor.PlayerSession);
}
}
}

View File

@@ -2,9 +2,12 @@ using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.PAI;
using Content.Shared.Verbs;
using Content.Shared.Instruments;
using Content.Server.Popups;
using Content.Server.Instruments;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind.Components;
using Robust.Server.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.GameObjects;
@@ -16,6 +19,7 @@ namespace Content.Server.PAI
public class PAISystem : SharedPAISystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly InstrumentSystem _instrumentSystem = default!;
public override void Initialize()
{
@@ -97,6 +101,15 @@ namespace Content.Server.PAI
private void PAITurningOff(EntityUid uid)
{
UpdatePAIAppearance(uid, PAIStatus.Off);
// Close the instrument interface if it was open
// before closing
if (EntityManager.TryGetComponent<ServerUserInterfaceComponent>(uid, out var serverUi))
if (EntityManager.TryGetComponent<ActorComponent>(uid, out var actor))
if (serverUi.TryGetBoundUserInterface(InstrumentUiKey.Key,out var bui))
bui.Close(actor.PlayerSession);
// Stop instrument
if (EntityManager.TryGetComponent<InstrumentComponent>(uid, out var instrument)) _instrumentSystem.Clean(uid, instrument);
if (EntityManager.TryGetComponent<MetaDataComponent>(uid, out var metadata))
{
var proto = metadata.EntityPrototype;

View File

@@ -17,7 +17,8 @@ namespace Content.Shared.Actions
DebugTargetPointRepeat,
DebugTargetEntity,
DebugTargetEntityRepeat,
SpellPie
SpellPie,
PAIMidi
}
/// <summary>

View File

@@ -66,6 +66,17 @@
cooldown: 120
maxTargets: 3
- type: action
actionType: PAIMidi
icon: Interface/Actions/midi.png
name: "Play MIDI"
description: "Open your portable MIDI interface to soothe your owner."
filters:
- pai
- music
behaviorType: Instant
behavior: !type:PAIMidi
- type: action
actionType: DebugInstant
icon: Interface/Alerts/human_health.rsi/health1.png
@@ -133,3 +144,4 @@
repeat: true
behavior: !type:DebugTargetEntity { }

View File

@@ -6,6 +6,15 @@
name: personal ai device
description: Your electronic pal who's fun to be with!
components:
- type: Instrument
allowPercussion: false
handheld: false
bank: 1
program: 2
- type: UserInterface
interfaces:
- key: enum.InstrumentUiKey.Key
type: InstrumentBoundUserInterface
- type: Sprite
netsync: false
sprite: Objects/Devices/pda.rsi
@@ -20,6 +29,8 @@
- type: GhostRadio
- type: DoAfter
- type: Actions
innateActions:
- PAIMidi
# This has to be installed because otherwise they're not "alive",
# so they can ghost and come back.
# Note that the personal AI never "dies".

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B