fix NetEntity datafield in JointVisualsComponent (#39987)
fix netentity datafield
This commit is contained in:
@@ -36,7 +36,7 @@ public sealed class JointVisualsOverlay : Overlay
|
|||||||
if (xform.MapID != args.MapId)
|
if (xform.MapID != args.MapId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var other = _entManager.GetEntity(visuals.Target);
|
var other = visuals.Target;
|
||||||
|
|
||||||
if (!xformQuery.TryGetComponent(other, out var otherXform))
|
if (!xformQuery.TryGetComponent(other, out var otherXform))
|
||||||
continue;
|
continue;
|
||||||
@@ -45,7 +45,7 @@ public sealed class JointVisualsOverlay : Overlay
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var texture = spriteSystem.Frame0(visuals.Sprite);
|
var texture = spriteSystem.Frame0(visuals.Sprite);
|
||||||
var width = texture.Width / (float) EyeManager.PixelsPerMeter;
|
var width = texture.Width / (float)EyeManager.PixelsPerMeter;
|
||||||
|
|
||||||
var coordsA = xform.Coordinates;
|
var coordsA = xform.Coordinates;
|
||||||
var coordsB = otherXform.Coordinates;
|
var coordsB = otherXform.Coordinates;
|
||||||
@@ -58,7 +58,7 @@ public sealed class JointVisualsOverlay : Overlay
|
|||||||
|
|
||||||
var posA = xformSystem.ToMapCoordinates(coordsA).Position;
|
var posA = xformSystem.ToMapCoordinates(coordsA).Position;
|
||||||
var posB = xformSystem.ToMapCoordinates(coordsB).Position;
|
var posB = xformSystem.ToMapCoordinates(coordsB).Position;
|
||||||
var diff = (posB - posA);
|
var diff = posB - posA;
|
||||||
var length = diff.Length();
|
var length = diff.Length();
|
||||||
|
|
||||||
var midPoint = diff / 2f + posA;
|
var midPoint = diff / 2f + posA;
|
||||||
|
|||||||
@@ -10,21 +10,30 @@ namespace Content.Shared.Physics;
|
|||||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class JointVisualsComponent : Component
|
public sealed partial class JointVisualsComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("sprite", required: true), AutoNetworkedField]
|
/// <summary>
|
||||||
|
/// The sprite to use for the line.
|
||||||
|
/// </summary>
|
||||||
|
[DataField(required: true), AutoNetworkedField]
|
||||||
public SpriteSpecifier Sprite = default!;
|
public SpriteSpecifier Sprite = default!;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("target"), AutoNetworkedField]
|
/// <summary>
|
||||||
public NetEntity? Target;
|
/// The line is drawn between this target and the entity owning the component.
|
||||||
|
/// </summary>
|
||||||
|
/// <summary>
|
||||||
|
/// TODO: WeakEntityReference.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public EntityUid? Target;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Offset from Body A.
|
/// Offset from Body A.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("offsetA"), AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public Vector2 OffsetA;
|
public Vector2 OffsetA;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Offset from Body B.
|
/// Offset from Body B.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("offsetB"), AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public Vector2 OffsetB;
|
public Vector2 OffsetB;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
|||||||
var visuals = EnsureComp<JointVisualsComponent>(shotUid.Value);
|
var visuals = EnsureComp<JointVisualsComponent>(shotUid.Value);
|
||||||
visuals.Sprite = component.RopeSprite;
|
visuals.Sprite = component.RopeSprite;
|
||||||
visuals.OffsetA = new Vector2(0f, 0.5f);
|
visuals.OffsetA = new Vector2(0f, 0.5f);
|
||||||
visuals.Target = GetNetEntity(uid);
|
visuals.Target = uid;
|
||||||
Dirty(shotUid.Value, visuals);
|
Dirty(shotUid.Value, visuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user