Skip to content

Commit

Permalink
Merge pull request #500 from DebugOk/Wizmerge-2/12
Browse files Browse the repository at this point in the history
Merge wizden up to 02/12 - Part one
  • Loading branch information
DebugOk authored Dec 2, 2023
2 parents 2fa1a61 + 2e02ffc commit ebfd7f4
Show file tree
Hide file tree
Showing 107 changed files with 957 additions and 325 deletions.
4 changes: 2 additions & 2 deletions Content.Client/Construction/ConstructionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public bool TrySpawnGhost(
var comp = EntityManager.GetComponent<ConstructionGhostComponent>(ghost.Value);
comp.Prototype = prototype;
EntityManager.GetComponent<TransformComponent>(ghost.Value).LocalRotation = dir.ToAngle();
_ghosts.Add(ghost.Value.Id, ghost.Value);
_ghosts.Add(ghost.GetHashCode(), ghost.Value);
var sprite = EntityManager.GetComponent<SpriteComponent>(ghost.Value);
sprite.Color = new Color(48, 255, 48, 128);

Expand Down Expand Up @@ -265,7 +265,7 @@ public void TryStartConstruction(EntityUid ghostId, ConstructionGhostComponent?
}

var transform = EntityManager.GetComponent<TransformComponent>(ghostId);
var msg = new TryStartStructureConstructionMessage(GetNetCoordinates(transform.Coordinates), ghostComp.Prototype.ID, transform.LocalRotation, ghostId.Id);
var msg = new TryStartStructureConstructionMessage(GetNetCoordinates(transform.Coordinates), ghostComp.Prototype.ID, transform.LocalRotation, ghostId.GetHashCode());
RaiseNetworkEvent(msg);
}

Expand Down
24 changes: 15 additions & 9 deletions Content.Client/Decals/DecalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public sealed class DecalSystem : SharedDecalSystem

private DecalOverlay _overlay = default!;

private HashSet<uint> _removedUids = new();
private readonly List<Vector2i> _removedChunks = new();

