Merge remote-tracking branch 'upstream/master' into ups

This commit is contained in:
Jabak
2024-08-23 02:25:53 +03:00
163 changed files with 2022 additions and 714 deletions

View File

@@ -23,6 +23,7 @@ public sealed class RandomAccentAspect : AspectSystem<RandomAccentAspectComponen
{
base.Started(uid, component, gameRule, args);
var query = EntityQueryEnumerator<MindContainerComponent>();
while (query.MoveNext(out var ent, out _))
{
ApplyRandomAccent(ent);
@@ -48,6 +49,8 @@ public sealed class RandomAccentAspect : AspectSystem<RandomAccentAspectComponen
#region Helpers
// TODO: Move this to prototypes.
private enum AccentType
{
Stuttering,
@@ -56,19 +59,23 @@ public sealed class RandomAccentAspect : AspectSystem<RandomAccentAspectComponen
Scrambled,
Pirate,
Russian,
Anime,
OwO,
Lizard,
Backwards,
Bark,
Anxiety,
Moth
Moth,
French,
Gnome,
}
private void ApplyRandomAccent(EntityUid uid)
{
var allAccents = Enum.GetValues(typeof(AccentType)).Cast<AccentType>().ToList();
var randomIndex = _random.Next(allAccents.Count);
var selectedAccent = allAccents[randomIndex];
ApplyAccent(uid, selectedAccent);
}
@@ -94,15 +101,17 @@ public sealed class RandomAccentAspect : AspectSystem<RandomAccentAspectComponen
case AccentType.Russian:
EntityManager.EnsureComponent<RussianAccentComponent>(uid);
break;
case AccentType.Anime:
case AccentType.OwO:
EntityManager.EnsureComponent<OwOAccentComponent>(uid);
break;
case AccentType.Lizard:
EntityManager.EnsureComponent<LizardAccentComponent>(uid);
break;
/* Not funny
case AccentType.Backwards:
EntityManager.EnsureComponent<BackwardsAccentComponent>(uid);
break;
*/
case AccentType.Bark:
EntityManager.EnsureComponent<BarkAccentComponent>(uid);
break;
@@ -116,6 +125,12 @@ public sealed class RandomAccentAspect : AspectSystem<RandomAccentAspectComponen
case AccentType.Moth:
EntityManager.EnsureComponent<MothAccentComponent>(uid);
break;
case AccentType.French:
EntityManager.EnsureComponent<FrenchAccentComponent>(uid);
break;
case AccentType.Gnome:
EntityManager.EnsureComponent<GnomeAccentComponent>(uid);
break;
}
}

View File

@@ -32,11 +32,10 @@ public sealed class MessagesCartridgeSystem : EntitySystem
SubscribeLocalEvent<MessagesCartridgeComponent, CartridgeActivatedEvent>(OnCartActivation);
SubscribeLocalEvent<MessagesCartridgeComponent, CartridgeDeactivatedEvent>(OnCartDeactivation);
SubscribeLocalEvent<MessagesCartridgeComponent, CartridgeAddedEvent>(OnCartInsertion);
SubscribeLocalEvent<MessagesCartridgeComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<MessagesCartridgeComponent, ComponentRemove>(OnRemove);
}
private void OnInit(EntityUid uid, MessagesCartridgeComponent component, ComponentInit args)
public void Send(EntityUid uid, MessagesCartridgeComponent component)
{
var stationId = _stationSystem.GetOwningStation(uid);
if (!stationId.HasValue ||

View File

@@ -1,7 +1,5 @@
using Content.Server.Ghost.Components;
using Content.Shared.Ghost;
using Content.Shared._White.CustomGhostSystem;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
@@ -19,12 +17,13 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GhostComponent, PlayerAttachedEvent>(OnShit);
}
private void OnShit(EntityUid uid, GhostComponent component, PlayerAttachedEvent args)
{
if(!_playerManager.TryGetSessionByEntity(uid, out var session))
if (!_playerManager.TryGetSessionByEntity(uid, out var session))
return;
TrySetCustomSprite(uid, session.Name);
@@ -37,32 +36,22 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
foreach (var customGhostPrototype in prototypes)
{
if (string.Equals(customGhostPrototype.Ckey, ckey, StringComparison.CurrentCultureIgnoreCase))
{
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.Sprite, customGhostPrototype.CustomSpritePath.ToString());
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.SizeOverride, customGhostPrototype.SizeOverride);
if (!string.Equals(customGhostPrototype.Ckey, ckey, StringComparison.CurrentCultureIgnoreCase))
continue;
if(customGhostPrototype.AlphaOverride > 0)
{
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.AlphaOverride, customGhostPrototype.AlphaOverride);
}
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.Sprite, customGhostPrototype.CustomSpritePath.ToString());
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.SizeOverride, customGhostPrototype.SizeOverride);
if (customGhostPrototype.GhostName != string.Empty)
{
_metaData.SetEntityName(ghostUid, customGhostPrototype.GhostName);
}
if (customGhostPrototype.AlphaOverride > 0)
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.AlphaOverride, customGhostPrototype.AlphaOverride);
if (customGhostPrototype.GhostDescription != string.Empty)
{
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
}
if (customGhostPrototype.GhostName != string.Empty)
_metaData.SetEntityName(ghostUid, customGhostPrototype.GhostName ?? "null");
if (customGhostPrototype.GhostDescription != string.Empty)
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
return;
}
return;
}
}
}

