Quellcode durchsuchen

Event3D: fix location expecting Event instead of IEvent

Yuxiao Mao vor 5 Monaten
Ursprung
Commit
b02b5dd9a9
5 geänderte Dateien mit 18 neuen und 23 gelöschten Zeilen
  1. 7 19
      hide/view/FXEditor.hx
  2. 1 0
      hrt/prefab/fx/Event.hx
  3. 2 2
      hrt/prefab/fx/FX.hx
  4. 2 2
      hrt/prefab/fx/FX2D.hx
  5. 6 0
      hrt/prefab/fx/SubFX.hx

+ 7 - 19
hide/view/FXEditor.hx

@@ -1083,16 +1083,12 @@ class FXEditor extends hide.view.FileView {
 			}
 
 			var events: Array<IEvent> = [];
-			for (e in section.root.flatten(Event)) {
-				events.push(e);
-				allElements.push(e);
-			}
-			for (e in section.root.flatten(hrt.prefab.fx.SubFX)) {
-				events.push(e);
-				allElements.push(e);
+			for (e in section.root.findAll(o -> Std.isOfType(o, IEvent))) {
+				events.push(cast (e, IEvent));
+				allElements.push(cast (e, IEvent));
 			}
 
-			if (section.root is Event || section.root is hrt.prefab.fx.SubFX) {
+			if (section.root is IEvent) {
 				events.push(cast section.root);
 				allElements.push(cast section.root);
 			}
@@ -1300,22 +1296,14 @@ class FXEditor extends hide.view.FileView {
 					}
 				}
 
-				if (child.flatten(Event).length > 0) {
-					if (child is Event) {
-						var e = Std.downcast(child, Event);
+				if (child.find(o -> Std.isOfType(o, IEvent)) != null) {
+					if (child is IEvent) {
+						var e = cast(child, IEvent);
 						section.events.push(e);
 						eventsToDraw.push(e);
 					}
 				}
 
-				if (child.flatten(hrt.prefab.fx.SubFX).length > 0) {
-					if (child is hrt.prefab.fx.SubFX) {
-						var s = Std.downcast(child, hrt.prefab.fx.SubFX);
-						section.events.push(s);
-						eventsToDraw.push(s);
-					}
-				}
-
 			}
 
 			return section;

+ 1 - 0
hrt/prefab/fx/Event.hx

@@ -16,6 +16,7 @@ interface IEvent {
 	var selected : Bool;
 	function getEventPrefab() : hrt.prefab.Prefab;
 	function getDuration() : Float;
+	function prepare() : EventInstance;
 	#if editor
 	function setDuration(duration: Float) : Void;
 	function getDisplayInfo(ctx: hide.prefab.EditContext) : { label: String, ?loop: Bool };

+ 2 - 2
hrt/prefab/fx/FX.hx

@@ -387,8 +387,8 @@ class FXAnimation extends h3d.scene.Object {
 		if (elt == null || @:privateAccess !elt.shouldBeInstanciated())
 			return out;
 
-		var asEvent = elt.to(Event);
-		if (asEvent != null) {
+		if( Std.isOfType(elt, IEvent) ) {
+			var asEvent = cast(elt, IEvent);
 			var eventObj = asEvent.prepare();
 			if(eventObj != null) {
 				if(out == null) out = [];

+ 2 - 2
hrt/prefab/fx/FX2D.hx

@@ -65,8 +65,8 @@ class FX2DAnimation extends h2d.Object {
 		if (elt == null || @:privateAccess !elt.shouldBeInstanciated())
 			return out;
 
-		var asEvent = elt.to(Event);
-		if (asEvent != null) {
+		if( Std.isOfType(elt, IEvent) ) {
+			var asEvent = cast(elt, IEvent);
 			var eventObj = asEvent.prepare();
 			if(eventObj != null) {
 				if(out == null) out = [];

+ 6 - 0
hrt/prefab/fx/SubFX.hx

@@ -58,6 +58,12 @@ class SubFX extends Reference implements hrt.prefab.fx.Event.IEvent{
 
 	public function getEventPrefab() { return this; }
 
+	public function prepare() : Event.EventInstance {
+		return {
+			evt: this
+		};
+	}
+
 	#if editor
 
 	override function edit( ctx : hide.prefab.EditContext ) {