You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

23 lines
473 B

  1. module.exports = async (cpnSocial, targetName) => {
  2. const { obj } = cpnSocial;
  3. const { instance: { objects, physics }, syncer } = obj;
  4. if (typeof(targetName) !== 'string')
  5. return;
  6. const target = objects.find(o => o.name?.toLowerCase().includes(targetName.toLowerCase()));
  7. if (!target)
  8. return;
  9. physics.removeObject(obj, obj.x, obj.y);
  10. obj.x = target.x;
  11. obj.y = target.y;
  12. physics.addObject(obj, obj.x, obj.y);
  13. syncer.o.x = obj.x;
  14. syncer.o.y = obj.y;
  15. };