Speech and Emoting components (#3075)
* Add Speech and Emoting components. * makesentient gives you speech and emoting abilities. * Ghosts do *not* need a SpeechComponent. * I hate you all, and I hate shared code as well.
This commit is contained in:
committed by
GitHub
parent
b62cc84e8c
commit
63e1252539
@@ -4,6 +4,7 @@ using Content.Server.Administration;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Headset;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.Mobs.Speech;
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#nullable enable
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.Components.Mobs.Speech;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.GameObjects.Components.Mobs.Speech;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -47,6 +49,8 @@ namespace Content.Server.Commands
|
||||
|
||||
entity.EnsureComponent<MindComponent>();
|
||||
entity.EnsureComponent<PlayerInputMoverComponent>();
|
||||
entity.EnsureComponent<SharedSpeechComponent>();
|
||||
entity.EnsureComponent<SharedEmotingComponent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Mobs.Speech;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
{
|
||||
internal interface IAccentComponent
|
||||
{
|
||||
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class SharedEmotingComponent : Component, IActionBlocker
|
||||
{
|
||||
private bool _enabled = true;
|
||||
public override string Name => "Emoting";
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
if (_enabled == value) return;
|
||||
_enabled = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanEmote() => Enabled;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, x => x.Enabled, "enabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
{
|
||||
/// <summary>
|
||||
/// Component required for entities to be able to speak.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class SharedSpeechComponent : Component, IActionBlocker
|
||||
{
|
||||
private bool _enabled = true;
|
||||
public override string Name => "Speech";
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
if (_enabled == value) return;
|
||||
_enabled = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanSpeak() => Enabled;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, x => x.Enabled, "enabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Content.Shared.GameObjects.Components.Mobs.Speech;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -62,6 +63,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
|
||||
public static bool CanSpeak(IEntity entity)
|
||||
{
|
||||
if (!entity.HasComponent<SharedSpeechComponent>())
|
||||
return false;
|
||||
|
||||
var canSpeak = true;
|
||||
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
@@ -98,6 +102,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
|
||||
public static bool CanEmote(IEntity entity)
|
||||
{
|
||||
if (!entity.HasComponent<SharedEmotingComponent>())
|
||||
return false;
|
||||
|
||||
var canEmote = true;
|
||||
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
|
||||
@@ -210,6 +210,8 @@
|
||||
meat: FoodMeat
|
||||
- type: Recyclable
|
||||
safe: false
|
||||
- type: Speech
|
||||
- type: Emoting
|
||||
|
||||
- type: entity
|
||||
save: false
|
||||
|
||||
Reference in New Issue
Block a user