예제 #1
0
    public static void ResetSimulation(JsonAssembly assembly = null)
    {
        rbs.Clear();

        ConnectionVoxelContainer.RemoveAllConnections();
        CollisionVoxelContainer.RemoveAllGos();

        foreach (KeyValuePair <int, Vector3> pos in savePositions)
        {
            GameObject go = GlobalReferences.FrozenParts[pos.Key];
            go.transform.parent   = null;
            go.transform.position = pos.Value;
            go.transform.rotation = saveRotations[pos.Key];

            Part part = go.GetComponent <Part>();

            CollisionVoxelContainer.StoreGameObject(go);

            foreach (int i in part.ActiveConnections)
            {
                ConnectionVoxelContainer.StoreConnection(part.Connections[i]);
            }
        }

        savePositions.Clear();
        saveRotations.Clear();

        simulationDone = false;
    }
예제 #2
0
    public static void AfterSimulation(TIExportAR exportItem = null, bool export = false)
    {
        ++handlerCallBack;
        if (handlerCallBack >= handlers.Count)
        {
            if (!export)
            {
                ConnectionVoxelContainer.RemoveAllConnections();
                CollisionVoxelContainer.RemoveAllGos();

                foreach (GameObject go in GlobalReferences.FrozenParts.Values)
                {
                    go.transform.parent = null;
                    Part part = go.GetComponent <Part>();

                    CollisionVoxelContainer.StoreGameObject(go);

                    foreach (int i in part.ActiveConnections)
                    {
                        ConnectionVoxelContainer.StoreConnection(part.Connections[i]);
                    }
                }

                for (int i = rbs.Count - 1; i >= 0; --i)
                {
                    MonoBehaviour.Destroy(rbs[i]);
                }

                simulationInProgress = false;
                simulationDone       = false;
            }
            else
            {
                string c = expCount.ToString();
                while (c.Length < countDigits)
                {
                    c = "0" + c;
                }
                SaveLoad.SaveGame(c + "_", true, folder);
            }


            for (int i = handlers.Count - 1; i >= 0; --i)
            {
                MonoBehaviour.Destroy(handlers[i]);
            }
            handlers.Clear();
            handlerCallBack = 0;

            if (export)
            {
                Export(exportItem);
            }
        }
    }
예제 #3
0
    public override void OnEvent(EndSimulation evnt)
    {
        if (!evnt.FromSelf)
        {
            ConnectionVoxelContainer.RemoveAllConnections();
            CollisionVoxelContainer.RemoveAllGos();

            foreach (GameObject go in GlobalReferences.FrozenParts.Values)
            {
                Part part = go.GetComponent <Part>();

                CollisionVoxelContainer.StoreGameObject(go);

                foreach (int i in part.ActiveConnections)
                {
                    ConnectionVoxelContainer.StoreConnection(part.Connections[i]);
                }
            }
        }
        PlacementReferences.Scanning = true;
    }