Beispiel #1
0
void Polygon2D::_set_bones(const Array &p_bones) {

	ERR_FAIL_COND(p_bones.size() & 1);
	clear_bones();
	for (int i = 0; i < p_bones.size(); i += 2) {
		add_bone(p_bones[i], p_bones[i + 1]);
	}
}
Beispiel #2
0
bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {

	String path = p_path;

	if (!path.begins_with("bones/"))
		return false;

	int which=path.get_slicec('/',1).to_int();
	String what=path.get_slicec('/',2);


	if (which==bones.size() && what=="name") {

		add_bone(p_value);
		return true;
	}

	ERR_FAIL_INDEX_V( which, bones.size(), false );

	if (what=="parent")
		set_bone_parent(which, p_value );
	else if (what=="rest")
		set_bone_rest(which, p_value);
	else if (what=="enabled")
		set_bone_enabled(which, p_value);
	else if (what=="pose")
		set_bone_pose(which, p_value);
	else if (what=="bound_childs") {
		Array children=p_value;

		if (is_inside_tree()) {
			bones[which].nodes_bound.clear();

			for (int i=0;i<children.size();i++) {

				NodePath path=children[i];
				ERR_CONTINUE( path.operator String()=="" );
				Node *node = get_node(path);
				ERR_CONTINUE(!node);
				bind_child_node_to_bone(which,node);
			}
		}
	} else {
		return false;
	}

	return true;
}