Add new creation method from a visual representation
This commit is contained in:
		
							parent
							
								
									8ade68101b
								
							
						
					
					
						commit
						7f639a6bf4
					
				
					 6 changed files with 72 additions and 16 deletions
				
			
		
							
								
								
									
										26
									
								
								game/unit.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								game/unit.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
#include "unit.h"
 | 
			
		||||
 | 
			
		||||
#include "unitv.h"
 | 
			
		||||
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
std::unique_ptr<CUnit> CUnit::getUnitFromVis( unitVis_c vis )
 | 
			
		||||
{
 | 
			
		||||
	switch( vis )
 | 
			
		||||
	{
 | 
			
		||||
		case '^':
 | 
			
		||||
		case '>':
 | 
			
		||||
		case 'v':
 | 
			
		||||
		case '<':
 | 
			
		||||
		{
 | 
			
		||||
			std::unique_ptr<CUnit> p = std::unique_ptr<CUnit>(new CUnitV);
 | 
			
		||||
			if( (bool)p && p->setFromVisual(vis) )
 | 
			
		||||
			{
 | 
			
		||||
				return std::move(p);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return std::move(std::unique_ptr<CUnit>(nullptr));
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue