Răsfoiți Sursa

Prefab: makeInstanceRec returns context, add visitChildren

trethaller 7 ani în urmă
părinte
comite
f19051425e
1 a modificat fișierele cu 10 adăugiri și 2 ștergeri
  1. 10 2
      hxd/prefab/Prefab.hx

+ 10 - 2
hxd/prefab/Prefab.hx

@@ -143,9 +143,9 @@ class Prefab {
 		return p;
 	}
 
-	public function makeInstanceRec( ctx : Context ) {
+	public function makeInstanceRec( ctx : Context ) : Context {
 		if(!enabled)
-			return;
+			return ctx;
 		if( ctx == null ) {
 			ctx = new Context();
 			ctx.init();
@@ -153,6 +153,7 @@ class Prefab {
 		ctx = makeInstance(ctx);
 		for( c in children )
 			c.makeInstanceRec(ctx);
+		return ctx;
 	}
 
 	#if castle
@@ -232,6 +233,13 @@ class Prefab {
 		return arr;
 	}
 
+	public function visitChildren(func: hide.prefab.Prefab->Bool) {
+		for(c in children) {
+			if(func(c))
+				c.visitChildren(func);
+		}
+	}
+
 	public function getParent<T:Prefab>( c : Class<T> ) : Null<T> {
 		var p = parent;
 		while(p != null) {