mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b6381c332 | ||
|
|
8149a3aaad | ||
|
|
4b39bf1f2d | ||
|
|
53394fff44 | ||
|
|
4bed20e070 | ||
|
|
e4b6af09f1 | ||
|
|
1ef29ae781 | ||
|
|
5686950421 | ||
|
|
2b54aa8984 | ||
|
|
859f150404 | ||
|
|
558f4b5b16 | ||
|
|
108366152b | ||
|
|
c55327e1d1 | ||
|
|
370e0fa0d0 | ||
|
|
4f9f82c20c | ||
|
|
43670a8ddd | ||
|
|
250313e1ed | ||
|
|
18d511d4b6 | ||
|
|
da9e5fb370 | ||
|
|
e3bac382ce | ||
|
|
179c6790b6 | ||
|
|
a7db5634df | ||
|
|
2daa86ff59 | ||
|
|
d6803f5294 | ||
|
|
bdcc0f7b9d | ||
|
|
ce49aa47cf | ||
|
|
c7d48b2526 | ||
|
|
6bb7f5b4ef | ||
|
|
2974310450 |
@@ -45,7 +45,7 @@
|
||||
<PackageVersion Include="Serilog" Version="3.1.1" />
|
||||
<PackageVersion Include="Serilog.Sinks.Loki" Version="4.0.0-beta3" />
|
||||
<PackageVersion Include="SharpZstd.Interop" Version="1.5.2-beta2" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.2" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.3" />
|
||||
<PackageVersion Include="SpaceWizards.HttpListener" Version="0.1.0" />
|
||||
<PackageVersion Include="SpaceWizards.NFluidsynth" Version="0.1.1" />
|
||||
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.0.2" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project>
|
||||
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
|
||||
|
||||
@@ -24,12 +24,16 @@
|
||||
<RobustInjectorsConfiguration>$(Configuration)</RobustInjectorsConfiguration>
|
||||
<RobustInjectorsConfiguration Condition="'$(Configuration)' == 'DebugOpt'">Debug</RobustInjectorsConfiguration>
|
||||
<RobustInjectorsConfiguration Condition="'$(Configuration)' == 'Tools'">Release</RobustInjectorsConfiguration>
|
||||
<RobustInjectorsConfiguration Condition="'$(UseArtifactsOutput)' == 'true' And '$(RuntimeIdentifier)' != ''">$(RobustInjectorsConfiguration)_$(RuntimeIdentifier)</RobustInjectorsConfiguration>
|
||||
<RobustInjectorsConfiguration Condition="'$(UseArtifactsOutput)' == 'true'">$(RobustInjectorsConfiguration.ToLower())</RobustInjectorsConfiguration>
|
||||
<CompileRobustXamlTaskAssemblyFile Condition="'$(UseArtifactsOutput)' != 'true'">$(MSBuildThisFileDirectory)\..\Robust.Client.Injectors\bin\$(RobustInjectorsConfiguration)\netstandard2.0\Robust.Client.Injectors.dll</CompileRobustXamlTaskAssemblyFile>
|
||||
<CompileRobustXamlTaskAssemblyFile Condition="'$(UseArtifactsOutput)' == 'true'">$(MSBuildThisFileDirectory)\..\..\artifacts\bin\Robust.Client.Injectors\$(RobustInjectorsConfiguration)\Robust.Client.Injectors.dll</CompileRobustXamlTaskAssemblyFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask
|
||||
Condition="'$(_RobustUseExternalMSBuild)' != 'true' And $(DesignTimeBuild) != true"
|
||||
TaskName="CompileRobustXamlTask"
|
||||
AssemblyFile="$(MSBuildThisFileDirectory)\..\Robust.Client.Injectors\bin\$(RobustInjectorsConfiguration)\netstandard2.0\Robust.Client.Injectors.dll"/>
|
||||
AssemblyFile="$(CompileRobustXamlTaskAssemblyFile)"/>
|
||||
<Target
|
||||
Name="CompileRobustXaml"
|
||||
Condition="Exists('@(IntermediateAssembly)')"
|
||||
|
||||
@@ -54,6 +54,79 @@ END TEMPLATE-->
|
||||
*None yet*
|
||||
|
||||
|
||||
## 213.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Remove obsoleted BaseContainer methods.
|
||||
|
||||
### New features
|
||||
|
||||
* Add EntityManager.RaiseSharedEvent where the event won't go to the attached client but will be predicted locally on their end.
|
||||
* Add GetEntitiesInRange override that takes in EntityCoordinates and an EntityUid hashset.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Check if a sprite entity is deleted before drawing in SpriteView.
|
||||
|
||||
|
||||
## 212.2.0
|
||||
|
||||
### New features
|
||||
|
||||
* Add IsHardCollidable to SharedPhysicsSystem to determine if 2 entities would collide.
|
||||
|
||||
### Other
|
||||
|
||||
* Double the default maximum replay size.
|
||||
|
||||
|
||||
## 212.1.0
|
||||
|
||||
### New features
|
||||
|
||||
* Add nullable methods for TryIndex / HasIndex on IPrototypeManager.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fix TextureRect alignment where the strech mode is KeepCentered.
|
||||
|
||||
|
||||
## 212.0.1
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fix passing array by `this` instead of by `ref`.
|
||||
|
||||
|
||||
## 212.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Change Collapsible controls default orientations to Vertical.
|
||||
|
||||
### New features
|
||||
|
||||
* Expose the Label control for Collapsible controls.
|
||||
* Add GetGridPosition that considers physics center-of-mass.
|
||||
* Add TileToVector methods to get the LocalPosition of tile-coords (taking into account tile size).
|
||||
* Add some more helper methods to PVS filters around EntityUids.
|
||||
* Add support for Dictionary AutoNetworkedFields.
|
||||
* Add EnsureLength method for arrays.
|
||||
* Add PushMarkup to FormattedMessage.
|
||||
* Add DrawPrimitives overload for `List<Vector2>`
|
||||
* Add more ValueList ctors that are faster.
|
||||
* Add ToMapCoordinates method for NetCoordinates.
|
||||
|
||||
### Other
|
||||
|
||||
* Remove ISerializationHooks obsoletion as they are useful in some rare cases.
|
||||
|
||||
### Internal
|
||||
|
||||
* Bump max pool size for robust jobs.
|
||||
|
||||
|
||||
## 211.0.2
|
||||
|
||||
### Bugfixes
|
||||
|
||||
@@ -490,7 +490,7 @@ cmd-net_entityreport-help = Usage: net_entityreport
|
||||
cmd-net_refresh-desc = Requests a full server state.
|
||||
cmd-net_refresh-help = Usage: net_refresh
|
||||
|
||||
cmd-net_graph-desc = Toggles the net statistics pannel.
|
||||
cmd-net_graph-desc = Toggles the net statistics panel.
|
||||
cmd-net_graph-help = Usage: net_graph
|
||||
|
||||
cmd-net_watchent-desc = Dumps all network updates for an EntityId to the console.
|
||||
|
||||
@@ -70,9 +70,9 @@ command-description-ls-in =
|
||||
command-description-methods-get =
|
||||
Returns all methods associated with the input type.
|
||||
command-description-methods-overrides =
|
||||
Returns all methods overriden on the input type.
|
||||
Returns all methods overridden on the input type.
|
||||
command-description-methods-overridesfrom =
|
||||
Returns all methods overriden from the given type on the input type.
|
||||
Returns all methods overridden from the given type on the input type.
|
||||
command-description-cmd-moo =
|
||||
Asks the important questions.
|
||||
command-description-cmd-descloc =
|
||||
@@ -418,6 +418,6 @@ command-description-tee =
|
||||
This essentially lets you have a branch in your code to do multiple operations on one value.
|
||||
command-description-cmd-info =
|
||||
Returns a CommandSpec for the given command.
|
||||
On it's own, this means it'll print the comamnd's help message.
|
||||
On its own, this means it'll print the command's help message.
|
||||
command-description-comp-rm =
|
||||
Removes the given component from the entity.
|
||||
|
||||
@@ -8,6 +8,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Network.Messages;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Replays;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -134,6 +135,24 @@ namespace Robust.Client.GameObjects
|
||||
EventBus.RaiseEvent(EventSource.Local, new EntitySessionMessage<T>(eventArgs, msg));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void RaiseSharedEvent<T>(T message, EntityUid? user = null)
|
||||
{
|
||||
if (user == null || user != _playerManager.LocalEntity || !_gameTiming.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
EventBus.RaiseEvent(EventSource.Local, ref message);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void RaiseSharedEvent<T>(T message, ICommonSession? user = null)
|
||||
{
|
||||
if (user == null || user != _playerManager.LocalSession || !_gameTiming.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
EventBus.RaiseEvent(EventSource.Local, ref message);
|
||||
}
|
||||
|
||||
#region IEntityNetworkManager impl
|
||||
|
||||
public override IEntityNetworkManager EntityNetManager => this;
|
||||
|
||||
@@ -1201,7 +1201,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
private void LightResolutionScaleChanged(float newValue)
|
||||
{
|
||||
_lightResolutionScale = newValue;
|
||||
_lightResolutionScale = newValue > 0.05f ? newValue : 0.05f;
|
||||
RegenAllLightRts();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -63,6 +64,19 @@ namespace Robust.Client.Graphics
|
||||
|
||||
// ---- DrawPrimitives: Vector2 API ----
|
||||
|
||||
/// <summary>
|
||||
/// Draws arbitrary geometry primitives with a flat color.
|
||||
/// </summary>
|
||||
/// <param name="primitiveTopology">The topology of the primitives to draw.</param>
|
||||
/// <param name="vertices">The list of vertices to render.</param>
|
||||
/// <param name="color">The color to draw with.</param>
|
||||
public void DrawPrimitives(DrawPrimitiveTopology primitiveTopology, List<Vector2> vertices,
|
||||
Color color)
|
||||
{
|
||||
var span = CollectionsMarshal.AsSpan(vertices);
|
||||
DrawPrimitives(primitiveTopology, span, color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws arbitrary geometry primitives with a flat color.
|
||||
/// </summary>
|
||||
|
||||
@@ -29,9 +29,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
}
|
||||
|
||||
public Collapsible()
|
||||
{}
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical;
|
||||
}
|
||||
|
||||
public Collapsible(CollapsibleHeading header, CollapsibleBody body)
|
||||
public Collapsible(CollapsibleHeading header, CollapsibleBody body) : this()
|
||||
{
|
||||
AddChild(header);
|
||||
AddChild(body);
|
||||
@@ -39,12 +41,9 @@ namespace Robust.Client.UserInterface.Controls
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public Collapsible(string title, CollapsibleBody body)
|
||||
public Collapsible(string title, CollapsibleBody body) : this(new CollapsibleHeading(title), body)
|
||||
{
|
||||
AddChild(new CollapsibleHeading(title));
|
||||
AddChild(body);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
protected internal override void Draw(DrawingHandleScreen handle)
|
||||
@@ -105,11 +104,15 @@ namespace Robust.Client.UserInterface.Controls
|
||||
set => _chevron.Margin = value;
|
||||
}
|
||||
|
||||
private Label _title = new();
|
||||
/// <summary>
|
||||
/// Exposes the label for this heading.
|
||||
/// </summary>
|
||||
public Label Label { get; }
|
||||
|
||||
public string? Title
|
||||
{
|
||||
get => _title.Text;
|
||||
set => _title.Text = value;
|
||||
get => Label.Text;
|
||||
set => Label.Text = value;
|
||||
}
|
||||
|
||||
public CollapsibleHeading()
|
||||
@@ -118,8 +121,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
var box = new BoxContainer();
|
||||
AddChild(box);
|
||||
box.AddChild(_chevron);
|
||||
_title = new Label();
|
||||
box.AddChild(_title);
|
||||
Label = new Label();
|
||||
box.AddChild(Label);
|
||||
}
|
||||
|
||||
public CollapsibleHeading(string title) : this()
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
private bool _suppressScrollValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// If true then if we have a y-axis scroll it will convert it to an x-axis scroll.
|
||||
/// </summary>
|
||||
public bool FallbackDeltaScroll { get; set; } = true;
|
||||
|
||||
public int ScrollSpeedX { get; set; } = 50;
|
||||
public int ScrollSpeedY { get; set; } = 50;
|
||||
|
||||
@@ -246,9 +251,19 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
if (_hScrollEnabled)
|
||||
{
|
||||
_hScrollBar.ValueTarget += args.Delta.X * ScrollSpeedX;
|
||||
var delta =
|
||||
args.Delta.X == 0f &&
|
||||
!_vScrollEnabled &&
|
||||
FallbackDeltaScroll ?
|
||||
-args.Delta.Y :
|
||||
args.Delta.X;
|
||||
|
||||
_hScrollBar.ValueTarget += delta * ScrollSpeedX;
|
||||
}
|
||||
|
||||
if (!_vScrollVisible && !_hScrollVisible)
|
||||
return;
|
||||
|
||||
args.Handle();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
private SpriteSystem? _sprite;
|
||||
private SharedTransformSystem? _transform;
|
||||
IEntityManager _entMan;
|
||||
private readonly IEntityManager _entMan;
|
||||
|
||||
[ViewVariables]
|
||||
public SpriteComponent? Sprite => Entity?.Comp1;
|
||||
@@ -143,6 +143,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
if (netEnt == NetEnt)
|
||||
return;
|
||||
|
||||
// The Entity is getting set later in the ResolveEntity method
|
||||
// because the client may not have received it yet.
|
||||
Entity = null;
|
||||
NetEnt = netEnt;
|
||||
}
|
||||
@@ -256,28 +258,19 @@ namespace Robust.Client.UserInterface.Controls
|
||||
[NotNullWhen(true)] out SpriteComponent? sprite,
|
||||
[NotNullWhen(true)] out TransformComponent? xform)
|
||||
{
|
||||
if (NetEnt != null && Entity == null && _entMan.TryGetEntity(NetEnt, out var ent))
|
||||
SetEntity(ent);
|
||||
|
||||
if (Entity != null)
|
||||
{
|
||||
(uid, sprite, xform) = Entity.Value;
|
||||
return true;
|
||||
return !_entMan.Deleted(uid);
|
||||
}
|
||||
|
||||
sprite = null;
|
||||
xform = null;
|
||||
uid = default;
|
||||
|
||||
if (NetEnt == null)
|
||||
return false;
|
||||
|
||||
if (!_entMan.TryGetEntity(NetEnt, out var ent))
|
||||
return false;
|
||||
|
||||
SetEntity(ent);
|
||||
if (Entity == null)
|
||||
return false;
|
||||
|
||||
(uid, sprite, xform) = Entity.Value;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
return UIBox2.FromDimensions(Vector2.Zero, TextureSizeTarget * UIScale);
|
||||
case StretchMode.KeepCentered:
|
||||
{
|
||||
var position = (PixelSize - TextureSizeTarget) / 2;
|
||||
var position = (Size - TextureSizeTarget) / 2;
|
||||
return UIBox2.FromDimensions(position, TextureSizeTarget * UIScale);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,40 @@ namespace Robust.Server.GameObjects
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void RaiseSharedEvent<T>(T message, EntityUid? user = null)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
var filter = Filter.Broadcast().RemoveWhereAttachedEntity(e => e == user.Value);
|
||||
foreach (var session in filter.Recipients)
|
||||
{
|
||||
EntityNetManager.SendSystemNetworkMessage(message, session.Channel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityNetManager.SendSystemNetworkMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void RaiseSharedEvent<T>(T message, ICommonSession? user = null)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
var filter = Filter.Broadcast().RemovePlayer(user);
|
||||
foreach (var session in filter.Recipients)
|
||||
{
|
||||
EntityNetManager.SendSystemNetworkMessage(message, session.Channel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityNetManager.SendSystemNetworkMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearTicks(EntityUid entity, EntityPrototype prototype)
|
||||
{
|
||||
foreach (var (netId, component) in GetNetComponents(entity))
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using static Microsoft.CodeAnalysis.SymbolDisplayFormat;
|
||||
using static Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions;
|
||||
|
||||
namespace Robust.Shared.CompNetworkGenerator
|
||||
{
|
||||
@@ -19,19 +17,25 @@ namespace Robust.Shared.CompNetworkGenerator
|
||||
private const string GlobalEntityUidName = "global::Robust.Shared.GameObjects.EntityUid";
|
||||
private const string GlobalNullableEntityUidName = "global::Robust.Shared.GameObjects.EntityUid?";
|
||||
|
||||
private const string GlobalNetEntityName = "global::Robust.Shared.GameObjects.NetEntity";
|
||||
private const string GlobalNetEntityNullableName = "global::Robust.Shared.GameObjects.NetEntity?";
|
||||
|
||||
private const string GlobalEntityCoordinatesName = "global::Robust.Shared.Map.EntityCoordinates";
|
||||
private const string GlobalNullableEntityCoordinatesName = "global::Robust.Shared.Map.EntityCoordinates?";
|
||||
|
||||
private const string GlobalEntityUidSetName = "global::System.Collections.Generic.HashSet<global::Robust.Shared.GameObjects.EntityUid>";
|
||||
private const string GlobalNetEntityUidSetName = "global::System.Collections.Generic.HashSet<global::Robust.Shared.GameObjects.NetEntity>";
|
||||
private const string GlobalNetEntityUidSetName = $"global::System.Collections.Generic.HashSet<{GlobalNetEntityName}>";
|
||||
|
||||
private const string GlobalEntityUidListName = "global::System.Collections.Generic.List<global::Robust.Shared.GameObjects.EntityUid>";
|
||||
private const string GlobalNetEntityUidListName = "global::System.Collections.Generic.List<global::Robust.Shared.GameObjects.NetEntity>";
|
||||
private const string GlobalNetEntityUidListName = $"global::System.Collections.Generic.List<{GlobalNetEntityName}>";
|
||||
|
||||
private const string GlobalDictionaryName = "global::System.Collections.Generic.Dictionary<TKey, TValue>";
|
||||
private const string GlobalHashSetName = "global::System.Collections.Generic.HashSet<T>";
|
||||
private const string GlobalListName = "global::System.Collections.Generic.List<T>";
|
||||
|
||||
private static readonly SymbolDisplayFormat FullNullableFormat =
|
||||
FullyQualifiedFormat.WithMiscellaneousOptions(IncludeNullableReferenceTypeModifier);
|
||||
|
||||
private static string? GenerateSource(in GeneratorExecutionContext context, INamedTypeSymbol classSymbol, CSharpCompilation comp, bool raiseAfterAutoHandle)
|
||||
{
|
||||
var nameSpace = classSymbol.ContainingNamespace.ToDisplayString();
|
||||
@@ -132,7 +136,7 @@ namespace Robust.Shared.CompNetworkGenerator
|
||||
|
||||
foreach (var (type, name) in fields)
|
||||
{
|
||||
var typeDisplayStr = type.ToDisplayString(FullyQualifiedFormat);
|
||||
var typeDisplayStr = type.ToDisplayString(FullNullableFormat);
|
||||
var nullable = type.NullableAnnotation == NullableAnnotation.Annotated;
|
||||
var nullableAnnotation = nullable ? "?" : string.Empty;
|
||||
|
||||
@@ -181,6 +185,62 @@ namespace Robust.Shared.CompNetworkGenerator
|
||||
|
||||
break;
|
||||
default:
|
||||
if (type is INamedTypeSymbol { TypeArguments.Length: 2 } named &&
|
||||
named.ConstructedFrom.ToDisplayString(FullyQualifiedFormat) == GlobalDictionaryName)
|
||||
{
|
||||
var key = named.TypeArguments[0].ToDisplayString(FullNullableFormat);
|
||||
var keyNullable = key.EndsWith("?");
|
||||
|
||||
var value = named.TypeArguments[1].ToDisplayString(FullNullableFormat);
|
||||
var valueNullable = value.EndsWith("?");
|
||||
|
||||
if (key is GlobalEntityUidName or GlobalNullableEntityUidName)
|
||||
{
|
||||
key = keyNullable ? GlobalNetEntityNullableName : GlobalNetEntityName;
|
||||
|
||||
var ensureGeneric = $"{componentName}, {value}";
|
||||
if (value is GlobalEntityUidName or GlobalNullableEntityUidName)
|
||||
{
|
||||
value = valueNullable ? GlobalNetEntityNullableName : GlobalNetEntityName;
|
||||
ensureGeneric = componentName;
|
||||
}
|
||||
|
||||
stateFields.Append($@"
|
||||
public Dictionary<{key}, {value}> {name} = default!;");
|
||||
|
||||
getStateInit.Append($@"
|
||||
{name} = GetNetEntityDictionary(component.{name}),");
|
||||
|
||||
if (valueNullable && value is not GlobalNetEntityName and not GlobalNetEntityNullableName)
|
||||
{
|
||||
handleStateSetters.Append($@"
|
||||
EnsureEntityDictionaryNullableValue<{componentName}, {value}>(state.{name}, uid, component.{name});");
|
||||
}
|
||||
else
|
||||
{
|
||||
handleStateSetters.Append($@"
|
||||
EnsureEntityDictionary<{ensureGeneric}>(state.{name}, uid, component.{name});");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (value is GlobalEntityUidName or GlobalNullableEntityUidName)
|
||||
{
|
||||
value = valueNullable ? GlobalNetEntityNullableName : GlobalNetEntityName;
|
||||
|
||||
stateFields.Append($@"
|
||||
public Dictionary<{key}, {value}> {name} = default!;");
|
||||
|
||||
getStateInit.Append($@"
|
||||
{name} = GetNetEntityDictionary(component.{name}),");
|
||||
handleStateSetters.Append($@"
|
||||
EnsureEntityDictionary<{componentName}, {key}>(state.{name}, uid, component.{name});");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stateFields.Append($@"
|
||||
public {typeDisplayStr} {name} = default!;");
|
||||
|
||||
@@ -193,7 +253,7 @@ namespace Robust.Shared.CompNetworkGenerator
|
||||
|
||||
handleStateSetters.Append($@"
|
||||
if (state.{name} == null)
|
||||
component.{name} = null;
|
||||
component.{name} = null!;
|
||||
else
|
||||
component.{name} = new(state.{name});");
|
||||
}
|
||||
@@ -219,6 +279,7 @@ namespace Robust.Shared.CompNetworkGenerator
|
||||
}
|
||||
|
||||
return $@"// <auto-generated />
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -1498,7 +1498,7 @@ namespace Robust.Shared
|
||||
/// Maximum compressed size of a replay recording (in kilobytes) before recording automatically stops.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<long> ReplayMaxCompressedSize = CVarDef.Create("replay.max_compressed_size",
|
||||
1024L * 256, CVar.ARCHIVE);
|
||||
1024L * 512, CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Maximum uncompressed size of a replay recording (in kilobytes) before recording automatically stops.
|
||||
|
||||
@@ -6,7 +6,9 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Robust.Shared.Collections;
|
||||
|
||||
@@ -50,6 +52,41 @@ public struct ValueList<T> : IEnumerable<T>
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list by copying the contents of the source list.
|
||||
/// </summary>
|
||||
public ValueList(List<T> list) : this(list, 0, list.Count)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list by copying the contents of the source list.
|
||||
/// </summary>
|
||||
public ValueList(List<T> list, int start, int count)
|
||||
{
|
||||
_items = new T[count];
|
||||
|
||||
var liSpan = CollectionsMarshal.AsSpan(list)[start..(start + count)];
|
||||
liSpan.CopyTo(_items);
|
||||
|
||||
Count = count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list by copying the contents of the source list.
|
||||
/// </summary>
|
||||
public ValueList(IReadOnlyCollection<T> list)
|
||||
{
|
||||
var count = list.Count;
|
||||
_items = new T[count];
|
||||
|
||||
foreach (var entry in list)
|
||||
{
|
||||
var size = Count;
|
||||
AddNoResize(entry, size);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a list by copying the contents from another enumerable.
|
||||
/// </summary>
|
||||
@@ -157,12 +194,10 @@ public struct ValueList<T> : IEnumerable<T>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Add(T item)
|
||||
{
|
||||
var array = _items;
|
||||
var size = Count;
|
||||
if ((uint)size < (uint)Capacity)
|
||||
{
|
||||
Count = size + 1;
|
||||
array![size] = item;
|
||||
AddNoResize(item, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -170,6 +205,14 @@ public struct ValueList<T> : IEnumerable<T>
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void AddNoResize(T item, int size)
|
||||
{
|
||||
var array = _items;
|
||||
Count = size + 1;
|
||||
array![size] = item;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ref T AddRef()
|
||||
{
|
||||
@@ -522,4 +565,46 @@ public struct ValueList<T> : IEnumerable<T>
|
||||
RemoveAt(Count - 1);
|
||||
return old;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a range of values from the source list.
|
||||
/// </summary>
|
||||
public void AddRange(ValueList<T> list)
|
||||
{
|
||||
var liSpan = list.Span;
|
||||
AddRange(liSpan);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a range of values from the source list.
|
||||
/// </summary>
|
||||
public void AddRange(List<T> list)
|
||||
{
|
||||
var liSpan = CollectionsMarshal.AsSpan(list);
|
||||
AddRange(liSpan);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddRange(Span<T> span)
|
||||
{
|
||||
var spanCount = span.Length;
|
||||
EnsureCapacity(Count + spanCount);
|
||||
var target = new Span<T>(_items, Count, spanCount);
|
||||
span.CopyTo(target);
|
||||
Count += spanCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills this with default data up to the specified count.
|
||||
/// </summary>
|
||||
public void EnsureLength(int newCount)
|
||||
{
|
||||
if (Count > newCount)
|
||||
return;
|
||||
|
||||
EnsureCapacity(newCount);
|
||||
var region = new Span<T>(_items, Count, (newCount - Count));
|
||||
region.Clear();
|
||||
Count = newCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,46 +71,6 @@ namespace Robust.Shared.Containers
|
||||
[DataField("showEnts")]
|
||||
public bool ShowContents { get; set; }
|
||||
|
||||
[Obsolete("Use container system method")]
|
||||
public bool Insert(
|
||||
EntityUid toinsert,
|
||||
IEntityManager? entMan = null,
|
||||
TransformComponent? transform = null,
|
||||
TransformComponent? ownerTransform = null,
|
||||
MetaDataComponent? meta = null,
|
||||
PhysicsComponent? physics = null,
|
||||
bool force = false)
|
||||
{
|
||||
IoCManager.Resolve(ref entMan);
|
||||
return entMan.System<SharedContainerSystem>().Insert((toinsert, transform, meta, physics), this, ownerTransform, force);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the given entity can be inserted into this container.
|
||||
/// </summary>
|
||||
/// <param name="assumeEmpty">Whether to assume that the container is currently empty.</param>
|
||||
protected internal virtual bool CanInsert(EntityUid toInsert, bool assumeEmpty, IEntityManager entMan) => true;
|
||||
|
||||
[Obsolete("Use container system method")]
|
||||
public bool Remove(
|
||||
EntityUid toRemove,
|
||||
IEntityManager? entMan = null,
|
||||
TransformComponent? xform = null,
|
||||
MetaDataComponent? meta = null,
|
||||
bool reparent = true,
|
||||
bool force = false,
|
||||
EntityCoordinates? destination = null,
|
||||
Angle? localRotation = null
|
||||
)
|
||||
{
|
||||
IoCManager.Resolve(ref entMan);
|
||||
return entMan.System<SharedContainerSystem>().Remove((toRemove, xform, meta), this, reparent, force, destination, localRotation);
|
||||
}
|
||||
|
||||
[Obsolete("Use container system method")]
|
||||
public void ForceRemove(EntityUid toRemove, IEntityManager? entMan = null, MetaDataComponent? meta = null)
|
||||
=> Remove(toRemove, entMan, meta: meta, reparent: false, force: true);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the entity is contained in this container.
|
||||
/// This is not recursive, so containers of children are not checked.
|
||||
@@ -120,18 +80,10 @@ namespace Robust.Shared.Containers
|
||||
public abstract bool Contains(EntityUid contained);
|
||||
|
||||
/// <summary>
|
||||
/// Clears the container and marks it as deleted.
|
||||
/// Whether the given entity can be inserted into this container.
|
||||
/// </summary>
|
||||
[Obsolete("use system method")]
|
||||
public void Shutdown(IEntityManager? entMan = null, INetManager? _ = null)
|
||||
{
|
||||
IoCManager.Resolve(ref entMan);
|
||||
entMan.System<SharedContainerSystem>().ShutdownContainer(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Access(typeof(SharedContainerSystem))]
|
||||
protected internal abstract void InternalShutdown(IEntityManager entMan, SharedContainerSystem system, bool isClient);
|
||||
/// <param name="assumeEmpty">Whether to assume that the container is currently empty.</param>
|
||||
protected internal virtual bool CanInsert(EntityUid toInsert, bool assumeEmpty, IEntityManager entMan) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Implement to store the reference in whatever form you want
|
||||
@@ -148,5 +100,14 @@ namespace Robust.Shared.Containers
|
||||
/// <param name="entMan"></param>
|
||||
[Access(typeof(SharedContainerSystem))]
|
||||
protected internal abstract void InternalRemove(EntityUid toRemove, IEntityManager entMan);
|
||||
|
||||
/// <summary>
|
||||
/// Implement to clear the container and mark it as deleted.
|
||||
/// </summary>
|
||||
/// <param name="entMan"></param>
|
||||
/// <param name="system"></param>
|
||||
/// <param name=isClient"></param>
|
||||
[Access(typeof(SharedContainerSystem))]
|
||||
protected internal abstract void InternalShutdown(IEntityManager entMan, SharedContainerSystem system, bool isClient);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -279,6 +278,66 @@ public partial class EntityManager
|
||||
return entities;
|
||||
}
|
||||
|
||||
public Dictionary<EntityUid, T> GetEntityDictionary<T>(Dictionary<NetEntity, T> netEntities)
|
||||
{
|
||||
var entities = new Dictionary<EntityUid, T>(netEntities.Count);
|
||||
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(GetEntity(pair.Key), pair.Value);
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public Dictionary<T, EntityUid> GetEntityDictionary<T>(Dictionary<T, NetEntity> netEntities) where T : notnull
|
||||
{
|
||||
var entities = new Dictionary<T, EntityUid>(netEntities.Count);
|
||||
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(pair.Key, GetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public Dictionary<T, EntityUid?> GetEntityDictionary<T>(Dictionary<T, NetEntity?> netEntities) where T : notnull
|
||||
{
|
||||
var entities = new Dictionary<T, EntityUid?>(netEntities.Count);
|
||||
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(pair.Key, GetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public Dictionary<EntityUid, EntityUid> GetEntityDictionary(Dictionary<NetEntity, NetEntity> netEntities)
|
||||
{
|
||||
var entities = new Dictionary<EntityUid, EntityUid>(netEntities.Count);
|
||||
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(GetEntity(pair.Key), GetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public Dictionary<EntityUid, EntityUid?> GetEntityDictionary(Dictionary<NetEntity, NetEntity?> netEntities)
|
||||
{
|
||||
var entities = new Dictionary<EntityUid, EntityUid?>(netEntities.Count);
|
||||
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(GetEntity(pair.Key), GetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public HashSet<EntityUid> EnsureEntitySet<T>(HashSet<NetEntity> netEntities, EntityUid callerEntity)
|
||||
{
|
||||
var entities = new HashSet<EntityUid>(netEntities.Count);
|
||||
@@ -324,6 +383,72 @@ public partial class EntityManager
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureEntityDictionary<TComp, TValue>(Dictionary<NetEntity, TValue> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, TValue> entities)
|
||||
{
|
||||
entities.Clear();
|
||||
entities.EnsureCapacity(netEntities.Count);
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(EnsureEntity<TComp>(pair.Key, callerEntity), pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureEntityDictionaryNullableValue<TComp, TValue>(Dictionary<NetEntity, TValue?> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, TValue?> entities)
|
||||
{
|
||||
entities.Clear();
|
||||
entities.EnsureCapacity(netEntities.Count);
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(EnsureEntity<TComp>(pair.Key, callerEntity), pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureEntityDictionary<TComp, TKey>(Dictionary<TKey, NetEntity> netEntities, EntityUid callerEntity,
|
||||
Dictionary<TKey, EntityUid> entities) where TKey : notnull
|
||||
{
|
||||
entities.Clear();
|
||||
entities.EnsureCapacity(netEntities.Count);
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(pair.Key, EnsureEntity<TComp>(pair.Value, callerEntity));
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureEntityDictionary<TComp, TKey>(Dictionary<TKey, NetEntity?> netEntities, EntityUid callerEntity,
|
||||
Dictionary<TKey, EntityUid?> entities) where TKey : notnull
|
||||
{
|
||||
entities.Clear();
|
||||
entities.EnsureCapacity(netEntities.Count);
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(pair.Key, EnsureEntity<TComp>(pair.Value, callerEntity));
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureEntityDictionary<TComp>(Dictionary<NetEntity, NetEntity> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, EntityUid> entities)
|
||||
{
|
||||
entities.Clear();
|
||||
entities.EnsureCapacity(netEntities.Count);
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(EnsureEntity<TComp>(pair.Key, callerEntity), EnsureEntity<TComp>(pair.Value, callerEntity));
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureEntityDictionary<TComp>(Dictionary<NetEntity, NetEntity?> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, EntityUid?> entities)
|
||||
{
|
||||
entities.Clear();
|
||||
entities.EnsureCapacity(netEntities.Count);
|
||||
foreach (var pair in netEntities)
|
||||
{
|
||||
entities.Add(EnsureEntity<TComp>(pair.Key, callerEntity), EnsureEntity<TComp>(pair.Value, callerEntity));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<EntityUid> GetEntityList(ICollection<NetEntity> netEntities)
|
||||
{
|
||||
@@ -467,6 +592,71 @@ public partial class EntityManager
|
||||
return netEntities;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<NetEntity, T> GetNetEntityDictionary<T>(Dictionary<EntityUid, T> entities)
|
||||
{
|
||||
var netEntities = new Dictionary<NetEntity, T>(entities.Count);
|
||||
|
||||
foreach (var pair in entities)
|
||||
{
|
||||
netEntities.Add(GetNetEntity(pair.Key), pair.Value);
|
||||
}
|
||||
|
||||
return netEntities;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<T, NetEntity> GetNetEntityDictionary<T>(Dictionary<T, EntityUid> entities) where T : notnull
|
||||
{
|
||||
var netEntities = new Dictionary<T, NetEntity>(entities.Count);
|
||||
|
||||
foreach (var pair in entities)
|
||||
{
|
||||
netEntities.Add(pair.Key, GetNetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return netEntities;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<T, NetEntity?> GetNetEntityDictionary<T>(Dictionary<T, EntityUid?> entities) where T : notnull
|
||||
{
|
||||
var netEntities = new Dictionary<T, NetEntity?>(entities.Count);
|
||||
|
||||
foreach (var pair in entities)
|
||||
{
|
||||
netEntities.Add(pair.Key, GetNetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return netEntities;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<NetEntity, NetEntity> GetNetEntityDictionary(Dictionary<EntityUid, EntityUid> entities)
|
||||
{
|
||||
var netEntities = new Dictionary<NetEntity, NetEntity>(entities.Count);
|
||||
|
||||
foreach (var pair in entities)
|
||||
{
|
||||
netEntities.Add(GetNetEntity(pair.Key), GetNetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return netEntities;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<NetEntity, NetEntity?> GetNetEntityDictionary(Dictionary<EntityUid, EntityUid?> entities)
|
||||
{
|
||||
var netEntities = new Dictionary<NetEntity, NetEntity?>(entities.Count);
|
||||
|
||||
foreach (var pair in entities)
|
||||
{
|
||||
netEntities.Add(GetNetEntity(pair.Key), GetNetEntity(pair.Value));
|
||||
}
|
||||
|
||||
return netEntities;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public HashSet<EntityCoordinates> GetEntitySet(HashSet<NetCoordinates> netEntities)
|
||||
{
|
||||
|
||||
@@ -906,6 +906,16 @@ namespace Robust.Shared.GameObjects
|
||||
DebugTools.Assert("Why are you raising predictive events on the server?");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises an event locally on client or networked on server.
|
||||
/// </summary>
|
||||
public abstract void RaiseSharedEvent<T>(T message, EntityUid? user = null) where T : EntityEventArgs;
|
||||
|
||||
/// <summary>
|
||||
/// Raises an event locally on client or networked on server.
|
||||
/// </summary>
|
||||
public abstract void RaiseSharedEvent<T>(T message, ICommonSession? user = null) where T : EntityEventArgs;
|
||||
|
||||
/// <summary>
|
||||
/// Factory for generating a new EntityUid for an entity currently being created.
|
||||
/// </summary>
|
||||
|
||||
@@ -1049,6 +1049,42 @@ public partial class EntitySystem
|
||||
EntityManager.EnsureEntityList<T>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void EnsureEntityDictionary<TComp, TValue>(Dictionary<NetEntity, TValue> netEntities, EntityUid callerEntity, Dictionary<EntityUid, TValue> entities)
|
||||
{
|
||||
EntityManager.EnsureEntityDictionary<TComp, TValue>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void EnsureEntityDictionaryNullableValue<TComp, TValue>(Dictionary<NetEntity, TValue?> netEntities, EntityUid callerEntity, Dictionary<EntityUid, TValue?> entities)
|
||||
{
|
||||
EntityManager.EnsureEntityDictionaryNullableValue<TComp, TValue>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void EnsureEntityDictionary<TComp, TKey>(Dictionary<TKey, NetEntity> netEntities, EntityUid callerEntity, Dictionary<TKey, EntityUid> entities) where TKey : notnull
|
||||
{
|
||||
EntityManager.EnsureEntityDictionary<TComp, TKey>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void EnsureEntityDictionary<TComp, TKey>(Dictionary<TKey, NetEntity?> netEntities, EntityUid callerEntity, Dictionary<TKey, EntityUid?> entities) where TKey : notnull
|
||||
{
|
||||
EntityManager.EnsureEntityDictionary<TComp, TKey>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void EnsureEntityDictionary<TComp>(Dictionary<NetEntity, NetEntity> netEntities, EntityUid callerEntity, Dictionary<EntityUid, EntityUid> entities)
|
||||
{
|
||||
EntityManager.EnsureEntityDictionary<TComp>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void EnsureEntityDictionary<TComp>(Dictionary<NetEntity, NetEntity?> netEntities, EntityUid callerEntity, Dictionary<EntityUid, EntityUid?> entities)
|
||||
{
|
||||
EntityManager.EnsureEntityDictionary<TComp>(netEntities, callerEntity, entities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="EntityUid"/> of a <see cref="NetEntity"/>. Returns <see cref="EntityUid.Invalid"/> if it doesn't exist.
|
||||
/// </summary>
|
||||
@@ -1184,6 +1220,96 @@ public partial class EntitySystem
|
||||
return EntityManager.GetEntityArray(netEntities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="NetEntity"/> versions of the supplied entities. Logs an error if the entities do not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<NetEntity, T> GetNetEntityDictionary<T>(Dictionary<EntityUid, T> uids)
|
||||
{
|
||||
return EntityManager.GetNetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="NetEntity"/> versions of the supplied entities. Logs an error if the entities do not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<T, NetEntity> GetNetEntityDictionary<T>(Dictionary<T, EntityUid> uids) where T : notnull
|
||||
{
|
||||
return EntityManager.GetNetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="NetEntity"/> versions of the supplied entities. Logs an error if the entities do not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<T, NetEntity?> GetNetEntityDictionary<T>(Dictionary<T, EntityUid?> uids) where T : notnull
|
||||
{
|
||||
return EntityManager.GetNetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="NetEntity"/> versions of the supplied entities. Logs an error if the entities do not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<NetEntity, NetEntity> GetNetEntityDictionary(Dictionary<EntityUid, EntityUid> uids)
|
||||
{
|
||||
return EntityManager.GetNetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="NetEntity"/> versions of the supplied entities. Logs an error if the entities do not exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<NetEntity, NetEntity?> GetNetEntityDictionary(Dictionary<EntityUid, EntityUid?> uids)
|
||||
{
|
||||
return EntityManager.GetNetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="EntityUid"/> versions of the supplied <see cref="NetEntity"/>. Returns <see cref="EntityUid.Invalid"/> if it doesn't exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<EntityUid, T> GetEntityDictionary<T>(Dictionary<NetEntity, T> uids)
|
||||
{
|
||||
return EntityManager.GetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="EntityUid"/> versions of the supplied <see cref="NetEntity"/>. Returns <see cref="EntityUid.Invalid"/> if it doesn't exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<T, EntityUid> GetEntityDictionary<T>(Dictionary<T, NetEntity> uids) where T : notnull
|
||||
{
|
||||
return EntityManager.GetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="EntityUid"/> versions of the supplied <see cref="NetEntity"/>. Returns <see cref="EntityUid.Invalid"/> if it doesn't exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<T, EntityUid?> GetEntityDictionary<T>(Dictionary<T, NetEntity?> uids) where T : notnull
|
||||
{
|
||||
return EntityManager.GetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="EntityUid"/> versions of the supplied <see cref="NetEntity"/>. Returns <see cref="EntityUid.Invalid"/> if it doesn't exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<EntityUid, EntityUid> GetEntityDictionary(Dictionary<NetEntity, NetEntity> uids)
|
||||
{
|
||||
return EntityManager.GetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="EntityUid"/> versions of the supplied <see cref="NetEntity"/>. Returns <see cref="EntityUid.Invalid"/> if it doesn't exist.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Dictionary<EntityUid, EntityUid?> GetEntityDictionary(Dictionary<NetEntity, NetEntity?> uids)
|
||||
{
|
||||
return EntityManager.GetEntityDictionary(uids);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected NetCoordinates GetNetCoordinates(EntityCoordinates coordinates, MetaDataComponent? metadata = null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Map;
|
||||
@@ -107,6 +106,16 @@ public partial interface IEntityManager
|
||||
/// </summary>
|
||||
EntityUid?[] GetEntityArray(NetEntity?[] netEntities);
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<EntityUid, T> GetEntityDictionary<T>(Dictionary<NetEntity, T> netEntities);
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<T, EntityUid> GetEntityDictionary<T>(Dictionary<T, NetEntity> netEntities) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// HashSet version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
@@ -117,6 +126,11 @@ public partial interface IEntityManager
|
||||
/// </summary>
|
||||
public List<NetEntity> GetNetEntityList(List<EntityUid> entities);
|
||||
|
||||
/// <summary>
|
||||
/// List version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
List<NetEntity> GetNetEntityList(IReadOnlyList<EntityUid> entities);
|
||||
|
||||
/// <summary>
|
||||
/// List version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
@@ -128,15 +142,40 @@ public partial interface IEntityManager
|
||||
public List<NetEntity?> GetNetEntityList(List<EntityUid?> entities);
|
||||
|
||||
/// <summary>
|
||||
/// List version of <see cref="GetNetEntity"/>
|
||||
/// Array version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
NetEntity[] GetNetEntityArray(EntityUid[] entities);
|
||||
|
||||
/// <summary>
|
||||
/// List version of <see cref="GetNetEntity"/>
|
||||
/// Array version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
NetEntity?[] GetNetEntityArray(EntityUid?[] entities);
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<NetEntity, T> GetNetEntityDictionary<T>(Dictionary<EntityUid, T> entities);
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<T, NetEntity> GetNetEntityDictionary<T>(Dictionary<T, EntityUid> entities) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<T, NetEntity?> GetNetEntityDictionary<T>(Dictionary<T, EntityUid?> entities) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<NetEntity, NetEntity> GetNetEntityDictionary(Dictionary<EntityUid, EntityUid> entities);
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary version of <see cref="GetNetEntity"/>
|
||||
/// </summary>
|
||||
Dictionary<NetEntity, NetEntity?> GetNetEntityDictionary(Dictionary<EntityUid, EntityUid?> entities);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the corresponding <see cref="NetCoordinates"/> for the specified local coordinates.
|
||||
/// </summary>
|
||||
@@ -178,6 +217,27 @@ public partial interface IEntityManager
|
||||
|
||||
public List<EntityUid> EnsureEntityList<T>(List<NetEntity> netEntities, EntityUid callerEntity);
|
||||
|
||||
void EnsureEntityList<T>(List<NetEntity> netEntities, EntityUid callerEntity, List<EntityUid> entities);
|
||||
|
||||
void EnsureEntityDictionary<TComp, TValue>(Dictionary<NetEntity, TValue> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, TValue> entities);
|
||||
|
||||
void EnsureEntityDictionaryNullableValue<TComp, TValue>(Dictionary<NetEntity, TValue?> netEntities,
|
||||
EntityUid callerEntity,
|
||||
Dictionary<EntityUid, TValue?> entities);
|
||||
|
||||
void EnsureEntityDictionary<TComp, TKey>(Dictionary<TKey, NetEntity> netEntities, EntityUid callerEntity,
|
||||
Dictionary<TKey, EntityUid> entities) where TKey : notnull;
|
||||
|
||||
void EnsureEntityDictionary<TComp, TKey>(Dictionary<TKey, NetEntity?> netEntities, EntityUid callerEntity,
|
||||
Dictionary<TKey, EntityUid?> entities) where TKey : notnull;
|
||||
|
||||
void EnsureEntityDictionary<TComp>(Dictionary<NetEntity, NetEntity> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, EntityUid> entities);
|
||||
|
||||
void EnsureEntityDictionary<TComp>(Dictionary<NetEntity, NetEntity?> netEntities, EntityUid callerEntity,
|
||||
Dictionary<EntityUid, EntityUid?> entities);
|
||||
|
||||
public List<EntityCoordinates> GetEntityList(ICollection<NetCoordinates> netEntities);
|
||||
|
||||
public List<EntityCoordinates?> GetEntityList(List<NetCoordinates?> netEntities);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
@@ -744,9 +745,20 @@ public sealed partial class EntityLookupSystem
|
||||
}
|
||||
|
||||
public HashSet<EntityUid> GetEntitiesInRange(EntityCoordinates coordinates, float range, LookupFlags flags = DefaultFlags)
|
||||
{
|
||||
var ents = new HashSet<EntityUid>();
|
||||
GetEntitiesInRange(coordinates, range, ents, flags);
|
||||
return ents;
|
||||
}
|
||||
|
||||
public void GetEntitiesInRange(EntityCoordinates coordinates, float range, HashSet<EntityUid> entities, LookupFlags flags = DefaultFlags)
|
||||
{
|
||||
var mapPos = coordinates.ToMap(EntityManager, _transform);
|
||||
return GetEntitiesInRange(mapPos, range, flags);
|
||||
|
||||
if (mapPos.MapId == MapId.Nullspace)
|
||||
return;
|
||||
|
||||
GetEntitiesInRange(mapPos.MapId, mapPos.Position, range, entities, flags);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -127,7 +127,31 @@ public abstract partial class SharedMapSystem
|
||||
SubscribeLocalEvent<MapGridComponent, MoveEvent>(OnGridMove);
|
||||
}
|
||||
|
||||
public void OnGridBoundsChange(EntityUid uid, MapGridComponent component)
|
||||
/// <summary>
|
||||
/// <see cref="GetGridPosition(Robust.Shared.GameObjects.Entity{Robust.Shared.Physics.Components.PhysicsComponent?},System.Numerics.Vector2,Robust.Shared.Maths.Angle)"/>
|
||||
/// </summary>
|
||||
public Vector2 GetGridPosition(Entity<PhysicsComponent?> grid, Vector2 worldPos, Angle worldRot)
|
||||
{
|
||||
if (!Resolve(grid.Owner, ref grid.Comp))
|
||||
return Vector2.Zero;
|
||||
|
||||
return worldPos + worldRot.RotateVec(grid.Comp.LocalCenter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapgrid's position considering its local physics center.
|
||||
/// </summary>
|
||||
public Vector2 GetGridPosition(Entity<PhysicsComponent?, TransformComponent?> grid)
|
||||
{
|
||||
if (!Resolve(grid.Owner, ref grid.Comp1, ref grid.Comp2))
|
||||
return Vector2.Zero;
|
||||
|
||||
var (worldPos, worldRot) = _transform.GetWorldPositionRotation(grid.Comp2);
|
||||
|
||||
return GetGridPosition((grid.Owner, grid.Comp1), worldPos, worldRot);
|
||||
}
|
||||
|
||||
private void OnGridBoundsChange(EntityUid uid, MapGridComponent component)
|
||||
{
|
||||
// Just MapLoader things.
|
||||
if (component.MapProxy == DynamicTree.Proxy.Free) return;
|
||||
@@ -193,7 +217,7 @@ public abstract partial class SharedMapSystem
|
||||
|
||||
if (xform.ParentUid != xform.MapUid && meta.EntityLifeStage < EntityLifeStage.Terminating && _netManager.IsServer)
|
||||
{
|
||||
Log.Error($"Grid {ToPrettyString(uid, meta)} it not parented to a map. y'all need jesus. {Environment.StackTrace}");
|
||||
Log.Error($"Grid {ToPrettyString(uid, meta)} is not parented to {ToPrettyString(xform._parent)} which is not a map. y'all need jesus. {Environment.StackTrace}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1363,8 +1387,36 @@ public abstract partial class SharedMapSystem
|
||||
|
||||
public EntityCoordinates GridTileToLocal(EntityUid uid, MapGridComponent grid, Vector2i gridTile)
|
||||
{
|
||||
return new(uid,
|
||||
new Vector2(gridTile.X * grid.TileSize + (grid.TileSize / 2f), gridTile.Y * grid.TileSize + (grid.TileSize / 2f)));
|
||||
var position = TileCenterToVector(uid, grid, gridTile);
|
||||
|
||||
return new(uid, position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns a gridtile origin into a Vector2, accounting for tile size.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector2 TileToVector(Entity<MapGridComponent> grid, Vector2i gridTile)
|
||||
{
|
||||
return new Vector2(gridTile.X * grid.Comp.TileSize, gridTile.Y * grid.Comp.TileSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns a gridtile center into a Vector2, accounting for tile size.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector2 TileCenterToVector(EntityUid uid, MapGridComponent grid, Vector2i gridTile)
|
||||
{
|
||||
return TileCenterToVector((uid, grid), gridTile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns a gridtile center into a Vector2, accounting for tile size.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Vector2 TileCenterToVector(Entity<MapGridComponent> grid, Vector2i gridTile)
|
||||
{
|
||||
return new Vector2(gridTile.X * grid.Comp.TileSize, gridTile.Y * grid.Comp.TileSize) + grid.Comp.TileSizeHalfVector;
|
||||
}
|
||||
|
||||
public Vector2 GridTileToWorldPos(EntityUid uid, MapGridComponent grid, Vector2i gridTile)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Robust.Shared.GameObjects;
|
||||
@@ -67,6 +68,16 @@ public abstract partial class SharedTransformSystem
|
||||
return new MapCoordinates(worldPos, xform.MapID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts entity-local coordinates into map terms.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public MapCoordinates ToMapCoordinates(NetCoordinates coordinates)
|
||||
{
|
||||
var eCoords = GetCoordinates(coordinates);
|
||||
return ToMapCoordinates(eCoords);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates EntityCoordinates given an entity and some MapCoordinates.
|
||||
/// </summary>
|
||||
|
||||
@@ -73,6 +73,74 @@ public abstract partial class SharedPhysicsSystem
|
||||
|
||||
#region Collision Masks & Layers
|
||||
|
||||
/// <summary>
|
||||
/// Similar to IsHardCollidable but also checks whether both entities are set to CanCollide
|
||||
/// </summary>
|
||||
public bool IsCurrentlyHardCollidable(Entity<FixturesComponent?, PhysicsComponent?> bodyA, Entity<FixturesComponent?, PhysicsComponent?> bodyB)
|
||||
{
|
||||
if (!_fixturesQuery.Resolve(bodyA, ref bodyA.Comp1, false) ||
|
||||
!_fixturesQuery.Resolve(bodyB, ref bodyB.Comp1, false) ||
|
||||
!PhysicsQuery.Resolve(bodyA, ref bodyA.Comp2, false) ||
|
||||
!PhysicsQuery.Resolve(bodyA, ref bodyB.Comp2, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bodyA.Comp2.CanCollide ||
|
||||
!bodyB.Comp2.CanCollide)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsHardCollidable(bodyA, bodyB);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if both entities are hard-collidable with each other.
|
||||
/// </summary>
|
||||
public bool IsHardCollidable(Entity<FixturesComponent?, PhysicsComponent?> bodyA, Entity<FixturesComponent?, PhysicsComponent?> bodyB)
|
||||
{
|
||||
if (!_fixturesQuery.Resolve(bodyA, ref bodyA.Comp1, false) ||
|
||||
!_fixturesQuery.Resolve(bodyB, ref bodyB.Comp1, false) ||
|
||||
!PhysicsQuery.Resolve(bodyA, ref bodyA.Comp2, false) ||
|
||||
!PhysicsQuery.Resolve(bodyA, ref bodyB.Comp2, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fast check
|
||||
if (!bodyA.Comp2.Hard ||
|
||||
!bodyB.Comp2.Hard ||
|
||||
((bodyA.Comp2.CollisionLayer & bodyB.Comp2.CollisionMask) == 0x0 &&
|
||||
(bodyA.Comp2.CollisionMask & bodyB.Comp2.CollisionLayer) == 0x0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Slow check
|
||||
foreach (var fix in bodyA.Comp1.Fixtures.Values)
|
||||
{
|
||||
if (!fix.Hard)
|
||||
continue;
|
||||
|
||||
foreach (var other in bodyB.Comp1.Fixtures.Values)
|
||||
{
|
||||
if (!other.Hard)
|
||||
continue;
|
||||
|
||||
if ((fix.CollisionLayer & other.CollisionMask) == 0x0 &&
|
||||
(fix.CollisionMask & other.CollisionLayer) == 0x0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddCollisionMask(EntityUid uid, string fixtureId, Fixture fixture, int mask, FixturesComponent? manager = null, PhysicsComponent? body = null)
|
||||
{
|
||||
if ((fixture.CollisionMask & mask) == mask) return;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -197,6 +198,42 @@ namespace Robust.Shared.Player
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes players from the filter.
|
||||
/// </summary>
|
||||
public Filter RemovePlayers(IEnumerable<ICommonSession> players)
|
||||
{
|
||||
foreach (var player in players)
|
||||
_recipients.Remove(player);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes players from the filter.
|
||||
/// </summary>
|
||||
public Filter RemovePlayers(params ICommonSession[] players) => RemovePlayers(players);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a single player from the filter, specified by the entity to which they are attached.
|
||||
/// </summary>
|
||||
public Filter RemovePlayerByAttachedEntity(EntityUid uid)
|
||||
{
|
||||
return RemoveWhereAttachedEntity(e => e == uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes players from the filter, specified by the entities to which they are attached.
|
||||
/// </summary>
|
||||
public Filter RemovePlayersByAttachedEntity(IEnumerable<EntityUid> uids)
|
||||
{
|
||||
return RemoveWhereAttachedEntity(e => uids.Contains(e));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes players from the filter, specified by the entities to which they are attached.
|
||||
/// </summary>
|
||||
public Filter RemovePlayersByAttachedEntity(params EntityUid[] uids) => RemovePlayersByAttachedEntity(uids);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all players from the filter that match a predicate.
|
||||
/// </summary>
|
||||
|
||||
@@ -108,6 +108,12 @@ public interface IPrototypeManager
|
||||
/// <inheritdoc cref="HasIndex{T}(string)"/>
|
||||
bool HasIndex<T>(ProtoId<T> id) where T : class, IPrototype;
|
||||
|
||||
/// <inheritdoc cref="HasIndex{T}(string)"/>
|
||||
bool HasIndex(EntProtoId? id);
|
||||
|
||||
/// <inheritdoc cref="HasIndex{T}(string)"/>
|
||||
bool HasIndex<T>(ProtoId<T>? id) where T : class, IPrototype;
|
||||
|
||||
bool TryIndex<T>(string id, [NotNullWhen(true)] out T? prototype) where T : class, IPrototype;
|
||||
bool TryIndex(Type kind, string id, [NotNullWhen(true)] out IPrototype? prototype);
|
||||
|
||||
@@ -130,6 +136,12 @@ public interface IPrototypeManager
|
||||
/// <inheritdoc cref="TryIndex{T}(string, out T)"/>
|
||||
bool TryIndex<T>(ProtoId<T> id, [NotNullWhen(true)] out T? prototype) where T : class, IPrototype;
|
||||
|
||||
/// <inheritdoc cref="TryIndex{T}(string, out T)"/>
|
||||
bool TryIndex(EntProtoId? id, [NotNullWhen(true)] out EntityPrototype? prototype);
|
||||
|
||||
/// <inheritdoc cref="TryIndex{T}(string, out T)"/>
|
||||
bool TryIndex<T>(ProtoId<T>? id, [NotNullWhen(true)] out T? prototype) where T : class, IPrototype;
|
||||
|
||||
bool HasMapping<T>(string id);
|
||||
bool TryGetMapping(Type kind, string id, [NotNullWhen(true)] out MappingDataNode? mappings);
|
||||
|
||||
|
||||
@@ -644,6 +644,24 @@ namespace Robust.Shared.Prototypes
|
||||
return HasIndex<T>(id.Id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasIndex(EntProtoId? id)
|
||||
{
|
||||
if (id == null)
|
||||
return false;
|
||||
|
||||
return HasIndex(id.Value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasIndex<T>(ProtoId<T>? id) where T : class, IPrototype
|
||||
{
|
||||
if (id == null)
|
||||
return false;
|
||||
|
||||
return HasIndex(id.Value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryIndex<T>(string id, [NotNullWhen(true)] out T? prototype) where T : class, IPrototype
|
||||
{
|
||||
@@ -675,6 +693,30 @@ namespace Robust.Shared.Prototypes
|
||||
return TryIndex(id.Id, out prototype);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryIndex(EntProtoId? id, [NotNullWhen(true)] out EntityPrototype? prototype)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
prototype = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TryIndex(id.Value, out prototype);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryIndex<T>(ProtoId<T>? id, [NotNullWhen(true)] out T? prototype) where T : class, IPrototype
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
prototype = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TryIndex(id.Value, out prototype);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasMapping<T>(string id)
|
||||
{
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
using System;
|
||||
namespace Robust.Shared.Serialization;
|
||||
|
||||
namespace Robust.Shared.Serialization
|
||||
/// <summary>
|
||||
/// Provides a method that gets executed after deserialization is complete and a method that gets executed before serialization
|
||||
/// </summary>
|
||||
[RequiresExplicitImplementation]
|
||||
public interface ISerializationHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a method that gets executed after deserialization is complete and a method that gets executed before serialization
|
||||
/// Gets executed after deserialization is complete
|
||||
/// </summary>
|
||||
[RequiresExplicitImplementation]
|
||||
[Obsolete($"Avoid using ISerializationHooks in favour of (Custom)TypeSerializers or ComponentInit-Events.")]
|
||||
public interface ISerializationHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets executed after deserialization is complete
|
||||
/// </summary>
|
||||
void AfterDeserialization() {}
|
||||
}
|
||||
void AfterDeserialization() {}
|
||||
}
|
||||
|
||||
@@ -57,16 +57,16 @@ internal sealed class ParallelManager : IParallelManagerInternal
|
||||
// This lets us avoid re-allocating the ManualResetEventSlims constantly when we just need a way to signal job completion.
|
||||
|
||||
private readonly ObjectPool<InternalJob> _jobPool =
|
||||
new DefaultObjectPool<InternalJob>(new DefaultPooledObjectPolicy<InternalJob>(), 256);
|
||||
new DefaultObjectPool<InternalJob>(new DefaultPooledObjectPolicy<InternalJob>(), 1024);
|
||||
|
||||
private readonly ObjectPool<InternalParallelJob> _parallelPool =
|
||||
new DefaultObjectPool<InternalParallelJob>(new DefaultPooledObjectPolicy<InternalParallelJob>(), 256);
|
||||
new DefaultObjectPool<InternalParallelJob>(new DefaultPooledObjectPolicy<InternalParallelJob>(), 1024);
|
||||
|
||||
/// <summary>
|
||||
/// Used internally for Parallel jobs, for external callers it gets garbage collected.
|
||||
/// </summary>
|
||||
private readonly ObjectPool<ParallelTracker> _trackerPool =
|
||||
new DefaultObjectPool<ParallelTracker>(new DefaultPooledObjectPolicy<ParallelTracker>());
|
||||
new DefaultObjectPool<ParallelTracker>(new DefaultPooledObjectPolicy<ParallelTracker>(), 1024);
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
@@ -8,9 +8,27 @@ namespace Robust.Shared.Utility
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures that the specified array has the specified length.
|
||||
/// </summary>
|
||||
public static void EnsureLength<T>(ref T[] array, int length)
|
||||
{
|
||||
if (array.Length > length)
|
||||
return;
|
||||
|
||||
Array.Resize(ref array, length);
|
||||
}
|
||||
|
||||
public static IList<T> Clone<T>(this IList<T> listToClone) where T : ICloneable
|
||||
{
|
||||
return listToClone.Select(item => (T)item.Clone()).ToList();
|
||||
var clone = new List<T>(listToClone.Count);
|
||||
|
||||
foreach (var value in listToClone)
|
||||
{
|
||||
clone.Add((T) value.Clone());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -35,6 +35,15 @@ public sealed partial class FormattedMessage
|
||||
_nodes.AddRange(ParseSafe(markup));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Same as <see cref="AddMarkup"/> but adds a newline too.
|
||||
/// </summary>
|
||||
public void PushMarkup(string markup)
|
||||
{
|
||||
AddMarkup(markup);
|
||||
PushNewline();
|
||||
}
|
||||
|
||||
// > wtf I love parser combinators now
|
||||
// - PJB 13 Oct 2019
|
||||
// this tbh - Julian 26 Jan 2023
|
||||
|
||||
Reference in New Issue
Block a user