From 2fa46e0b3eebcb5872d2996f8662d9f0d3e1775f Mon Sep 17 00:00:00 2001 From: ThereDrD <88589686+ThereDrD0@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:54:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=95=D1=89=D0=B5=20=D0=BE=D0=B4=D0=BD=D0=B8?= =?UTF-8?q?=20=D1=84=D0=B8=D0=BA=D1=81=D1=8B=20=D0=B0=D0=BF=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B8=D0=BC=D0=B0=20(#671)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wizard appearance system refactor * new helper method for drop anything from inventory * fix wizard and nukie inventory saving * remove wieldable from laser rifle * replace comment with todo --- Content.Server/Antag/AntagSelectionSystem.cs | 7 ++++ .../Components/AntagSelectionComponent.cs | 4 +- .../GameTicking/Rules/NukeopsRuleSystem.cs | 2 +- .../Inventory/ServerInventorySystem.cs | 22 ++++++++++ .../Appearance/WizardAppearanceSystem.cs | 42 ++++++++++++++++--- .../_White/Wizard/WizardRuleSystem.cs | 27 +++++++++++- .../Weapons/Guns/Battery/battery_guns.yml | 2 +- Resources/Prototypes/GameRules/roundstart.yml | 8 ++-- 8 files changed, 101 insertions(+), 13 deletions(-) diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 8f7006ff7b..5bbfff582e 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -26,6 +26,7 @@ using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Random; using Content.Server._Miracle.GulagSystem; +using Content.Server.Inventory; using Robust.Shared.Utility; namespace Content.Server.Antag; @@ -43,6 +44,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem diff --git a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs index 57eb6366a6..b7af4cbb59 100644 --- a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs @@ -449,7 +449,6 @@ public sealed class NukeopsRuleSystem : GameRuleSystem if (nukeops.RoundEndBehavior == RoundEndBehavior.Nothing || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor) return; - // If there are any nuclear bombs that are active, immediately return. We're not over yet. foreach (var nuke in EntityQuery()) { @@ -519,6 +518,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem var profile = args.Session != null ? _prefs.GetPreferences(args.Session.UserId).SelectedCharacter as HumanoidCharacterProfile : HumanoidCharacterProfile.RandomWithSpecies(); + if (!_prototypeManager.TryIndex(profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies, out SpeciesPrototype? species)) { species = _prototypeManager.Index(SharedHumanoidAppearanceSystem.DefaultSpecies); diff --git a/Content.Server/Inventory/ServerInventorySystem.cs b/Content.Server/Inventory/ServerInventorySystem.cs index ab0f1f70e0..86b2a57231 100644 --- a/Content.Server/Inventory/ServerInventorySystem.cs +++ b/Content.Server/Inventory/ServerInventorySystem.cs @@ -1,10 +1,13 @@ using Content.Shared.Explosion; +using Content.Shared.Hands.EntitySystems; using Content.Shared.Inventory; namespace Content.Server.Inventory { public sealed class ServerInventorySystem : InventorySystem { + [Dependency] private readonly SharedHandsSystem _hands = default!; // WD + public override void Initialize() { base.Initialize(); @@ -43,5 +46,24 @@ namespace Content.Server.Inventory } // WD EDIT END } + + + // WD edit start - new helper method for drop anything from inventory. + public void DropAnything(EntityUid uid) + { + if (TryGetContainerSlotEnumerator(uid, out var enumerator)) + { + while (enumerator.MoveNext(out var slot)) + { + TryUnequip(uid, slot.ID, true, true); + } + } + + foreach (var held in _hands.EnumerateHeld(uid)) + { + _hands.TryDrop(uid, held); + } + } + // WD edit end } } diff --git a/Content.Server/_White/Wizard/Appearance/WizardAppearanceSystem.cs b/Content.Server/_White/Wizard/Appearance/WizardAppearanceSystem.cs index 8991f03e47..69d8b2a720 100644 --- a/Content.Server/_White/Wizard/Appearance/WizardAppearanceSystem.cs +++ b/Content.Server/_White/Wizard/Appearance/WizardAppearanceSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Humanoid; using Content.Shared._White.Wizard.Appearance; using Content.Shared.Dataset; +using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -22,8 +23,41 @@ public sealed class WizardAppearanceSystem : EntitySystem private void OnInit(EntityUid wizard, WizardAppearanceComponent appearance, ComponentInit _) { - var random = IoCManager.Resolve(); - var profile = HumanoidCharacterProfile.RandomWithSpecies().WithAge(random.Next(appearance.MinAge, appearance.MaxAge)); + Wizardify(wizard, appearance); + } + + public void Wizardify(EntityUid wizard, WizardAppearanceComponent appearance) + { + var profile = GetWizardProfile(appearance); + + _humanoid.LoadProfile(wizard, profile); + + _metaData.SetEntityName(wizard, GetRandom(appearance.Name, string.Empty)); + } + + public string GetWizardName(WizardAppearanceComponent appearance) + { + return GetRandom(appearance.Name, string.Empty); + } + + public EntityUid GetWizardEntity(WizardAppearanceComponent appearance) + { + var profile = GetWizardProfile(appearance); + + if (!_prototypeManager.TryIndex(profile.Species, out SpeciesPrototype? species)) + return EntityUid.Invalid; + + var entity = Spawn(species.Prototype); + + _humanoid.LoadProfile(entity, profile); + _metaData.SetEntityName(entity, GetWizardName(appearance)); + + return entity; + } + + public HumanoidCharacterProfile GetWizardProfile(WizardAppearanceComponent appearance) + { + var profile = HumanoidCharacterProfile.RandomWithSpecies().WithAge(_random.Next(appearance.MinAge, appearance.MaxAge)); var color = Color.FromHex(GetRandom(appearance.Color, "#B5B8B1")); var hair = GetRandom(appearance.Hair, "HumanHairAfricanPigtails"); @@ -37,9 +71,7 @@ public sealed class WizardAppearanceSystem : EntitySystem .Appearance.WithHairColor(color)) .Appearance.WithFacialHairColor(color)); - _humanoid.LoadProfile(wizard, profile); - - _metaData.SetEntityName(wizard, GetRandom(appearance.Name, string.Empty)); + return profile; } private string GetRandom(string list, string ifNull) diff --git a/Content.Server/_White/Wizard/WizardRuleSystem.cs b/Content.Server/_White/Wizard/WizardRuleSystem.cs index a03932e6e1..7158f6e298 100644 --- a/Content.Server/_White/Wizard/WizardRuleSystem.cs +++ b/Content.Server/_White/Wizard/WizardRuleSystem.cs @@ -4,9 +4,10 @@ using Content.Server.Mind; using Content.Server.RoundEnd; using Content.Shared.Mobs; using System.Linq; +using Content.Server._White.Wizard.Appearance; using Content.Server.Objectives; using Content.Server.StationEvents.Components; -using Content.Shared._White.Mood; +using Content.Shared._White.Wizard.Appearance; using Content.Shared.Mind; using Content.Shared.Objectives.Components; @@ -20,12 +21,16 @@ public sealed class WizardRuleSystem : GameRuleSystem [Dependency] private readonly MindSystem _mind = default!; [Dependency] private readonly RoundEndSystem _roundEndSystem = default!; [Dependency] private readonly ObjectivesSystem _objectives = default!; + [Dependency] private readonly WizardAppearanceSystem _wizardAppearance = default!; + + private const string WizardObjective = "WizardSurviveObjective"; /// public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnAntagSelectEntity); SubscribeLocalEvent(AfterEntitySelected); SubscribeLocalEvent(OnMobStateChanged); @@ -46,7 +51,7 @@ public sealed class WizardRuleSystem : GameRuleSystem private void GiveObjectives(EntityUid mindId, MindComponent mind, WizardRuleComponent wizardRule) { - _mind.TryAddObjective(mindId, mind, "WizardSurviveObjective"); + _mind.TryAddObjective(mindId, mind, WizardObjective); var difficulty = 0f; for (var pick = 0; pick < 6 && 8 > difficulty; pick++) @@ -66,6 +71,24 @@ public sealed class WizardRuleSystem : GameRuleSystem MakeWizard(args.EntityUid, ent); } + private void OnAntagSelectEntity(Entity ent, ref AntagSelectEntityEvent args) + { + if (args.Handled) + return; + + if (!args.Entity.HasValue) + return; + + var wizardAppearanceComponent = EnsureComp(args.Entity.Value); + + // TODO: Пофиксить, что игрун сохраняет свой прототип вместе с расой и остаются абилки расы + + var entity = _wizardAppearance.GetWizardEntity(wizardAppearanceComponent); + + if (entity != EntityUid.Invalid) + args.Entity = entity; + } + private void MakeWizard(EntityUid wizard, WizardRuleComponent component, bool giveObjectives = true) { if (!_mind.TryGetMind(wizard, out var mindId, out var mind)) diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml index 70284b1f49..81d1497249 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml @@ -230,7 +230,7 @@ - type: entity name: laser rifle - parent: [BaseWeaponBattery, BaseGunWieldable] + parent: BaseWeaponBattery id: WeaponLaserCarbine description: Favoured by Nanotrasen Security for being cheap and easy to use. components: diff --git a/Resources/Prototypes/GameRules/roundstart.yml b/Resources/Prototypes/GameRules/roundstart.yml index 107ec68204..f9a6b3ef66 100644 --- a/Resources/Prototypes/GameRules/roundstart.yml +++ b/Resources/Prototypes/GameRules/roundstart.yml @@ -86,6 +86,7 @@ playerRatio: 10 startingGear: SyndicateCommanderGearFull moodEffect: TraitorFocused # WD + dropInventory: true # WD components: - type: NukeOperative - type: RandomMetadata @@ -262,7 +263,7 @@ definitions: - prefRoles: [ Cultist ] max: 3 - moodEffect: CultFocused + moodEffect: CultFocused # WD briefing: text: cult-role-greeting color: Red @@ -291,7 +292,8 @@ - type: AntagSelection definitions: - prefRoles: [ WizardRole ] - moodEffect: WizardFocused + moodEffect: WizardFocused # WD + dropInventory: true # WD briefing: text: wizard-welcome color: Aqua @@ -322,7 +324,7 @@ max: 8 playerRatio: 10 lateJoinAdditional: true - moodEffect: TraitorFocused + moodEffect: TraitorFocused # WD briefing: text: changeling-role-greeting color: Red