// Connect to DF, fetch initial data, start things running void ConnectAndInit() { blockRequest = new RemoteFortressReader.BlockRequest(); blockRequest.blocks_needed = BlocksToFetch; pendingBlocks = new Util.UniqueQueue <DFCoord, RemoteFortressReader.MapBlock>(); networkClient = new DFHack.RemoteClient(dfNetworkOut); bool success = networkClient.connect(); if (!success) { networkClient.disconnect(); networkClient = null; throw new UnityException("DF Connection Failure"); } BindMethods(); FetchUnchangingInfo(); networkClient.suspend_game(); viewInfoCall.execute(null, out _netViewInfo); unitListCall.execute(null, out _netUnitList); worldMapCall.execute(null, out _netWorldMap); regionMapCall.execute(null, out _netRegionMaps); networkClient.resume_game(); mapResetCall.execute(); InitStatics(); foreach (System.Action callback in connectionCallbacks) { callback.Invoke(); } connectionCallbacks.Clear(); connectionMode = ConnectionMode.GetConnectionMode(this, RunOnAlternateThread); }
protected readonly Stack <MapDataStore> recycledBlocks; // Object pool! protected BlockMesher() { // Make queues requestQueue = new Util.UniqueQueue <DFCoord, Request>(); recycledBlocks = new Stack <MapDataStore>(); resultQueue = new Queue <Result>(); GC.Collect(); //force a garbage collect after initial load. }
protected readonly Stack <MapDataStore> recycledBlocks; // Object pool! protected BlockMesher() { // Make queues requestQueue = new Util.UniqueQueue <DFCoord, Request>(); recycledBlocks = new Stack <MapDataStore>(); resultQueue = new Queue <Result>(); // Load materials materials = new Dictionary <MatPairStruct, MaterialDefinition>(); foreach (MaterialDefinition material in DFConnection.Instance.NetMaterialList.material_list) { materials[material.mat_pair] = material; } System.GC.Collect(); //force a garbage collect after initial load. }
protected readonly Stack <MapDataStore> recycledBlocks; // Object pool! protected BlockMesher() { // Make queues requestQueue = new Util.UniqueQueue <DFCoord, Request>(); recycledBlocks = new Stack <MapDataStore>(); resultQueue = new Queue <Result>(); // Load meshes contentLoader = new ContentLoader(); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); contentLoader.ParseContentIndexFile(Application.streamingAssetsPath + "/index.txt"); contentLoader.FinalizeTextureAtlases(); watch.Stop(); Debug.Log("Took a total of " + watch.ElapsedMilliseconds + "ms to load all XML files."); // Load materials materials = new Dictionary <MatPairStruct, RemoteFortressReader.MaterialDefinition>(); foreach (RemoteFortressReader.MaterialDefinition material in DFConnection.Instance.NetMaterialList.material_list) { materials[material.mat_pair] = material; } }