Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Фигсы барков #864

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Content.Client/ADT/Bark/Systems/HumanoidProfileEditor.Barks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public sealed partial class HumanoidProfileEditor
{
private List<BarkPrototype> _barkList = new();

private void InitializeBarks()
private void InitializeBarks() // У меня случился небольшой затуп. Оно барки в обход кнопки сохраняет, но хотя бы работает ы
{
_barkList = _prototypeManager
.EnumeratePrototypes<BarkPrototype>()
Expand All @@ -20,6 +20,7 @@ private void InitializeBarks()
{
BarkProtoButton.SelectId(args.Id);
SetBarkProto(_barkList[args.Id].ID);
UpdateSaveButton();
};

PitchEdit.OnTextChanged += args =>
Expand All @@ -28,6 +29,7 @@ private void InitializeBarks()
return;

SetBarkPitch(newPitch);
UpdateSaveButton();
};

DelayVariationMinEdit.OnTextChanged += args =>
Expand All @@ -36,6 +38,7 @@ private void InitializeBarks()
return;

SetBarkMinVariation(newVar);
UpdateSaveButton();
};

DelayVariationMaxEdit.OnTextChanged += args =>
Expand All @@ -44,6 +47,7 @@ private void InitializeBarks()
return;

SetBarkMaxVariation(newVar);
UpdateSaveButton();
};

BarkPlayButton.OnPressed += _ => PlayPreviewBark();
Expand All @@ -56,9 +60,9 @@ private void UpdateBarkVoicesControls()

BarkProtoButton.Clear();

PitchEdit.Text = Profile.BarkPitch.ToString();
DelayVariationMinEdit.Text = Profile.BarkLowVar.ToString();
DelayVariationMaxEdit.Text = Profile.BarkHighVar.ToString();
PitchEdit.Text = Profile.Bark.Pitch.ToString();
DelayVariationMinEdit.Text = Profile.Bark.MinVar.ToString();
DelayVariationMaxEdit.Text = Profile.Bark.MaxVar.ToString();

var firstVoiceChoiceId = 1;
for (var i = 0; i < _barkList.Count; i++)
Expand All @@ -72,7 +76,7 @@ private void UpdateBarkVoicesControls()
firstVoiceChoiceId = i;
}

var voiceChoiceId = _barkList.FindIndex(x => x.ID == Profile.BarkProto);
var voiceChoiceId = _barkList.FindIndex(x => x.ID == Profile.Bark.Proto);
if (!BarkProtoButton.TrySelectId(voiceChoiceId) &&
BarkProtoButton.TrySelectId(firstVoiceChoiceId))
{
Expand All @@ -85,6 +89,6 @@ private void PlayPreviewBark()
if (Profile is null)
return;

_entManager.System<SpeechBarksSystem>().PlayDataPrewiew(Profile.BarkProto, Profile.BarkPitch, Profile.BarkLowVar, Profile.BarkHighVar);
_entManager.System<SpeechBarksSystem>().PlayDataPrewiew(Profile.Bark.Proto, Profile.Bark.Pitch, Profile.Bark.MinVar, Profile.Bark.MaxVar);
}
}
4 changes: 2 additions & 2 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<Control HorizontalExpand="True"/>
<OptionButton Name="SpawnPriorityButton" HorizontalAlignment="Right" />
</BoxContainer>
<!-- ADT-Barks-Start -->
<!-- ADT Barks Start -->
<BoxContainer HorizontalExpand="True" Visible="False" Name="BarksContainer">
<Label Text="{Loc 'humanoid-profile-editor-bark-label'}" />
<Control HorizontalExpand="True"/>
Expand All @@ -109,7 +109,7 @@
<LineEdit Name="DelayVariationMinEdit" MinSize="40 0" HorizontalAlignment="Right" Margin="2 0 2 0" />
<LineEdit Name="DelayVariationMaxEdit" MinSize="40 0" HorizontalAlignment="Right" Margin="2 0 2 0" />
</BoxContainer>
<!-- ADT-Barks-End -->
<!-- ADT Barks End -->

<!-- Corvax-TTS-Start -->
<BoxContainer HorizontalExpand="True" Visible="False" Name="TTSContainer">
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ private void SetVoice(string newVoice)
IsDirty = true;
}
// Corvax-TTS-End

