Optimise storage a quadrillion times (#37638)
* Optimise storage a quadrillion times * How sweaty can we get * Add fast angle checks * Fix chunk indices * Optimise the refresh method Helps on client a lot as the clientside is suboptimal atm. * Better name * wawawewa * Add single-angle path * Okay FINE rider
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Shared.Examine;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -206,15 +207,21 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
public IReadOnlyList<Box2i> GetAdjustedItemShape(Entity<ItemComponent?> entity, Angle rotation, Vector2i position)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp))
|
||||
return new Box2i[] { };
|
||||
return [];
|
||||
|
||||
var adjustedShapes = new List<Box2i>();
|
||||
GetAdjustedItemShape(adjustedShapes, entity, rotation, position);
|
||||
return adjustedShapes;
|
||||
}
|
||||
|
||||
public void GetAdjustedItemShape(List<Box2i> adjustedShapes, Entity<ItemComponent?> entity, Angle rotation, Vector2i position)
|
||||
{
|
||||
var shapes = GetItemShape(entity);
|
||||
var boundingShape = shapes.GetBoundingBox();
|
||||
var boundingCenter = ((Box2) boundingShape).Center;
|
||||
var matty = Matrix3Helpers.CreateTransform(boundingCenter, rotation);
|
||||
var drift = boundingShape.BottomLeft - matty.TransformBox(boundingShape).BottomLeft;
|
||||
|
||||
var adjustedShapes = new List<Box2i>();
|
||||
foreach (var shape in shapes)
|
||||
{
|
||||
var transformed = matty.TransformBox(shape).Translated(drift);
|
||||
@@ -223,8 +230,6 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
|
||||
adjustedShapes.Add(translated);
|
||||
}
|
||||
|
||||
return adjustedShapes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user