diff --git a/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs b/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs index 63ef73950d..8bcdf41dfe 100644 --- a/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs +++ b/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs @@ -14,7 +14,6 @@ namespace Content.Client.Humanoid; public sealed partial class OrganMarkingPicker : Control { [Dependency] private readonly MarkingManager _marking = default!; - [Dependency] private readonly IPrototypeManager _prototype = default!; [Dependency] private readonly IEntityManager _entity = default!; private readonly SpriteSystem _sprite; diff --git a/Content.Client/Light/EntitySystems/LightBehaviorSystem.cs b/Content.Client/Light/EntitySystems/LightBehaviorSystem.cs index d4eaad3882..b91062b60b 100644 --- a/Content.Client/Light/EntitySystems/LightBehaviorSystem.cs +++ b/Content.Client/Light/EntitySystems/LightBehaviorSystem.cs @@ -1,5 +1,7 @@ +using System.ComponentModel.Design; using System.Linq; using Content.Client.Light.Components; +using Content.Shared.Trigger.Components.Effects; using Robust.Client.GameObjects; using Robust.Client.Animations; using Robust.Shared.Random; @@ -36,6 +38,10 @@ public sealed class LightBehaviorSystem : EntitySystem container.LightBehaviour.UpdatePlaybackValues(container.Animation); _player.Play(uid, container.Animation, container.FullKey); } + else + { + StopLightBehaviour((uid, component), container.LightBehaviour.ID, resetToOriginalSettings: true); + } } private void OnLightStartup(Entity entity, ref ComponentStartup args) @@ -53,7 +59,7 @@ public sealed class LightBehaviorSystem : EntitySystem { if (container.LightBehaviour.Enabled) { - StartLightBehaviour(entity, container.LightBehaviour.ID); + StartLightBehaviour((entity, entity), container.LightBehaviour.ID); } } } @@ -82,12 +88,13 @@ public sealed class LightBehaviorSystem : EntitySystem /// If specified light behaviours are already animating, calling this does nothing. /// Multiple light behaviours can have the same ID. /// - public void StartLightBehaviour(Entity entity, string id = "") + public void StartLightBehaviour(Entity entity, string id = "") { - if (!TryComp(entity, out AnimationPlayerComponent? animation)) - { + if (!Resolve(entity, ref entity.Comp)) + return; + + if (!TryComp(entity, out AnimationPlayerComponent? animation)) return; - } foreach (var container in entity.Comp.Animations) { @@ -95,7 +102,7 @@ public sealed class LightBehaviorSystem : EntitySystem { if (!_player.HasRunningAnimation(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key)) { - CopyLightSettings(entity, container.LightBehaviour.Property); + CopyLightSettings((entity, entity.Comp), container.LightBehaviour.Property); container.LightBehaviour.UpdatePlaybackValues(container.Animation); _player.Play(entity, container.Animation, LightBehaviourComponent.KeyPrefix + container.Key); } @@ -118,11 +125,9 @@ public sealed class LightBehaviorSystem : EntitySystem return; } - var comp = entity.Comp; - var toRemove = new List(); - foreach (var container in comp.Animations) + foreach (var container in entity.Comp.Animations) { if (container.LightBehaviour.ID == id || id == string.Empty) { @@ -140,18 +145,24 @@ public sealed class LightBehaviorSystem : EntitySystem foreach (var container in toRemove) { - comp.Animations.Remove(container); + entity.Comp.Animations.Remove(container); } - if (resetToOriginalSettings && TryComp(entity, out PointLightComponent? light)) + if (resetToOriginalSettings) + ResetToOriginalSettings(entity); + + entity.Comp.OriginalPropertyValues.Clear(); + } + + private void ResetToOriginalSettings(Entity entity) + { + if (!Resolve(entity, ref entity.Comp2)) + return; + + foreach (var (property, value) in entity.Comp1.OriginalPropertyValues) { - foreach (var (property, value) in comp.OriginalPropertyValues) - { - AnimationHelper.SetAnimatableProperty(light, property, value); - } + AnimationHelper.SetAnimatableProperty(entity.Comp2, property, value); } - - comp.OriginalPropertyValues.Clear(); } /// @@ -194,7 +205,7 @@ public sealed class LightBehaviorSystem : EntitySystem if (playImmediately) { - StartLightBehaviour(entity, behaviour.ID); + StartLightBehaviour((entity, entity), behaviour.ID); } } } diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index f0e03ee35d..85f382d78d 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -39,7 +39,6 @@ public sealed partial class LobbyUIController : UIController, IOnStateEntered - /// Applies the highest priority job's clothes to the dummy. - /// - public void GiveDummyJobClothesLoadout(EntityUid dummy, JobPrototype? jobProto, HumanoidCharacterProfile profile) - { - var job = jobProto ?? GetPreferredJob(profile); - GiveDummyJobClothes(dummy, profile, job); - - if (_prototypeManager.HasIndex(LoadoutSystem.GetJobPrototype(job.ID))) - { - var loadout = profile.GetLoadoutOrDefault(LoadoutSystem.GetJobPrototype(job.ID), _playerManager.LocalSession, profile.Species, EntityManager, _prototypeManager); - GiveDummyLoadout(dummy, loadout); - } - } - - /// - /// Gets the highest priority job for the profile. - /// - public JobPrototype GetPreferredJob(HumanoidCharacterProfile profile) - { - var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key; - // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract (what is resharper smoking?) - return _prototypeManager.Index(highPriorityJob.Id ?? SharedGameTicker.FallbackOverflowJob); - } - - public void GiveDummyLoadout(EntityUid uid, RoleLoadout? roleLoadout) - { - if (roleLoadout == null) - return; - - foreach (var group in roleLoadout.SelectedLoadouts.Values) - { - foreach (var loadout in group) - { - if (!_prototypeManager.Resolve(loadout.Prototype, out var loadoutProto)) - continue; - - _spawn.EquipStartingGear(uid, loadoutProto); - } - } - } - - /// - /// Applies the specified job's clothes to the dummy. - /// - public void GiveDummyJobClothes(EntityUid dummy, HumanoidCharacterProfile profile, JobPrototype job) - { - if (!_inventory.TryGetSlots(dummy, out var slots)) - return; - - // Apply loadout - if (profile.Loadouts.TryGetValue(job.ID, out var jobLoadout)) - { - foreach (var loadouts in jobLoadout.SelectedLoadouts.Values) - { - foreach (var loadout in loadouts) - { - if (!_prototypeManager.Resolve(loadout.Prototype, out var loadoutProto)) - continue; - - // TODO: Need some way to apply starting gear to an entity and replace existing stuff coz holy fucking shit dude. - foreach (var slot in slots) - { - // Try startinggear first - if (_prototypeManager.Resolve(loadoutProto.StartingGear, out var loadoutGear)) - { - var itemType = ((IEquipmentLoadout) loadoutGear).GetGear(slot.Name); - - if (_inventory.TryUnequip(dummy, slot.Name, out var unequippedItem, silent: true, force: true, reparent: false)) - { - EntityManager.DeleteEntity(unequippedItem.Value); - } - - if (itemType != string.Empty) - { - var item = EntityManager.SpawnEntity(itemType, MapCoordinates.Nullspace); - _inventory.TryEquip(dummy, item, slot.Name, true, true); - } - } - else - { - var itemType = ((IEquipmentLoadout) loadoutProto).GetGear(slot.Name); - - if (_inventory.TryUnequip(dummy, slot.Name, out var unequippedItem, silent: true, force: true, reparent: false)) - { - EntityManager.DeleteEntity(unequippedItem.Value); - } - - if (itemType != string.Empty) - { - var item = EntityManager.SpawnEntity(itemType, MapCoordinates.Nullspace); - _inventory.TryEquip(dummy, item, slot.Name, true, true); - } - } - } - } - } - } - - if (!_prototypeManager.Resolve(job.StartingGear, out var gear)) - return; - - foreach (var slot in slots) - { - var itemType = ((IEquipmentLoadout) gear).GetGear(slot.Name); - - if (_inventory.TryUnequip(dummy, slot.Name, out var unequippedItem, silent: true, force: true, reparent: false)) - { - EntityManager.DeleteEntity(unequippedItem.Value); - } - - if (itemType != string.Empty) - { - var item = EntityManager.SpawnEntity(itemType, MapCoordinates.Nullspace); - _inventory.TryEquip(dummy, item, slot.Name, true, true); - } - } - } - - /// - /// Loads the profile onto a dummy entity. - /// - public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, JobPrototype? job, bool jobClothes) - { - EntityUid dummyEnt; - - EntProtoId? previewEntity = null; - if (humanoid != null && jobClothes) - { - job ??= GetPreferredJob(humanoid); - - previewEntity = job.JobPreviewEntity ?? (EntProtoId?)job?.JobEntity; - } - - if (previewEntity != null) - { - // Special type like borg or AI, do not spawn a human just spawn the entity. - dummyEnt = EntityManager.SpawnEntity(previewEntity, MapCoordinates.Nullspace); - return dummyEnt; - } - else if (humanoid is not null) - { - var dummy = _prototypeManager.Index(humanoid.Species).DollPrototype; - dummyEnt = EntityManager.SpawnEntity(dummy, MapCoordinates.Nullspace); - _visualBody.ApplyProfileTo(dummyEnt, humanoid); - } - else - { - dummyEnt = EntityManager.SpawnEntity(_prototypeManager.Index(HumanoidCharacterProfile.DefaultSpecies).DollPrototype, MapCoordinates.Nullspace); - } - - if (humanoid != null && jobClothes) - { - DebugTools.Assert(job != null); - - GiveDummyJobClothes(dummyEnt, humanoid, job); - - if (_prototypeManager.HasIndex(LoadoutSystem.GetJobPrototype(job.ID))) - { - var loadout = humanoid.GetLoadoutOrDefault(LoadoutSystem.GetJobPrototype(job.ID), _playerManager.LocalSession, humanoid.Species, EntityManager, _prototypeManager); - GiveDummyLoadout(dummyEnt, loadout); - } - } - - return dummyEnt; - } - - #endregion } diff --git a/Content.Client/Lobby/UI/CharacterPickerButton.xaml b/Content.Client/Lobby/UI/CharacterPickerButton.xaml index 723da433a1..c1c15322c0 100644 --- a/Content.Client/Lobby/UI/CharacterPickerButton.xaml +++ b/Content.Client/Lobby/UI/CharacterPickerButton.xaml @@ -1,15 +1,16 @@ - +