PlaceableSurface ECS (#8013)

This commit is contained in:
metalgearsloth
2022-05-08 15:50:31 +10:00
committed by GitHub
parent 0ed3858f47
commit 6edb29f68b
2 changed files with 9 additions and 15 deletions

View File

@@ -14,16 +14,22 @@ namespace Content.Shared.Placeable
base.Initialize();
SubscribeLocalEvent<PlaceableSurfaceComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
SubscribeLocalEvent<PlaceableSurfaceComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<PlaceableSurfaceComponent, ComponentHandleState>(OnHandleState);
}
private void OnGetState(EntityUid uid, PlaceableSurfaceComponent component, ref ComponentGetState args)
{
args.State = new PlaceableSurfaceComponentState(component.IsPlaceable, component.PlaceCentered, component.PositionOffset);
}
public void SetPlaceable(EntityUid uid, bool isPlaceable, PlaceableSurfaceComponent? surface = null)
{
if (!Resolve(uid, ref surface))
return;
surface.IsPlaceable = isPlaceable;
surface.Dirty();
Dirty(surface);
}
public void SetPlaceCentered(EntityUid uid, bool placeCentered, PlaceableSurfaceComponent? surface = null)
@@ -32,7 +38,7 @@ namespace Content.Shared.Placeable
return;
surface.PlaceCentered = placeCentered;
surface.Dirty();
Dirty(surface);
}
public void SetPositionOffset(EntityUid uid, Vector2 offset, PlaceableSurfaceComponent? surface = null)
@@ -41,7 +47,7 @@ namespace Content.Shared.Placeable
return;
surface.PositionOffset = offset;
surface.Dirty();
Dirty(surface);
}
private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args)