Macros.PopulateMacros C# (CSharp) Method

PopulateMacros() public method

public PopulateMacros ( ) : void
return void
    public void PopulateMacros()
    {
        /* agh i hate this hack so much */
        // needs to be done in CLOSE predicate
        // how do you reason satisfaction conditions on a predicate you sub in?
        ObjectSelector objSelector = GameObject.Find ("BlocksWorld").GetComponent<ObjectSelector> ();
        GameObject mug = GameObject.Find ("mug");
        GameObject table = GameObject.Find ("square_table");

        if (table != null) {
            if (mug != null) {
                GameObject mugInterior = mug.transform.Find ("mug*/cup/interior").gameObject;

                if (mugInterior != null) {
                    foreach (Voxeme voxeme in objSelector.allVoxemes) {
                        if (voxeme.gameObject.activeInHierarchy) {
                            if ((voxeme.gameObject != mug) && (voxeme.gameObject != table)) {
                                if ((Helper.GetObjectWorldSize (voxeme.gameObject).size.x >= Helper.GetObjectWorldSize (mugInterior).size.x) &&
                                   (Helper.GetObjectWorldSize (voxeme.gameObject).size.z >= Helper.GetObjectWorldSize (mugInterior).size.z)) {
                                    lids.Add (voxeme.gameObject);
                                    lids = lids.OrderBy (o => (Helper.GetObjectWorldSize (o).size.x +
                                        Helper.GetObjectWorldSize (o).size.z) * Helper.GetObjectWorldSize (o).size.y).ToList ();
                                }
                            }
                        }
                    }

                    if (lids.Count > 0) {
                        commandMacros.Add ("close(mug)", string.Format ("put({0},on(mug))", lids [0].name));
                    }
                    else {
                        commandMacros.Add ("close(mug)", "flip(mug)");
                    }
                }
            }
        }

        commandMacros.Add ("stack(blocks)", "put(block1,on(block3));put(block2,on(block1));bind(block1,block2,block3,as(\"stack\"))");
        commandMacros.Add ("stack(apple,plate,mug)", "put(apple,on(plate));put(plate,on(mug))");
        commandMacros.Add ("build(staircase)", "put(green(block),left(black(block)));put(red(block),right(black(block)));put(yellow(block),on(red(block)));put(blue(block),on(black(block)));put(brown(block),on(yellow(block)))");
        commandMacros.Add ("build(pyramid)", "put(block1,left(block3));put(block2,right(block3));put(block4,behind(block3));put(block5,in_front(block3));put(block6,on(block3))");
    }

Usage Example

示例#1
0
            // Use this for initialization
            void Start()
            {
                objSelector = GameObject.Find("VoxWorld").GetComponent <ObjectSelector>();
                Macros macros = GameObject.Find("BehaviorController").GetComponent <Macros>();

                float start_time;
                float end_time;

                start_time = Time.realtimeSinceStartup;
                InitializeVoxemes();
                end_time = Time.realtimeSinceStartup;
                Debug.LogWarning("Initializing took " + (end_time - start_time) + " ... seconds?");

                start_time = Time.realtimeSinceStartup;
                objSelector.InitDisabledObjects();
                macros.PopulateMacros();
                end_time = Time.realtimeSinceStartup;
                Debug.LogWarning("Second step took " + (end_time - start_time) + " ... seconds?");
            }