mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
* Allow component trees to be disabled * forgot * I'm pretty sure this wasn't working as intended * also outdated * reduce branches in QueueTreeUpdate * remove update hashset * try fix * Use Entity<T> and add ray overloads * Move InRangeUnoccluded to engine * reduce code duplication * move _initialized check * release notes
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Robust.Shared.Physics;
|
|
|
|
/// <summary>
|
|
/// This is a data struct for use with a <see cref="DynamicTree"/>. This stores both some generic component and the
|
|
/// entity's transform component. This is being used in place of a simple tuple so that the IEquatable can be
|
|
/// overriden, such that we can remove entries without needing to fetch the transform component of a possible
|
|
/// deleted entity.
|
|
/// </summary>
|
|
public readonly struct ComponentTreeEntry<T> : IEquatable<ComponentTreeEntry<T>>, IComparable<ComponentTreeEntry<T>> where T : IComponent
|
|
{
|
|
public T Component { get; init; }
|
|
public TransformComponent Transform { get; init; }
|
|
public EntityUid Uid => Component.Owner;
|
|
|
|
public int CompareTo(ComponentTreeEntry<T> other)
|
|
{
|
|
return Uid.CompareTo(other.Uid);
|
|
}
|
|
|
|
public bool Equals(ComponentTreeEntry<T> other)
|
|
{
|
|
return Uid.Equals(other.Uid);
|
|
}
|
|
|
|
public readonly void Deconstruct(out T component, out TransformComponent xform)
|
|
{
|
|
component = Component;
|
|
xform = Transform;
|
|
}
|
|
|
|
public static implicit operator Entity<T, TransformComponent>(ComponentTreeEntry<T> entry)
|
|
{
|
|
return new(entry.Uid, entry.Component, entry.Transform);
|
|
}
|
|
|
|
public static implicit operator ComponentTreeEntry<T>((T, TransformComponent) tuple)
|
|
{
|
|
return new ComponentTreeEntry<T>()
|
|
{
|
|
Component = tuple.Item1,
|
|
Transform = tuple.Item2
|
|
};
|
|
}
|
|
}
|