public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -65,26 +68,27 @@ private void OnHandleState(EntityUid gridUid, DecalGridComponent gridComp, ref C
return;

// is this a delta or full state?
var removedChunks = new List<Vector2i>();
_removedChunks.Clear();

if (!state.FullState)
{
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
{
if (!state.AllChunks!.Contains(key))
removedChunks.Add(key);
_removedChunks.Add(key);
}
}
else
{
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
{
if (!state.Chunks.ContainsKey(key))
removedChunks.Add(key);
_removedChunks.Add(key);
}
}

if (removedChunks.Count > 0)
RemoveChunks(gridUid, gridComp, removedChunks);
if (_removedChunks.Count > 0)
RemoveChunks(gridUid, gridComp, _removedChunks);

if (state.Chunks.Count > 0)
UpdateChunks(gridUid, gridComp, state.Chunks);
Expand Down Expand Up @@ -137,9 +141,10 @@ private void UpdateChunks(EntityUid gridId, DecalGridComponent gridComp, Diction
{
if (chunkCollection.TryGetValue(indices, out var chunk))
{
var removedUids = new HashSet<uint>(chunk.Decals.Keys);
removedUids.ExceptWith(newChunkData.Decals.Keys);
foreach (var removedUid in removedUids)
_removedUids.Clear();
_removedUids.UnionWith(chunk.Decals.Keys);
_removedUids.ExceptWith(newChunkData.Decals.Keys);
foreach (var removedUid in _removedUids)
{
OnDecalRemoved(gridId, removedUid, gridComp, indices, chunk);
gridComp.DecalIndex.Remove(removedUid);
Expand All @@ -166,7 +171,8 @@ private void RemoveChunks(EntityUid gridId, DecalGridComponent gridComp, IEnumer

foreach (var index in chunks)
{
if (!chunkCollection.TryGetValue(index, out var chunk)) continue;
if (!chunkCollection.TryGetValue(index, out var chunk))
continue;

foreach (var decalId in chunk.Decals.Keys)
{
Expand Down
13 changes: 7 additions & 6 deletions Content.Client/Decals/Overlays/DecalOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ protected override void Draw(in OverlayDrawArgs args)
{
// Shouldn't need to clear cached textures unless the prototypes get reloaded.
var handle = args.WorldHandle;
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
var xformSystem = _entManager.System<TransformSystem>();
var eyeAngle = args.Viewport.Eye?.Rotation ?? Angle.Zero;

foreach (var (decalGrid, xform) in _entManager.EntityQuery<DecalGridComponent, TransformComponent>(true))
var gridQuery = _entManager.AllEntityQueryEnumerator<DecalGridComponent, TransformComponent>();

while (gridQuery.MoveNext(out var decalGrid, out var xform))
{
if (xform.MapID != args.MapId)
continue;

var zIndexDictionary = decalGrid.DecalRenderIndex;

if (zIndexDictionary.Count == 0)
continue;

if (xform.MapID != args.MapId)
continue;

var (_, worldRot, worldMatrix) = xformSystem.GetWorldPositionRotationMatrix(xform, xformQuery);
var (_, worldRot, worldMatrix) = xformSystem.GetWorldPositionRotationMatrix(xform);

handle.SetTransform(worldMatrix);

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/PDA/PdaWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</Control>
<!--Footer-->
<BoxContainer Orientation="Horizontal" SetHeight="28">
<Label Text="Personal Digital Assistant" StyleClasses="PdaWindowFooterText" Margin="32 0 0 6"/>
<Label Text="{Loc 'comp-pda-ui-footer'}" StyleClasses="PdaWindowFooterText" Margin="32 0 0 6"/>
</BoxContainer>
</BoxContainer>
</pda:PdaWindow>
17 changes: 7 additions & 10 deletions Content.Client/SubFloor/TrayScannerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
private const string TRayAnimationKey = "trays";
private const double AnimationLength = 0.3;

public const LookupFlags Flags = LookupFlags.Static | LookupFlags.Sundries | LookupFlags.Approximate;

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand Down Expand Up @@ -76,28 +78,23 @@ public override void Update(float frameTime)

if (canSee)
{
_lookup.GetEntitiesInRange(playerMap, playerPos, range, inRange);
_lookup.GetEntitiesInRange(playerMap, playerPos, range, inRange, flags: Flags);

foreach (var (uid, comp) in inRange)
{
if (!comp.IsUnderCover || !comp.BlockAmbience | !comp.BlockInteractions)
continue;

EnsureComp<TrayRevealedComponent>(uid);
if (comp.IsUnderCover)
EnsureComp<TrayRevealedComponent>(uid);
}
}

var revealedQuery = AllEntityQuery<TrayRevealedComponent, SpriteComponent, TransformComponent>();
var revealedQuery = AllEntityQuery<TrayRevealedComponent, SpriteComponent>();
var subfloorQuery = GetEntityQuery<SubFloorHideComponent>();

while (revealedQuery.MoveNext(out var uid, out _, out var sprite, out var xform))
while (revealedQuery.MoveNext(out var uid, out _, out var sprite))
{
// Revealing
// Add buffer range to avoid flickers.
if (subfloorQuery.TryGetComponent(uid, out var subfloor) &&
xform.MapID != MapId.Nullspace &&
xform.MapID == playerMap &&
xform.Anchored &&
inRange.Contains((uid, subfloor)))
{
// Due to the fact client is predicting this server states will reset it constantly
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/UserInterface/Controls/SlotControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void ClearHover()
if (!EntityHover)
return;

var tempQualifier = HoverSpriteView.Ent;
var tempQualifier = HoverSpriteView.Entity;
if (tempQualifier != null)
{
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(tempQualifier);
Expand Down
5 changes: 3 additions & 2 deletions Content.IntegrationTests/Tests/FollowerSystemTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.GameTicking;
using Content.Shared.Follower;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
Expand Down Expand Up @@ -31,11 +32,11 @@ await server.WaitPost(() =>
var map = mapMan.CreateMap();

// Spawn an observer to be followed.
var followed = entMan.SpawnEntity("MobObserver", new MapCoordinates(0, 0, map));
var followed = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, new MapCoordinates(0, 0, map));
logger.Info($"Spawned followed observer: {entMan.ToPrettyString(followed)}");

// Spawn an observer to follow another observer.
var follower = entMan.SpawnEntity("MobObserver", new MapCoordinates(0, 0, map));
var follower = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, new MapCoordinates(0, 0, map));
logger.Info($"Spawned follower observer: {entMan.ToPrettyString(follower)}");

followerSystem.StartFollowingEntity(follower, followed);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using Content.Server.Players;
using Content.Server.GameTicking;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Players;
Expand Down Expand Up @@ -173,7 +173,7 @@ public async Task TestOriginalDeletedWhileGhostingKeepsGhost()
EntityUid ghost = default!;
await server.WaitAssertion(() =>
{
ghost = entMan.SpawnEntity("MobObserver", MapCoordinates.Nullspace);
ghost = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, MapCoordinates.Nullspace);
mindSystem.Visit(mind.Id, ghost);
});

Expand Down Expand Up @@ -224,7 +224,7 @@ public async Task TestGhostToAghost()
var ghost = await BecomeGhost(pair);

// Player is a normal ghost (not admin ghost).
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.Not.EqualTo("AdminObserver"));
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.Not.EqualTo(GameTicker.AdminObserverPrototypeName));

// Try to become an admin ghost
await server.WaitAssertion(() => serverConsole.ExecuteCommand(player, "aghost"));
Expand All @@ -235,7 +235,7 @@ public async Task TestGhostToAghost()
{
Assert.That(player.AttachedEntity, Is.Not.EqualTo(ghost), "Player is still attached to the old ghost");
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity), "Player did not become a new ghost");
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo("AdminObserver"));
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo(GameTicker.AdminObserverPrototypeName));
});

var mindId = player.ContentData()?.Mind;
Expand Down
4 changes: 2 additions & 2 deletions Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq;
using Content.IntegrationTests.Pair;
using Content.Server.GameTicking;
using Content.Server.Mind;
using Content.Server.Players;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Players;
Expand Down Expand Up @@ -78,7 +78,7 @@ private static async Task<EntityUid> BecomeGhost(TestPair pair, bool visit = fal
await pair.Server.WaitAssertion(() =>
{
var oldUid = player.AttachedEntity;
ghostUid = entMan.SpawnEntity("MobObserver", MapCoordinates.Nullspace);
ghostUid = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, MapCoordinates.Nullspace);
mindId = mindSys.GetMind(player.UserId)!.Value;
Assert.That(mindId, Is.Not.EqualTo(default(EntityUid)));
mind = entMan.GetComponent<MindComponent>(mindId);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Administration/Commands/AGhost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
var coordinates = player.AttachedEntity != null
? _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
var ghost = _entities.SpawnEntity("AdminObserver", coordinates);
var ghost = _entities.SpawnEntity(GameTicker.AdminObserverPrototypeName, coordinates);
_entities.GetComponent<TransformComponent>(ghost).AttachToGridOrMap();

if (canReturn)
Expand Down
28 changes: 13 additions & 15 deletions Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ private void AddAdminVerbs(GetVerbsEvent<Verb> args)
Impact = LogImpact.Extreme,
ConfirmationPopup = true
});

// Respawn
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("admin-player-actions-respawn"),
Category = VerbCategory.Admin,
Act = () =>
{
_console.ExecuteCommand(player, $"respawn {targetActor.PlayerSession.Name}");
},
ConfirmationPopup = true,
// No logimpact as the command does it internally.
});
}

// Admin Logs
Expand Down Expand Up @@ -211,21 +224,6 @@ private void AddAdminVerbs(GetVerbsEvent<Verb> args)
Impact = LogImpact.Low
});

