"use strict";

module.exports = function(ecs, data) {
	ecs.addEach(function(entity, elapsed) { // eslint-disable-line no-unused-vars
		var parent = data.entities.entities[entity.match.id];
		if (parent === undefined) {
			return;
		}

		entity.position.x = parent.position.x + entity.match.offsetX;
		entity.position.y = parent.position.y + entity.match.offsetY;
	}, ["position", "match"]);
};

"use strict";

module.exports = function(ecs, data) {
	data.entities.registerSearch("matchParent", ["position", "match"]);
	ecs.addEach(function(entity, elapsed) { // eslint-disable-line no-unused-vars
		var match = data.entities.get(entity, "match");

		var parentPosition = data.entities.get(match.id, "position");
		if (parentPosition === undefined) {
			return;
		}

		data.entities.set(entity, "position", {
			x: parentPosition.x + match.offsetX,
			y: parentPosition.y + match.offsetY
		});
	}, "matchParent");
};

Update matchParent to new ecs
Update matchParent to new ecs
