Еще одни фиксы апстрима (#671)
* 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
This commit is contained in:
@@ -26,6 +26,7 @@ using Robust.Shared.Map;
|
|||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Content.Server._Miracle.GulagSystem;
|
using Content.Server._Miracle.GulagSystem;
|
||||||
|
using Content.Server.Inventory;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.Antag;
|
namespace Content.Server.Antag;
|
||||||
@@ -43,6 +44,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
|
|||||||
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
|
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
|
||||||
[Dependency] private readonly TransformSystem _transform = default!;
|
[Dependency] private readonly TransformSystem _transform = default!;
|
||||||
[Dependency] private readonly GulagSystem _gulag = default!; // WD
|
[Dependency] private readonly GulagSystem _gulag = default!; // WD
|
||||||
|
[Dependency] private readonly ServerInventorySystem _inventory = default!; // WD
|
||||||
|
|
||||||
// arbitrary random number to give late joining some mild interest.
|
// arbitrary random number to give late joining some mild interest.
|
||||||
public const float LateJoinRandomChance = 0.5f;
|
public const float LateJoinRandomChance = 0.5f;
|
||||||
@@ -274,6 +276,11 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
|
|||||||
if (antagEnt is not { } player)
|
if (antagEnt is not { } player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// WD edit start - preventing wizard with previous entity`s gear
|
||||||
|
if (def.DropInventory)
|
||||||
|
_inventory.DropAnything(player);
|
||||||
|
// WD edit end
|
||||||
|
|
||||||
var getPosEv = new AntagSelectLocationEvent(session, ent);
|
var getPosEv = new AntagSelectLocationEvent(session, ent);
|
||||||
RaiseLocalEvent(ent, ref getPosEv, true);
|
RaiseLocalEvent(ent, ref getPosEv, true);
|
||||||
if (getPosEv.Handled)
|
if (getPosEv.Handled)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Content.Server.Administration.Systems;
|
|||||||
using Content.Server.Destructible.Thresholds;
|
using Content.Server.Destructible.Thresholds;
|
||||||
using Content.Shared.Antag;
|
using Content.Shared.Antag;
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Content.Shared.Storage;
|
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
@@ -164,6 +163,9 @@ public partial struct AntagSelectionDefinition()
|
|||||||
|
|
||||||
[DataField]
|
[DataField]
|
||||||
public string? MoodEffect; // WD
|
public string? MoodEffect; // WD
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool DropInventory; // WD
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -449,7 +449,6 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
|
|||||||
if (nukeops.RoundEndBehavior == RoundEndBehavior.Nothing || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
|
if (nukeops.RoundEndBehavior == RoundEndBehavior.Nothing || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
// If there are any nuclear bombs that are active, immediately return. We're not over yet.
|
// If there are any nuclear bombs that are active, immediately return. We're not over yet.
|
||||||
foreach (var nuke in EntityQuery<NukeComponent>())
|
foreach (var nuke in EntityQuery<NukeComponent>())
|
||||||
{
|
{
|
||||||
@@ -519,6 +518,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
|
|||||||
var profile = args.Session != null
|
var profile = args.Session != null
|
||||||
? _prefs.GetPreferences(args.Session.UserId).SelectedCharacter as HumanoidCharacterProfile
|
? _prefs.GetPreferences(args.Session.UserId).SelectedCharacter as HumanoidCharacterProfile
|
||||||
: HumanoidCharacterProfile.RandomWithSpecies();
|
: HumanoidCharacterProfile.RandomWithSpecies();
|
||||||
|
|
||||||
if (!_prototypeManager.TryIndex(profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies, out SpeciesPrototype? species))
|
if (!_prototypeManager.TryIndex(profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies, out SpeciesPrototype? species))
|
||||||
{
|
{
|
||||||
species = _prototypeManager.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies);
|
species = _prototypeManager.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies);
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
using Content.Shared.Explosion;
|
using Content.Shared.Explosion;
|
||||||
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
|
|
||||||
namespace Content.Server.Inventory
|
namespace Content.Server.Inventory
|
||||||
{
|
{
|
||||||
public sealed class ServerInventorySystem : InventorySystem
|
public sealed class ServerInventorySystem : InventorySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedHandsSystem _hands = default!; // WD
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -43,5 +46,24 @@ namespace Content.Server.Inventory
|
|||||||
}
|
}
|
||||||
// WD EDIT END
|
// 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.Humanoid;
|
using Content.Server.Humanoid;
|
||||||
using Content.Shared._White.Wizard.Appearance;
|
using Content.Shared._White.Wizard.Appearance;
|
||||||
using Content.Shared.Dataset;
|
using Content.Shared.Dataset;
|
||||||
|
using Content.Shared.Humanoid.Prototypes;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
@@ -22,8 +23,41 @@ public sealed class WizardAppearanceSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnInit(EntityUid wizard, WizardAppearanceComponent appearance, ComponentInit _)
|
private void OnInit(EntityUid wizard, WizardAppearanceComponent appearance, ComponentInit _)
|
||||||
{
|
{
|
||||||
var random = IoCManager.Resolve<IRobustRandom>();
|
Wizardify(wizard, appearance);
|
||||||
var profile = HumanoidCharacterProfile.RandomWithSpecies().WithAge(random.Next(appearance.MinAge, appearance.MaxAge));
|
}
|
||||||
|
|
||||||
|
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 color = Color.FromHex(GetRandom(appearance.Color, "#B5B8B1"));
|
||||||
var hair = GetRandom(appearance.Hair, "HumanHairAfricanPigtails");
|
var hair = GetRandom(appearance.Hair, "HumanHairAfricanPigtails");
|
||||||
@@ -37,9 +71,7 @@ public sealed class WizardAppearanceSystem : EntitySystem
|
|||||||
.Appearance.WithHairColor(color))
|
.Appearance.WithHairColor(color))
|
||||||
.Appearance.WithFacialHairColor(color));
|
.Appearance.WithFacialHairColor(color));
|
||||||
|
|
||||||
_humanoid.LoadProfile(wizard, profile);
|
return profile;
|
||||||
|
|
||||||
_metaData.SetEntityName(wizard, GetRandom(appearance.Name, string.Empty));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetRandom(string list, string ifNull)
|
private string GetRandom(string list, string ifNull)
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ using Content.Server.Mind;
|
|||||||
using Content.Server.RoundEnd;
|
using Content.Server.RoundEnd;
|
||||||
using Content.Shared.Mobs;
|
using Content.Shared.Mobs;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server._White.Wizard.Appearance;
|
||||||
using Content.Server.Objectives;
|
using Content.Server.Objectives;
|
||||||
using Content.Server.StationEvents.Components;
|
using Content.Server.StationEvents.Components;
|
||||||
using Content.Shared._White.Mood;
|
using Content.Shared._White.Wizard.Appearance;
|
||||||
using Content.Shared.Mind;
|
using Content.Shared.Mind;
|
||||||
using Content.Shared.Objectives.Components;
|
using Content.Shared.Objectives.Components;
|
||||||
|
|
||||||
@@ -20,12 +21,16 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
|||||||
[Dependency] private readonly MindSystem _mind = default!;
|
[Dependency] private readonly MindSystem _mind = default!;
|
||||||
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
||||||
[Dependency] private readonly ObjectivesSystem _objectives = default!;
|
[Dependency] private readonly ObjectivesSystem _objectives = default!;
|
||||||
|
[Dependency] private readonly WizardAppearanceSystem _wizardAppearance = default!;
|
||||||
|
|
||||||
|
private const string WizardObjective = "WizardSurviveObjective";
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<WizardRuleComponent, AntagSelectEntityEvent>(OnAntagSelectEntity);
|
||||||
SubscribeLocalEvent<WizardRuleComponent, AfterAntagEntitySelectedEvent>(AfterEntitySelected);
|
SubscribeLocalEvent<WizardRuleComponent, AfterAntagEntitySelectedEvent>(AfterEntitySelected);
|
||||||
|
|
||||||
SubscribeLocalEvent<WizardComponent, MobStateChangedEvent>(OnMobStateChanged);
|
SubscribeLocalEvent<WizardComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||||
@@ -46,7 +51,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
|||||||
|
|
||||||
private void GiveObjectives(EntityUid mindId, MindComponent mind, WizardRuleComponent wizardRule)
|
private void GiveObjectives(EntityUid mindId, MindComponent mind, WizardRuleComponent wizardRule)
|
||||||
{
|
{
|
||||||
_mind.TryAddObjective(mindId, mind, "WizardSurviveObjective");
|
_mind.TryAddObjective(mindId, mind, WizardObjective);
|
||||||
|
|
||||||
var difficulty = 0f;
|
var difficulty = 0f;
|
||||||
for (var pick = 0; pick < 6 && 8 > difficulty; pick++)
|
for (var pick = 0; pick < 6 && 8 > difficulty; pick++)
|
||||||
@@ -66,6 +71,24 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
|||||||
MakeWizard(args.EntityUid, ent);
|
MakeWizard(args.EntityUid, ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnAntagSelectEntity(Entity<WizardRuleComponent> ent, ref AntagSelectEntityEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!args.Entity.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var wizardAppearanceComponent = EnsureComp<WizardAppearanceComponent>(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)
|
private void MakeWizard(EntityUid wizard, WizardRuleComponent component, bool giveObjectives = true)
|
||||||
{
|
{
|
||||||
if (!_mind.TryGetMind(wizard, out var mindId, out var mind))
|
if (!_mind.TryGetMind(wizard, out var mindId, out var mind))
|
||||||
|
|||||||
@@ -230,7 +230,7 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: laser rifle
|
name: laser rifle
|
||||||
parent: [BaseWeaponBattery, BaseGunWieldable]
|
parent: BaseWeaponBattery
|
||||||
id: WeaponLaserCarbine
|
id: WeaponLaserCarbine
|
||||||
description: Favoured by Nanotrasen Security for being cheap and easy to use.
|
description: Favoured by Nanotrasen Security for being cheap and easy to use.
|
||||||
components:
|
components:
|
||||||
|
|||||||
@@ -86,6 +86,7 @@
|
|||||||
playerRatio: 10
|
playerRatio: 10
|
||||||
startingGear: SyndicateCommanderGearFull
|
startingGear: SyndicateCommanderGearFull
|
||||||
moodEffect: TraitorFocused # WD
|
moodEffect: TraitorFocused # WD
|
||||||
|
dropInventory: true # WD
|
||||||
components:
|
components:
|
||||||
- type: NukeOperative
|
- type: NukeOperative
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
@@ -262,7 +263,7 @@
|
|||||||
definitions:
|
definitions:
|
||||||
- prefRoles: [ Cultist ]
|
- prefRoles: [ Cultist ]
|
||||||
max: 3
|
max: 3
|
||||||
moodEffect: CultFocused
|
moodEffect: CultFocused # WD
|
||||||
briefing:
|
briefing:
|
||||||
text: cult-role-greeting
|
text: cult-role-greeting
|
||||||
color: Red
|
color: Red
|
||||||
@@ -291,7 +292,8 @@
|
|||||||
- type: AntagSelection
|
- type: AntagSelection
|
||||||
definitions:
|
definitions:
|
||||||
- prefRoles: [ WizardRole ]
|
- prefRoles: [ WizardRole ]
|
||||||
moodEffect: WizardFocused
|
moodEffect: WizardFocused # WD
|
||||||
|
dropInventory: true # WD
|
||||||
briefing:
|
briefing:
|
||||||
text: wizard-welcome
|
text: wizard-welcome
|
||||||
color: Aqua
|
color: Aqua
|
||||||
@@ -322,7 +324,7 @@
|
|||||||
max: 8
|
max: 8
|
||||||
playerRatio: 10
|
playerRatio: 10
|
||||||
lateJoinAdditional: true
|
lateJoinAdditional: true
|
||||||
moodEffect: TraitorFocused
|
moodEffect: TraitorFocused # WD
|
||||||
briefing:
|
briefing:
|
||||||
text: changeling-role-greeting
|
text: changeling-role-greeting
|
||||||
color: Red
|
color: Red
|
||||||
|
|||||||
Reference in New Issue
Block a user