// Respawn
if (HasComp<ActorComponent>(args.Target))
{
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("admin-player-actions-respawn"),
Category = VerbCategory.Admin,
Act = () =>
{
_console.ExecuteCommand(player, $"respawn {actor.PlayerSession.Name}");
},
ConfirmationPopup = true,
// No logimpact as the command does it internally.
});
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions Content.Server/Atmos/Components/GridAtmosphereComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ public sealed partial class GridAtmosphereComponent : Component
public readonly HashSet<Entity<AtmosDeviceComponent>> AtmosDevices = new();

[ViewVariables]
public Queue<TileAtmosphere> CurrentRunTiles = new();
public readonly Queue<TileAtmosphere> CurrentRunTiles = new();

[ViewVariables]
public Queue<ExcitedGroup> CurrentRunExcitedGroups = new();
public readonly Queue<ExcitedGroup> CurrentRunExcitedGroups = new();

[ViewVariables]
public Queue<IPipeNet> CurrentRunPipeNet = new();
public readonly Queue<IPipeNet> CurrentRunPipeNet = new();

[ViewVariables]
public Queue<Entity<AtmosDeviceComponent>> CurrentRunAtmosDevices = new();
public readonly Queue<Entity<AtmosDeviceComponent>> CurrentRunAtmosDevices = new();

[ViewVariables]
public readonly HashSet<Vector2i> InvalidatedCoords = new(1000);

[ViewVariables]
public Queue<Vector2i> CurrentRunInvalidatedCoordinates = new();
public readonly Queue<Vector2i> CurrentRunInvalidatedCoordinates = new();

[ViewVariables]
public int InvalidatedCoordsCount => InvalidatedCoords.Count;
Expand Down
Loading

0 comments on commit ebfd7f4

Please sign in to comment.