/////////////////////////////////////////////////////////////////////
| 615 | |
| 616 | ////////////////////////////////////////////////////////////////////////// |
| 617 | void CEntityScript::VarToScriptObject( IVariable *var,IScriptObject *obj ) |
| 618 | { |
| 619 | assert(var); |
| 620 | |
| 621 | if (var->GetType() == IVariable::ARRAY) |
| 622 | { |
| 623 | int type = obj->GetValueType( var->GetName() ); |
| 624 | if (type != svtObject) |
| 625 | return; |
| 626 | |
| 627 | IScriptSystem *scriptSystem = GetIEditor()->GetSystem()->GetIScriptSystem(); |
| 628 | _SmartScriptObject pTableObj( scriptSystem,true ); |
| 629 | if (obj->GetValue( var->GetName(),*pTableObj )) |
| 630 | { |
| 631 | for (int i = 0; i < var->NumChildVars(); i++) |
| 632 | { |
| 633 | IVariable *child = var->GetChildVar(i); |
| 634 | VarToScriptObject( child,pTableObj ); |
| 635 | } |
| 636 | } |
| 637 | return; |
| 638 | } |
| 639 | |
| 640 | const char *name = var->GetName(); |
| 641 | int type = obj->GetValueType( name ); |
| 642 | |
| 643 | if (type == svtString) |
| 644 | { |
| 645 | CString value; |
| 646 | var->Get(value); |
| 647 | obj->SetValue( name,value ); |
| 648 | } |
| 649 | else if (type == svtNumber) |
| 650 | { |
| 651 | float val = 0; |
| 652 | var->Get(val); |
| 653 | obj->SetValue( name,val ); |
| 654 | } |
| 655 | else if (type == svtObject) |
| 656 | { |
| 657 | IScriptSystem *scriptSystem = GetIEditor()->GetSystem()->GetIScriptSystem(); |
| 658 | // Probably Color/Vector. |
| 659 | _SmartScriptObject pTable( scriptSystem,true ); |
| 660 | if (obj->GetValue( name,pTable )) |
| 661 | { |
| 662 | if (var->GetType() == IVariable::VECTOR) |
| 663 | { |
| 664 | Vec3 vec; |
| 665 | var->Get(vec); |
| 666 | |
| 667 | float temp; |
| 668 | if (pTable->GetValue( "x",temp )) |
| 669 | { |
| 670 | // Named vector. |
| 671 | pTable->SetValue( "x",vec.x ); |
| 672 | pTable->SetValue( "y",vec.y ); |
| 673 | pTable->SetValue( "z",vec.z ); |
| 674 | } |
nothing calls this directly
no test coverage detected