View File

@@ -0,0 +1,94 @@
using System.Linq;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.Xenoarchaeology.XenoArtifacts;
using Content.Shared._White;
using Content.Shared.Item;
using Robust.Shared.Configuration;
using Robust.Shared.Random;
namespace Content.Server._White.RandomArtifacts;
public sealed class RandomArtifactsSystem : EntitySystem
{
[Dependency] private readonly ArtifactSystem _artifactsSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly StationSystem _station = default!;
private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.7%
private bool _artifactsEnabled;
public override void Initialize()
{
base.Initialize();
_configurationManager.OnValueChanged(WhiteCVars.EnableRandomArtifacts, b => OnCvarChanged(b), true);
_configurationManager.OnValueChanged(WhiteCVars.ItemToArtifactRatio, r => _itemToArtifactRatio = r, true);
SubscribeLocalEvent<MainMapInitEvent>(OnRoundStart);
}
private void OnRoundStart(MainMapInitEvent ev)
{
if (!_artifactsEnabled)
return;
// Removing old artifact-items and replace it with new funny stealthy items
foreach (var oldArtifact in EntityQuery<ArtifactComponent>())
{
QueueDel(oldArtifact.Owner);
}
var items = EntityQuery<ItemComponent>().ToList();
_random.Shuffle(items);
var selectedItems = GetPercentageOfHashSet(items, _itemToArtifactRatio);
foreach (var item in selectedItems)
{
var entity = item.Owner;
var xform = Transform(entity);
var station = _station.GetStationInMap(xform.MapID);
if (!HasComp<StationDataComponent>(station))
continue;
var artifactComponent = EnsureComp<ArtifactComponent>(entity);
_artifactsSystem.RandomizeArtifact(entity, artifactComponent);
}
}
private HashSet<ItemComponent> GetPercentageOfHashSet(List<ItemComponent> sourceList, float percentage)
{
var countToAdd = (int) Math.Round((double) sourceList.Count * percentage / 100);
return sourceList.Where(x => !Transform(x.Owner).Anchored).Take(countToAdd).ToHashSet();
}
private void OnCvarChanged(bool enabled)
{
if (_artifactsEnabled != enabled && !enabled)
{
var items = EntityQuery<ItemComponent, ArtifactComponent>();
foreach (var (_, artifact) in items)
{
RemComp<ArtifactComponent>(artifact.Owner);
}
}
_artifactsEnabled = enabled;
}
public sealed class MainMapInitEvent : EntityEventArgs { }
}
/*
Number of items on maps
DEV - 1527
WhiteBox - 13692
WonderBox - 15306
*/