Merge remote-tracking branch 'upstream/master' into Suka
This commit is contained in:
@@ -16,7 +16,7 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly PvsOverrideSystem _pvsOverrideSystem = default!;
|
||||
|
||||
private readonly List<JukeboxComponent> _playingJukeboxes = new() { };
|
||||
private readonly List<WhiteJukeboxComponent> _playingJukeboxes = new() { };
|
||||
|
||||
private const float UpdateTimerDefaultTime = 1f;
|
||||
private float _updateTimer;
|
||||
@@ -25,16 +25,16 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeNetworkEvent<JukeboxRequestSongPlay>(OnSongRequestPlay);
|
||||
SubscribeLocalEvent<JukeboxComponent, InteractUsingEvent>(OnInteract);
|
||||
SubscribeLocalEvent<JukeboxComponent, JukeboxStopRequest>(OnRequestStop);
|
||||
SubscribeLocalEvent<JukeboxComponent, JukeboxRepeatToggled>(OnRepeatToggled);
|
||||
SubscribeLocalEvent<JukeboxComponent, JukeboxEjectRequest>(OnEjectRequest);
|
||||
SubscribeLocalEvent<JukeboxComponent, GetVerbsEvent<Verb>>(OnGetVerb);
|
||||
SubscribeLocalEvent<JukeboxComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<WhiteJukeboxComponent, InteractUsingEvent>(OnInteract);
|
||||
SubscribeLocalEvent<WhiteJukeboxComponent, JukeboxStopRequest>(OnRequestStop);
|
||||
SubscribeLocalEvent<WhiteJukeboxComponent, JukeboxRepeatToggled>(OnRepeatToggled);
|
||||
SubscribeLocalEvent<WhiteJukeboxComponent, JukeboxEjectRequest>(OnEjectRequest);
|
||||
SubscribeLocalEvent<WhiteJukeboxComponent, GetVerbsEvent<Verb>>(OnGetVerb);
|
||||
SubscribeLocalEvent<WhiteJukeboxComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, JukeboxComponent component, ComponentInit args)
|
||||
private void OnInit(EntityUid uid, WhiteJukeboxComponent component, ComponentInit args)
|
||||
{
|
||||
_pvsOverrideSystem.AddGlobalOverride(uid);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
_playingJukeboxes.Clear();
|
||||
}
|
||||
|
||||
private void OnEjectRequest(EntityUid uid, JukeboxComponent component, JukeboxEjectRequest args)
|
||||
private void OnEjectRequest(EntityUid uid, WhiteJukeboxComponent component, JukeboxEjectRequest args)
|
||||
{
|
||||
if (component.PlayingSongData != null) return;
|
||||
|
||||
@@ -56,7 +56,7 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetVerb(EntityUid uid, JukeboxComponent jukeboxComponent, GetVerbsEvent<Verb> ev)
|
||||
private void OnGetVerb(EntityUid uid, WhiteJukeboxComponent jukeboxComponent, GetVerbsEvent<Verb> ev)
|
||||
{
|
||||
if (ev.Hands == null) return;
|
||||
if (jukeboxComponent.PlayingSongData != null) return;
|
||||
@@ -82,19 +82,19 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
ev.Verbs.Add(removeTapeVerb);
|
||||
}
|
||||
|
||||
private void OnRepeatToggled(EntityUid uid, JukeboxComponent component, JukeboxRepeatToggled args)
|
||||
private void OnRepeatToggled(EntityUid uid, WhiteJukeboxComponent component, JukeboxRepeatToggled args)
|
||||
{
|
||||
component.Playing = args.NewState;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnRequestStop(EntityUid uid, JukeboxComponent component, JukeboxStopRequest args)
|
||||
private void OnRequestStop(EntityUid uid, WhiteJukeboxComponent component, JukeboxStopRequest args)
|
||||
{
|
||||
component.PlayingSongData = null;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnInteract(EntityUid uid, JukeboxComponent component, InteractUsingEvent args)
|
||||
private void OnInteract(EntityUid uid, WhiteJukeboxComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (component.PlayingSongData != null) return;
|
||||
|
||||
@@ -122,7 +122,7 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
private void OnSongRequestPlay(JukeboxRequestSongPlay msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var entity = GetEntity(msg.Jukebox!.Value);
|
||||
var jukebox = Comp<JukeboxComponent>(entity);
|
||||
var jukebox = Comp<WhiteJukeboxComponent>(entity);
|
||||
jukebox.Playing = true;
|
||||
|
||||
var songData = new PlayingSongData
|
||||
@@ -186,4 +186,4 @@ public sealed class JukeboxSystem : EntitySystem
|
||||
|
||||
_updateTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Server._White.Loadout;
|
||||
|
||||
[Prototype("loadout")]
|
||||
public sealed class LoadoutItemPrototype : IPrototype
|
||||
{
|
||||
[IdDataFieldAttribute] public string ID { get; } = default!;
|
||||
|
||||
[DataField("entity", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string EntityId { get; } = default!;
|
||||
|
||||
// WD-Sponsors-Start
|
||||
[DataField("sponsorOnly")]
|
||||
public bool SponsorOnly = false;
|
||||
// WD-Sponsors-End
|
||||
|
||||
[DataField("whitelistJobs", customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
|
||||
public List<string>? WhitelistJobs { get; }
|
||||
|
||||
[DataField("blacklistJobs", customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
|
||||
public List<string>? BlacklistJobs { get; }
|
||||
|
||||
[DataField("speciesRestriction")]
|
||||
public List<string>? SpeciesRestrictions { get; }
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Content.Server._White.Sponsors;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Shared._White.Loadout;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -32,7 +33,7 @@ public sealed class LoadoutSystem : EntitySystem
|
||||
foreach (var loadoutId in sponsor.AllowedMarkings)
|
||||
{
|
||||
// NOTE: Now is easy to not extract method because event give all info we need
|
||||
if (_prototypeManager.TryIndex<LoadoutItemPrototype>(loadoutId, out var loadout))
|
||||
if (_prototypeManager.TryIndex<SponsorLoadoutItemPrototype>(loadoutId, out var loadout))
|
||||
{
|
||||
var isSponsorOnly = loadout.SponsorOnly &&
|
||||
!sponsor.AllowedMarkings.Contains(loadoutId);
|
||||
|
||||
137
Content.Server/_White/Wizard/Mirror/WizardMirrorSystem.cs
Normal file
137
Content.Server/_White/Wizard/Mirror/WizardMirrorSystem.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.IdentityManagement;
|
||||
using Content.Shared._White.Wizard.Mirror;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Humanoid.Markings;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.UserInterface;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.Wizard.Mirror;
|
||||
|
||||
public sealed class WizardMirrorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly IdentitySystem _identity = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<WizardMirrorComponent, ActivatableUIOpenAttemptEvent>(OnOpenUIAttempt);
|
||||
|
||||
Subs.BuiEvents<WizardMirrorComponent>(WizardMirrorUiKey.Key,
|
||||
subs =>
|
||||
{
|
||||
subs.Event<BoundUIClosedEvent>(OnUIClosed);
|
||||
subs.Event<WizardMirrorSave>(OnSave);
|
||||
});
|
||||
|
||||
SubscribeLocalEvent<WizardMirrorComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<WizardMirrorComponent, AfterInteractEvent>(OnMagicMirrorInteract);
|
||||
|
||||
SubscribeLocalEvent<WizardMirrorComponent, BoundUserInterfaceCheckRangeEvent>(OnRangeCheck);
|
||||
}
|
||||
|
||||
private void OnOpenUIAttempt(EntityUid uid, WizardMirrorComponent mirror, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (!HasComp<HumanoidAppearanceComponent>(args.User))
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private static void OnUIClosed(Entity<WizardMirrorComponent> ent, ref BoundUIClosedEvent args)
|
||||
{
|
||||
ent.Comp.Target = null;
|
||||
}
|
||||
|
||||
private void OnSave(EntityUid uid, WizardMirrorComponent component, WizardMirrorSave args)
|
||||
{
|
||||
if (!TryComp(component.Target, out HumanoidAppearanceComponent? humanoid) || !string.IsNullOrEmpty(humanoid.Initial))
|
||||
return;
|
||||
|
||||
_humanoid.LoadProfile(component.Target.Value, args.Profile, humanoid);
|
||||
_metaData.SetEntityName(component.Target.Value, args.Profile.Name);
|
||||
_identity.QueueIdentityUpdate(component.Target.Value);
|
||||
}
|
||||
|
||||
private void OnInteractHand(EntityUid uid, WizardMirrorComponent component, ref InteractHandEvent args)
|
||||
{
|
||||
UpdateInterface(uid, args.User, component);
|
||||
}
|
||||
|
||||
private void OnMagicMirrorInteract(EntityUid uid, WizardMirrorComponent component, ref AfterInteractEvent args)
|
||||
{
|
||||
if (!args.CanReach || args.Target == null)
|
||||
return;
|
||||
|
||||
if (!TryComp<ActorComponent>(args.User, out var actor))
|
||||
return;
|
||||
|
||||
if (!_uiSystem.TryOpen(uid, WizardMirrorUiKey.Key, actor.PlayerSession))
|
||||
return;
|
||||
|
||||
UpdateInterface(uid, args.Target.Value, component);
|
||||
}
|
||||
|
||||
private void OnRangeCheck(EntityUid uid, WizardMirrorComponent component, ref BoundUserInterfaceCheckRangeEvent args)
|
||||
{
|
||||
component.Target ??= args.Player.AttachedEntity;
|
||||
|
||||
if (!component.Target.HasValue || !_interaction.InRangeUnobstructed(uid, component.Target!.Value, range: 2f, CollisionGroup.None))
|
||||
args.Result = BoundUserInterfaceRangeResult.Fail;
|
||||
}
|
||||
|
||||
private void UpdateInterface(EntityUid mirrorUid, EntityUid targetUid, WizardMirrorComponent component)
|
||||
{
|
||||
if (!TryComp<HumanoidAppearanceComponent>(targetUid, out var humanoid) ||
|
||||
!TryComp<MetaDataComponent>(targetUid, out var meta))
|
||||
return;
|
||||
|
||||
var hair = humanoid.MarkingSet.TryGetCategory(MarkingCategories.Hair, out var hairMarkings)
|
||||
? new List<Marking>(hairMarkings)[0]
|
||||
: null;
|
||||
|
||||
var facialHair = humanoid.MarkingSet.TryGetCategory(MarkingCategories.FacialHair, out var facialHairMarkings)
|
||||
? new List<Marking>(facialHairMarkings)[0]
|
||||
: null;
|
||||
|
||||
var profile = HumanoidCharacterProfile.RandomWithSpecies(humanoid.Species)
|
||||
.WithAge(humanoid.Age)
|
||||
.WithGender(humanoid.Gender)
|
||||
.WithName(meta.EntityName)
|
||||
.WithSex(humanoid.Sex)
|
||||
.WithVoice(humanoid.Voice)
|
||||
.WithBodyType(humanoid.BodyType);
|
||||
|
||||
profile = profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.Appearance.WithSkinColor(humanoid.SkinColor))
|
||||
.Appearance.WithEyeColor(humanoid.EyeColor));
|
||||
|
||||
if (hair != null)
|
||||
{
|
||||
profile = profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.Appearance.WithHairStyleName(hair.MarkingId))
|
||||
.Appearance.WithHairColor(hair.MarkingColors[0]));
|
||||
}
|
||||
|
||||
if (facialHair != null)
|
||||
{
|
||||
profile = profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.Appearance.WithFacialHairStyleName(facialHair.MarkingId))
|
||||
.Appearance.WithFacialHairColor(facialHair.MarkingColors[0]));
|
||||
}
|
||||
|
||||
var state = new WizardMirrorUiState(profile);
|
||||
|
||||
component.Target = targetUid;
|
||||
_uiSystem.TrySetUiState(mirrorUid, WizardMirrorUiKey.Key, state);
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,22 @@ public sealed partial class WizardComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool EndRoundOnDeath;
|
||||
|
||||
[DataField]
|
||||
public int MinAge = 90;
|
||||
|
||||
[DataField]
|
||||
public int MaxAge = 170;
|
||||
|
||||
[DataField]
|
||||
public string Hair = "WizardHair";
|
||||
|
||||
[DataField]
|
||||
public string FacialHair = "WizardFacialHair";
|
||||
|
||||
[DataField]
|
||||
public string Color = "WizardHairColor";
|
||||
|
||||
[DataField]
|
||||
public string Name = "WizardNames";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ using Content.Server.Objectives;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Shared._White.Antag;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.NPC.Components;
|
||||
using Content.Shared.Objectives.Components;
|
||||
@@ -55,6 +56,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
||||
[Dependency] private readonly ObjectivesSystem _objectives = default!;
|
||||
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -137,10 +139,6 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
if (!TryComp<WizardSpawnerComponent>(spawner, out var wizardSpawner))
|
||||
return;
|
||||
|
||||
HumanoidCharacterProfile? profile = null;
|
||||
if (TryComp(args.Spawned, out ActorComponent? actor))
|
||||
profile = _prefs.GetPreferences(actor.PlayerSession.UserId).SelectedCharacter as HumanoidCharacterProfile;
|
||||
|
||||
if (!EntityQuery<WizardRuleComponent>().Any())
|
||||
return;
|
||||
|
||||
@@ -150,7 +148,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
return;
|
||||
}
|
||||
|
||||
SetupWizardEntity(uid, gear, profile, false);
|
||||
SetupWizardEntity(uid, gear, false);
|
||||
}
|
||||
|
||||
private void OnMindAdded(EntityUid uid, WizardComponent component, MindAddedMessage args)
|
||||
@@ -279,25 +277,40 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SetupWizardEntity(
|
||||
private HumanoidCharacterProfile SetupWizardEntity(
|
||||
EntityUid mob,
|
||||
StartingGearPrototype gear,
|
||||
HumanoidCharacterProfile? profile,
|
||||
bool endRoundOnDeath)
|
||||
{
|
||||
EnsureComp<WizardComponent>(mob).EndRoundOnDeath = endRoundOnDeath;
|
||||
EnsureComp<WizardComponent>(mob, out var component);
|
||||
component.EndRoundOnDeath = endRoundOnDeath;
|
||||
EnsureComp<GlobalAntagonistComponent>(mob).AntagonistPrototype = "globalAntagonistWizard";
|
||||
|
||||
profile ??= HumanoidCharacterProfile.RandomWithSpecies();
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var profile = HumanoidCharacterProfile.RandomWithSpecies().WithAge(random.Next(component.MinAge, component.MaxAge));
|
||||
|
||||
var color = Color.FromHex(GetRandom(component.Color, "#B5B8B1"));
|
||||
var hair = GetRandom(component.Hair, "HumanHairAfricanPigtails");
|
||||
var facialHair = GetRandom(component.FacialHair, "HumanFacialHairAbe");
|
||||
profile = profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.Appearance.WithHairStyleName(hair))
|
||||
.Appearance.WithFacialHairStyleName(facialHair))
|
||||
.Appearance.WithHairColor(color))
|
||||
.Appearance.WithFacialHairColor(color));
|
||||
|
||||
_humanoid.LoadProfile(mob, profile);
|
||||
|
||||
_metaData.SetEntityName(mob, profile.Name);
|
||||
_metaData.SetEntityName(mob, GetRandom(component.Name, ""));
|
||||
|
||||
_stationSpawning.EquipStartingGear(mob, gear, profile);
|
||||
_stationSpawning.EquipStartingGear(mob, gear);
|
||||
|
||||
_npcFaction.RemoveFaction(mob, "NanoTrasen", false);
|
||||
_npcFaction.AddFaction(mob, "Wizard");
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
private EntityCoordinates WizardSpawnPoint(WizardRuleComponent component)
|
||||
@@ -342,13 +355,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
//If a session is available, spawn mob and transfer mind into it
|
||||
if (session != null)
|
||||
{
|
||||
var profile =
|
||||
_prefs.GetPreferences(session.UserId).SelectedCharacter as HumanoidCharacterProfile;
|
||||
|
||||
profile ??= HumanoidCharacterProfile.RandomWithSpecies();
|
||||
var name = profile.Name;
|
||||
|
||||
if (!_prototypeManager.TryIndex(profile.Species, out SpeciesPrototype? species))
|
||||
if (!_prototypeManager.TryIndex(SharedHumanoidAppearanceSystem.DefaultSpecies, out SpeciesPrototype? species))
|
||||
{
|
||||
species = _prototypeManager.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies);
|
||||
}
|
||||
@@ -360,7 +367,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
return;
|
||||
}
|
||||
|
||||
SetupWizardEntity(mob, gear, profile, true);
|
||||
var name = SetupWizardEntity(mob, gear, true).Name;
|
||||
|
||||
var newMind = _mind.CreateMind(session.UserId, name);
|
||||
_mind.SetUserId(newMind, session.UserId);
|
||||
@@ -442,10 +449,6 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
return false;
|
||||
}
|
||||
|
||||
HumanoidCharacterProfile? profile = null;
|
||||
if (TryComp(wizard, out ActorComponent? actor))
|
||||
profile = _prefs.GetPreferences(actor.PlayerSession.UserId).SelectedCharacter as HumanoidCharacterProfile;
|
||||
|
||||
if (giveObjectives)
|
||||
{
|
||||
AddRole(mindId, mind, rule);
|
||||
@@ -457,7 +460,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
return false;
|
||||
}
|
||||
|
||||
SetupWizardEntity(wizard, gear, profile, false);
|
||||
SetupWizardEntity(wizard, gear, false);
|
||||
|
||||
var spawnpoint = WizardSpawnPoint(rule);
|
||||
var transform = EnsureComp<TransformComponent>(wizard);
|
||||
@@ -465,4 +468,11 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private string GetRandom(string list, string ifNull)
|
||||
{
|
||||
return _prototypeManager.TryIndex<DatasetPrototype>(list, out var prototype)
|
||||
? _random.Pick(prototype.Values)
|
||||
: ifNull;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user