forked from LeenkxTeam/LNXSDK
		
	t3du - Set / Get World Nodes
This commit is contained in:
		
							
								
								
									
										40
									
								
								leenkx/Sources/leenkx/logicnode/SetWorldNode.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								leenkx/Sources/leenkx/logicnode/SetWorldNode.hx
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					package leenkx.logicnode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SetWorldNode extends LogicNode {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public function new(tree: LogicTree) {
 | 
				
			||||||
 | 
							super(tree);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						override function run(from: Int) {
 | 
				
			||||||
 | 
							var world: String = inputs[1].get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (world != null){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//check if world shader data exists
 | 
				
			||||||
 | 
								var file: String = 'World_'+world+'_data';
 | 
				
			||||||
 | 
								#if lnx_json
 | 
				
			||||||
 | 
									file += ".json";
 | 
				
			||||||
 | 
								#elseif lnx_compress
 | 
				
			||||||
 | 
									file += ".lz4";
 | 
				
			||||||
 | 
								#else
 | 
				
			||||||
 | 
									file += '.lnx';
 | 
				
			||||||
 | 
								#end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								var exists: Bool = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								iron.data.Data.getBlob(file, function(b: kha.Blob) {
 | 
				
			||||||
 | 
									if (b != null) exists = true;
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								assert(Error, exists == true, "World must be either associated to a scene or have fake user");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								iron.Scene.active.raw.world_ref = world;
 | 
				
			||||||
 | 
								var npath = leenkx.renderpath.RenderPathCreator.get();
 | 
				
			||||||
 | 
								npath.loadShader("shader_datas/World_" + world + "/World_" + world);
 | 
				
			||||||
 | 
								iron.RenderPath.setActive(npath);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							runOutput(0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user