MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / VarToScriptObject

Method VarToScriptObject

Editor/Objects/EntityScript.cpp:617–685  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

615
616//////////////////////////////////////////////////////////////////////////
617void 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 }

Callers

nothing calls this directly

Calls 12

GetIEditorFunction · 0.85
SetAtMethod · 0.80
GetTypeMethod · 0.45
GetValueTypeMethod · 0.45
GetNameMethod · 0.45
GetIScriptSystemMethod · 0.45
GetSystemMethod · 0.45
GetValueMethod · 0.45
NumChildVarsMethod · 0.45
GetChildVarMethod · 0.45
GetMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected