示例#1
0
 public override void DoWork(WorkData unused)
 {
     if (MySession.Static.Ready)
     {
         MyEntityIdentifier.InEntityCreationBlock = true;
         MyEntityIdentifier.LazyInitPerThreadStorage(0x800);
         int num = 0;
         while (true)
         {
             if (num < this.debrisPieces)
             {
                 MyDebrisBase base2 = this.Context.CreateRandomDebris();
                 if (base2 != null)
                 {
                     float      randomFloat = MyUtils.GetRandomFloat(this.minDeviationAngle, this.maxDeviationAngle);
                     Matrix     matrix      = Matrix.CreateRotationX(MyUtils.GetRandomFloat(this.minDeviationAngle, this.maxDeviationAngle)) * Matrix.CreateRotationY(randomFloat);
                     Vector3    vector      = Vector3.Transform(this.offsetDirection, matrix);
                     DebrisData item        = new DebrisData {
                         Object          = base2,
                         StartPos        = this.sourceWorldPosition + (vector * MyUtils.GetRandomFloat(this.minSourceDistance, this.maxSourceDistance)),
                         InitialVelocity = vector * this.initialSpeed
                     };
                     this.m_pieces.Add(item);
                     num++;
                     continue;
                 }
             }
             MyEntityIdentifier.ClearPerThreadEntities();
             MyEntityIdentifier.InEntityCreationBlock = false;
             return;
         }
     }
 }
示例#2
0
 public void CallCreateGridsFromPrefab(ParallelTasks.WorkData workData)
 {
     try
     {
         MyEntityIdentifier.LazyInitPerThreadStorage(2048);
         MyPrefabManager.Static.CreateGridsFromPrefab(m_results, m_prefabName, m_worldMatrix, m_spawnAtOrigin, m_ignoreMemoryLimits, m_factionId, m_callbacks);
     }
     finally
     {
         m_resultIDs = new List <VRage.ModAPI.IMyEntity>();
         MyEntityIdentifier.GetPerThreadEntities(m_resultIDs);
         MyEntityIdentifier.ClearPerThreadEntities();
         Interlocked.Decrement(ref PendingGrids);
         if (PendingGrids <= 0)
         {
             FinishedProcessingGrids.Set();
         }
     }
 }