private void OnInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, InteractUsingEvent args) { if (args.Handled) { return; } if (!surface.IsPlaceable) { return; } if (!args.User.TryGetComponent <SharedHandsComponent>(out var handComponent)) { return; } if (!handComponent.TryDropEntity(args.Used, surface.Owner.Transform.Coordinates)) { return; } if (surface.PlaceCentered) { args.Used.Transform.LocalPosition = args.Target.Transform.LocalPosition + surface.PositionOffset; } else { args.Used.Transform.Coordinates = args.ClickLocation; } args.Handled = true; }
private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args) { if (args.Handled || !args.CanReach) { return; } if (!surface.IsPlaceable) { return; } if (!_handsSystem.TryDrop(args.User, args.Used)) { return; } if (surface.PlaceCentered) { Transform(args.Used).LocalPosition = Transform(uid).LocalPosition + surface.PositionOffset; } else { Transform(args.Used).Coordinates = args.ClickLocation; } args.Handled = true; }
private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args) { if (args.Handled || !args.CanReach) { return; } if (!surface.IsPlaceable) { return; } // 99% of the time they want to dump the stuff inside on the table, they can manually place with q if they really need to. // Just causes prediction CBT otherwise. if (HasComp <DumpableComponent>(args.Used)) { return; } if (!_handsSystem.TryDrop(args.User, args.Used)) { return; } if (surface.PlaceCentered) { Transform(args.Used).LocalPosition = Transform(uid).LocalPosition + surface.PositionOffset; } else { Transform(args.Used).Coordinates = args.ClickLocation; } args.Handled = true; }
private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args) { if (args.Handled || !args.CanReach) { return; } if (!surface.IsPlaceable) { return; } if (!EntityManager.TryGetComponent <SharedHandsComponent?>(args.User, out var handComponent)) { return; } if (!handComponent.TryDropEntity(args.Used, EntityManager.GetComponent <TransformComponent>(surface.Owner).Coordinates)) { return; } if (surface.PlaceCentered) { EntityManager.GetComponent <TransformComponent>(args.Used).LocalPosition = EntityManager.GetComponent <TransformComponent>(uid).LocalPosition + surface.PositionOffset; } else { EntityManager.GetComponent <TransformComponent>(args.Used).Coordinates = args.ClickLocation; } args.Handled = true; }
private void OnHandleState(EntityUid uid, PlaceableSurfaceComponent component, ref ComponentHandleState args) { if (args.Current is not PlaceableSurfaceComponentState state) { return; } component.IsPlaceable = state.IsPlaceable; component.PlaceCentered = state.PlaceCentered; component.PositionOffset = state.PositionOffset; }
public void SetPositionOffset(PlaceableSurfaceComponent surface, Vector2 offset) { surface.PositionOffset = offset; surface.Dirty(); }
public void SetPlaceCentered(PlaceableSurfaceComponent surface, bool placeCentered) { surface.PlaceCentered = placeCentered; surface.Dirty(); }
public void SetPlaceable(PlaceableSurfaceComponent surface, bool isPlaceable) { surface.IsPlaceable = isPlaceable; surface.Dirty(); }
private void OnGetState(EntityUid uid, PlaceableSurfaceComponent component, ref ComponentGetState args) { args.State = new PlaceableSurfaceComponentState(component.IsPlaceable, component.PlaceCentered, component.PositionOffset); }