Engine Entity Anchoring Changes (#4195)

* Converted all SnapGridPositionChangedEvent subscriptions to AnchorStateChangedEvent.

* Fixes power tests with new anchored requirements.

* Moved AnchorableComponent into construction.
AnchorableComponent now uses Transform.Anchored.

* Fixed bug with nodes, power works again.

* Adds lifetime stages to Component.

* Update Engine to v0.4.70.
This commit is contained in:
Acruid
2021-06-19 19:41:26 -07:00
committed by GitHub
parent 0ab7b3a5d2
commit 15fb554c28
187 changed files with 279 additions and 287 deletions

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -68,6 +68,7 @@ namespace Content.Shared.Actions.Components
protected override void Startup()
{
base.Startup();
foreach (var actionType in InnateActions)
{
Grant(actionType);

View File

@@ -74,7 +74,7 @@ namespace Content.Shared.Body.Components
public SharedBodyPartComponent? CenterPart => CenterSlot?.Part;
public override void Initialize()
protected override void Initialize()
{
base.Initialize();
@@ -99,7 +99,7 @@ namespace Content.Shared.Body.Components
CalculateSpeed();
}
public override void OnRemove()
protected override void OnRemove()
{
foreach (var slot in SlotIds.Values)
{

View File

@@ -116,7 +116,7 @@ namespace Content.Shared.Body.Mechanism
}
}
public override void Initialize()
protected override void Initialize()
{
base.Initialize();

View File

@@ -71,7 +71,7 @@ namespace Content.Shared.Chemistry.Solution.Components
public bool CanRefill => Capabilities.HasCap(SolutionContainerCaps.Refillable);
public bool CanDrain => Capabilities.HasCap(SolutionContainerCaps.Drainable);
public override void Initialize()
protected override void Initialize()
{
base.Initialize();
UpdateAppearance();

View File

@@ -63,7 +63,7 @@ namespace Content.Shared.Damage.Components
return SupportedTypes.Contains(type);
}
public override void Initialize()
protected override void Initialize()
{
base.Initialize();

View File

@@ -28,7 +28,7 @@ namespace Content.Shared.Inventory
[DataField("Template")]
private string _templateName = "HumanInventory"; //stored for serialization purposes
public override void Initialize()
protected override void Initialize()
{
base.Initialize();

View File

@@ -58,7 +58,7 @@ namespace Content.Shared.MobState.State
}
}
public override void OnRemove()
protected override void OnRemove()
{
if (Owner.TryGetComponent(out SharedAlertsComponent? status))
{

View File

@@ -114,7 +114,7 @@ namespace Content.Shared.Movement.Components
public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>(CCVars.GameDiagonalMovement);
/// <inheritdoc />
public override void Initialize()
protected override void Initialize()
{
base.Initialize();
Owner.EnsureComponentWarn<PhysicsComponent>();

View File

@@ -83,7 +83,7 @@ namespace Content.Shared.Movement.Components
}
}
public override void Initialize()
protected override void Initialize()
{
base.Initialize();
if (!Owner.HasComponent<IMoverComponent>())

View File

@@ -10,7 +10,7 @@ namespace Content.Shared.Portal.Components
{
public override string Name => "Portal";
public override void OnAdd()
protected override void OnAdd()
{
base.OnAdd();

View File

@@ -354,7 +354,7 @@ namespace Content.Shared.Pulling.Components
}
}
public override void OnRemove()
protected override void OnRemove()
{
TryStopPull();
MovingTo = null;

View File

@@ -37,7 +37,7 @@ namespace Content.Shared.Pulling.Components
}
}
public override void OnRemove()
protected override void OnRemove()
{
if (Pulling != null &&
Pulling.TryGetComponent(out SharedPullableComponent? pullable))

View File

@@ -54,7 +54,7 @@ namespace Content.Shared.SubFloor
SubscribeLocalEvent<SubFloorHideComponent, ComponentStartup>(OnSubFloorStarted);
SubscribeLocalEvent<SubFloorHideComponent, ComponentShutdown>(OnSubFloorTerminating);
SubscribeLocalEvent<SubFloorHideComponent, SnapGridPositionChangedEvent>(OnSnapGridPositionChanged);
SubscribeLocalEvent<SubFloorHideComponent, AnchorStateChangedEvent>(HandleAnchorChanged);
}
public override void Shutdown()
@@ -75,11 +75,13 @@ namespace Content.Shared.SubFloor
UpdateEntity(uid);
}
private void OnSnapGridPositionChanged(EntityUid uid, SubFloorHideComponent component, SnapGridPositionChangedEvent ev)
private void HandleAnchorChanged(EntityUid uid, SubFloorHideComponent component, AnchorStateChangedEvent args)
{
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
// We do this directly instead of calling UpdateEntity.
if(_mapManager.TryGetGrid(ev.NewGrid, out var grid))
UpdateTile(grid, ev.Position);
if(_mapManager.TryGetGrid(transform.GridID, out var grid))
UpdateTile(grid, grid.TileIndicesFor(transform.Coordinates));
}
private void MapManagerOnTileChanged(object? sender, TileChangedEventArgs e)

View File

@@ -23,7 +23,7 @@ namespace Content.Shared.Tag
public IReadOnlySet<string> Tags => _tags;
public override void Initialize()
protected override void Initialize()
{
base.Initialize();