private void OnCollisionEnter2D(Collision2D collision) { StickyComponent stickTarget = collision.gameObject.GetComponent <StickyComponent>(); if (stickTarget != null) { GetStuck(stickTarget.stickContainer, collision.contacts[0].point); } }
private void OnAfterInteract(EntityUid uid, StickyComponent component, AfterInteractEvent args) { if (args.Handled || !args.CanReach || args.Target == null) { return; } // try stick object to a clicked target entity args.Handled = StartSticking(uid, args.User, args.Target.Value, component); }
private void AddUnstickVerb(EntityUid uid, StickyComponent component, GetVerbsEvent <Verb> args) { if (component.StuckTo == null || !component.CanUnstick || !args.CanInteract || args.Hands == null) { return; } // we can't use args.CanAccess, because it stuck in another container // we also need to ignore entity that it stuck to var inRange = _interactionSystem.InRangeUnobstructed(uid, args.User, predicate: entity => component.StuckTo == entity); if (!inRange) { return; } args.Verbs.Add(new Verb { Text = Loc.GetString("comp-sticky-unstick-verb-text"), IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png", Act = () => StartUnsticking(uid, args.User, component) }); }