// ADT Barks start
private void SetBarkProto(string prototype)
{
Profile = Profile?.WithBarkProto(prototype);
Expand All @@ -1254,17 +1254,18 @@ private void SetBarkPitch(float pitch)

private void SetBarkMinVariation(float variation)
{
Profile = Profile?.WithBarkMinVariation(Math.Clamp(variation, _cfgManager.GetCVar(ADTCCVars.BarksMinDelay), Profile.BarkHighVar));
Profile = Profile?.WithBarkMinVariation(Math.Clamp(variation, _cfgManager.GetCVar(ADTCCVars.BarksMinDelay), Profile.Bark.MaxVar));
ReloadPreview();
SetDirty();
}

private void SetBarkMaxVariation(float variation)
{
Profile = Profile?.WithBarkMaxVariation(Math.Clamp(variation, Profile.BarkLowVar, _cfgManager.GetCVar(ADTCCVars.BarksMaxDelay)));
Profile = Profile?.WithBarkMaxVariation(Math.Clamp(variation, Profile.Bark.MinVar, _cfgManager.GetCVar(ADTCCVars.BarksMaxDelay)));
ReloadPreview();
SetDirty();
}
// ADT Barks end

private void SetSpecies(string newSpecies)
{
Expand Down
18 changes: 8 additions & 10 deletions Content.Server/ADT/Bark/Systems/SpeechBarksSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ public override void Initialize()
}
private void OnMapInit(EntityUid uid, SpeechBarksComponent comp, MapInitEvent args)
{
if (comp.BarkPrototype != null && comp.BarkPrototype != String.Empty)
{
var proto = _proto.Index(comp.BarkPrototype.Value);
comp.Sound = proto.Sound;
}
if (comp.Data.Sound != String.Empty)
return;
comp.Data.Sound = _proto.Index(comp.Data.Proto).Sound;
}

private void OnEntitySpoke(EntityUid uid, SpeechBarksComponent component, EntitySpokeEvent args)
{
if (!_isEnabled)
return;

var ev = new TransformSpeakerBarkEvent(uid, component.Sound, component.BarkPitch);
var ev = new TransformSpeakerBarkEvent(uid, component.Data.Copy());
RaiseLocalEvent(uid, ev);

var message = args.ObfuscatedMessage ?? args.Message;
Expand All @@ -64,10 +62,10 @@ private void OnEntitySpoke(EntityUid uid, SpeechBarksComponent component, Entity
RaiseNetworkEvent(new PlaySpeechBarksEvent(
GetNetEntity(uid),
message,
ev.Sound,
ev.Pitch,
component.BarkLowVar,
component.BarkHighVar,
ev.Data.Sound,
ev.Data.Pitch,
ev.Data.MinVar,
ev.Data.MaxVar,
args.Whisper), mind.Session);
}
}
Expand Down
5 changes: 2 additions & 3 deletions Content.Server/ADT/Bark/Systems/VoiceMaskSystem.Barks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ private void InitializeBarks()

private void OnSpeakerVoiceTransform(EntityUid uid, VoiceMaskComponent component, ref InventoryRelayedEvent<TransformSpeakerBarkEvent> args)
{
args.Args.Pitch = Math.Clamp(component.BarkPitch, _cfg.GetCVar(ADTCCVars.BarksMinPitch), _cfg.GetCVar(ADTCCVars.BarksMaxPitch));

if (!_proto.TryIndex<BarkPrototype>(component.BarkId, out var proto))
return;

args.Args.Sound = proto.Sound;
args.Args.Data.Pitch = Math.Clamp(component.BarkPitch, _cfg.GetCVar(ADTCCVars.BarksMinPitch), _cfg.GetCVar(ADTCCVars.BarksMaxPitch));
args.Args.Data.Sound = proto.Sound;
}

private void OnChangeBark(EntityUid uid, VoiceMaskComponent component, VoiceMaskChangeBarkMessage message)
Expand Down
3 changes: 1 addition & 2 deletions Content.Server/ADT/Bark/Systems/VoiceOverrideSystem.Barks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ private void OnTransformSpeakerBark(Entity<VoiceOverrideComponent> entity, ref T
if (!entity.Comp.Enabled)
return;

args.Sound = entity.Comp.BarkSound ?? args.Sound;
args.Pitch = entity.Comp.BarkPitch ?? args.Pitch;
args.Data = entity.Comp.Bark ?? args.Data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ private void OnAbsorbDoAfter(EntityUid uid, ChangelingComponent component, Absor
{
_store.TryAddCurrency(new Dictionary<string, FixedPoint2> { { "EvolutionPoints", component.AbsorbedChangelingPointsAmount } }, uid, store);
_store.UpdateUserInterface(uid, uid, store);
component.ChangelingsAbsorbed++;
}
}
else // Если это не был генокрад, получаем возможность "сброса"
{
var selfMessage = Loc.GetString("changeling-dna-success", ("target", Identity.Entity(target, EntityManager)));
_popup.PopupEntity(selfMessage, uid, uid, PopupType.Medium);
component.CanRefresh = true;
component.AbsorbedDnaModifier += 1;
component.AbsorbedDnaModifier++;
}
}

Expand Down
17 changes: 4 additions & 13 deletions Content.Server/ADT/Changeling/Systems/ChangelingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Content.Shared.Changeling.Components;
using Content.Shared.Popups;
using Content.Shared.Store;
using Content.Server.Traitor.Uplink;
using Content.Shared.Mobs.Systems;
using Content.Shared.FixedPoint;
using Content.Shared.Humanoid;
Expand All @@ -29,7 +28,6 @@
using Robust.Shared.Player;
using System.Linq;
using Content.Shared.Preferences;
using Content.Server.Humanoid;
using Robust.Shared.Utility;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Store.Components;
Expand All @@ -43,13 +41,12 @@
using Content.Server.Cuffs;
using Robust.Shared.Timing;
using Content.Server.ADT.Hallucinations;
using Content.Shared.Gibbing.Systems;
using Content.Shared.Mobs;
using Content.Server.Stealth;
using Content.Server.ADT.Store;
using Robust.Server.Containers;
using Content.Server.Ghost;
using Content.Shared.ADT.Stealth.Components;
using Content.Shared.Sirena.CollectiveMind;

namespace Content.Server.Changeling.EntitySystems;

Expand All @@ -59,25 +56,20 @@ public sealed partial class ChangelingSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly UplinkSystem _uplink = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PolymorphSystem _polymorph = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly StatusEffectsSystem _status = default!;
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
[Dependency] private readonly StaminaSystem _stamina = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly FlashSystem _flashSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
Expand Down Expand Up @@ -140,9 +132,6 @@ public override void Update(float frameTime)

private void OnStartup(EntityUid uid, ChangelingComponent component, ComponentStartup args)
{
//RemComp<ActivatableUIComponent>(uid); // TODO: Исправить проблему с волосами слаймов
//RemComp<UserInterfaceComponent>(uid);
//RemComp<SlimeHairComponent>(uid);
StealDNA(uid, component);

RemComp<HungerComponent>(uid);
Expand All @@ -156,6 +145,7 @@ private void OnStartup(EntityUid uid, ChangelingComponent component, ComponentSt

private void OnMapInit(EntityUid uid, ChangelingComponent component, MapInitEvent args)
{
EnsureComp<CollectiveMindComponent>(uid);
if (component.GainedActions)
return;
_action.AddAction(uid, ref component.ChangelingEvolutionMenuActionEntity, component.ChangelingEvolutionMenuAction);
Expand Down Expand Up @@ -282,7 +272,7 @@ private void OnRefresh(EntityUid uid, ChangelingComponent component, ChangelingR

component.BoughtActions.Clear();

_store.TrySetCurrency(new Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> { { "EvolutionPoints", 10 } }, uid);
_store.TrySetCurrency(new Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> { { "EvolutionPoints", 10 + (5 * component.ChangelingsAbsorbed) } }, uid);
_store.TryRefreshStoreStock(uid);
component.CanRefresh = false;

Expand Down Expand Up @@ -341,6 +331,7 @@ public void CopyLing(EntityUid from, EntityUid to, ChangelingComponent? comp = n

newLingComponent.AbsorbedDnaModifier = comp.AbsorbedDnaModifier;
newLingComponent.DNAStolen = comp.DNAStolen;
newLingComponent.ChangelingsAbsorbed = comp.ChangelingsAbsorbed;
newLingComponent.LastResortUsed = comp.LastResortUsed;
newLingComponent.CanRefresh = comp.CanRefresh;

Expand Down
14 changes: 6 additions & 8 deletions Content.Server/ADT/TapeRecorder/TapeRecorderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ protected override void ReplayMessagesInSegment(Entity<TapeRecorderComponent> en
if (message.Bark != null)
{
var barkOverride = EnsureComp<SpeechBarksComponent>(ent);
barkOverride.BarkPrototype = message.Bark;
barkOverride.BarkPitch = message.BarkPitch;
barkOverride.Data = message.Bark;
}
if (message.TTS.HasValue)
{
Expand Down Expand Up @@ -97,15 +96,14 @@ private void OnListen(Entity<TapeRecorderComponent> ent, ref ListenEvent args)
//Add a new entry to the tape
var name = nameEv.VoiceName;
var verb = _chat.GetSpeechVerb(args.Source, args.Message);
var barkPitch = 1f;
string? bark = null;

BarkData? bark = null;
ProtoId<TTSVoicePrototype>? tts = null;
if (TryComp<SpeechBarksComponent>(args.Source, out var barksComponent))
{
var barkEv = new TransformSpeakerBarkEvent(args.Source, barksComponent.Sound, barksComponent.BarkPitch);
var barkEv = new TransformSpeakerBarkEvent(args.Source, barksComponent.Data.Copy());
RaiseLocalEvent(args.Source, barkEv);
bark = barkEv.Sound;
barkPitch = barkEv.Pitch;
bark = barkEv.Data;
}
if (TryComp<TTSComponent>(args.Source, out var ttsComp) && ttsComp.VoicePrototypeId != null)
{
Expand All @@ -114,7 +112,7 @@ private void OnListen(Entity<TapeRecorderComponent> ent, ref ListenEvent args)
tts = ttsEv.VoiceId;
}

cassette.Comp.Buffer.Add(new TapeCassetteRecordedMessage(cassette.Comp.CurrentPosition, name, verb, bark, barkPitch, tts, _language.GetCurrentLanguage(args.Source), args.Message));
cassette.Comp.Buffer.Add(new TapeCassetteRecordedMessage(cassette.Comp.CurrentPosition, name, verb, bark, tts, _language.GetCurrentLanguage(args.Source), args.Message));
}

private void OnPrintMessage(Entity<TapeRecorderComponent> ent, ref PrintTapeRecorderMessage args)
Expand Down
13 changes: 5 additions & 8 deletions Content.Server/Database/ServerDbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ private static HumanoidCharacterProfile ConvertProfiles(Profile profile)
traits.ToHashSet(),
loadouts,
// ADT Barks start
profile.BarkProto,
profile.BarkPitch,
profile.LowBarkVar,
profile.HighBarkVar
new BarkData(profile.BarkProto, profile.BarkPitch, profile.LowBarkVar, profile.HighBarkVar)
// ADT Barks end
);
}
Expand Down Expand Up @@ -357,10 +354,10 @@ private static Profile ConvertProfiles(HumanoidCharacterProfile humanoid, int sl
profile.Loadouts.Add(dz);
}
// ADT Barks start
profile.BarkProto = humanoid.BarkProto;
profile.BarkPitch = humanoid.BarkPitch;
profile.LowBarkVar = humanoid.BarkLowVar;
profile.HighBarkVar = humanoid.BarkHighVar;
profile.BarkProto = humanoid.Bark.Proto;
profile.BarkPitch = humanoid.Bark.Pitch;
profile.LowBarkVar = humanoid.Bark.MinVar;
profile.HighBarkVar = humanoid.Bark.MaxVar;
// ADT Barks end

return profile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void SetAppearance(HumanoidAppearanceComponent sourceHumanoid, HumanoidAp
targetHumanoid.CustomBaseLayers = new(sourceHumanoid.CustomBaseLayers);
targetHumanoid.MarkingSet = new(sourceHumanoid.MarkingSet);
SetTTSVoice(targetHumanoid.Owner, sourceHumanoid.Voice, targetHumanoid); // Corvax-TTS
SetBarkData(targetHumanoid.Owner, sourceHumanoid.Bark, targetHumanoid); // ADT Barks

targetHumanoid.Gender = sourceHumanoid.Gender;
if (TryComp<GrammarComponent>(targetHumanoid.Owner, out var grammar))
Expand Down
7 changes: 2 additions & 5 deletions Content.Server/Speech/Components/VoiceOverrideComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.ADT.SpeechBarks;
using Content.Shared.Corvax.TTS;
using Content.Shared.Speech;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -36,11 +37,7 @@ public sealed partial class VoiceOverrideComponent : Component

// ADT start
[DataField]
public string? BarkSound;

[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public float? BarkPitch;
public BarkData? Bark;

[DataField]
public ProtoId<TTSVoicePrototype>? TTS;
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Speech/EntitySystems/VoiceOverrideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<VoiceOverrideComponent, TransformSpeakerNameEvent>(OnTransformSpeakerName);

InitializeTTS(); // ADT TTS
InitializeBarks(); // ADT Barks
}

private void OnTransformSpeakerName(Entity<VoiceOverrideComponent> entity, ref TransformSpeakerNameEvent args)
Expand Down
Loading
Loading