public void DisableGatheredItems()
        {
            ProfilerShort.Begin("PlanetEnvironment::DisableItemsOverlappingBlocks()");
            foreach (var sector in m_itemsToDisable)
            {
                for (int i = 0; i < sector.Value.Count; ++i)
                {
                    sector.Key.EnableItem(sector.Value[i], false);
                }
            }

            m_itemsToDisable.Clear();

            m_itemDisableJobRunning = false;
            ProfilerShort.End();
        }
Ejemplo n.º 2
0
        internal void Clear()
        {
            if (m_VBs == null)
            {
                m_VBs     = new Buffer[8];
                m_strides = new int[8];
                m_CBs     = new Buffer[8];

                m_bindings          = new Dictionary <int, MyBinding>();
                m_slotToBindingKeys = new MyListDictionary <int, int>();
                m_srvBindings       = new MyListDictionary <int, int>();

                m_RTVs = new RenderTargetView[8];
                m_SRVs = new ShaderResourceView[8];

                m_constantsVersion = new Dictionary <Buffer, int>();
                m_constantBindings = new Dictionary <MyStageBinding, Buffer>(MyStageBinding.Comparer);
                m_srvTableBindings = new Dictionary <MyStageSrvBinding, int>(MyStageSrvBinding.Comparer);
                m_srvBindings1     = new List <MyStageSrvBinding>();
            }

            m_IB = null;

            m_inputLayout = null;
            m_ps          = null;
            m_vs          = null;
            m_gs          = null;

            m_RS         = null;
            m_BS         = null;
            m_DS         = null;
            m_stencilRef = 0;

            Array.Clear(m_VBs, 0, m_VBs.Length);
            Array.Clear(m_CBs, 0, m_CBs.Length);

            m_bindings.Clear();
            m_slotToBindingKeys.Clear();
            m_srvBindings.Clear();

            m_constantsVersion.Clear();
            m_constantBindings.Clear();
            m_srvTableBindings.Clear();
            m_srvBindings1.SetSize(0);
        }
Ejemplo n.º 3
0
        void Scan()
        {
            m_lastScan = MySession.Static.GameplayFrameCounter;
            ProfilerShort.Begin("QueryTargets");
            BoundingSphereD bs = new BoundingSphereD(Vector3D.Transform(m_queryLocal.Center, m_grid.WorldMatrix), m_queryLocal.Radius);

            m_targetRoots.Clear();
            m_targetBlocks.Clear();

            ProfilerShort.Begin("MyGamePruningStructure.GetAllTop...");
            MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref bs, m_targetRoots);
            ProfilerShort.End();

            int targetCount = m_targetRoots.Count;

            m_ownersA.AddList(m_grid.SmallOwners);
            m_ownersA.AddList(m_grid.BigOwners);
            for (int i = 0; i < targetCount; i++)
            {
                var grid = m_targetRoots[i] as MyCubeGrid; //perf: using grid owners to not querry friendly ships for blocks
                if (grid != null)
                {
                    if (grid.Physics != null && !grid.Physics.Enabled)
                    {
                        continue;
                    }

                    ProfilerShort.Begin("Friend checks");
                    bool enemy = false;
                    if (grid.BigOwners.Count == 0 && grid.SmallOwners.Count == 0)
                    {
                        foreach (var owner in m_ownersA)
                        {
                            if (MyIDModule.GetRelation(owner, 0) == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies)
                            {
                                enemy = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        m_ownersB.AddList(grid.BigOwners);
                        m_ownersB.AddList(grid.SmallOwners);


                        foreach (var owner in m_ownersA)
                        {
                            foreach (var other in m_ownersB)
                            {
                                if (MyIDModule.GetRelation(owner, other) == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies)
                                {
                                    enemy = true;
                                    break;
                                }
                            }
                        }
                        m_ownersB.Clear();
                    }
                    ProfilerShort.End();
                    if (enemy)
                    {
                        ProfilerShort.Begin("grid.Hierarchy.QuerySphere");
                        var list = m_targetBlocks.GetOrAddList(grid);
                        grid.Hierarchy.QuerySphere(ref bs, list);
                        ProfilerShort.End();
                    }
                    else
                    {
                        MyIDModule module;
                        //performance unfriendly case when grid is not clearly neutral or enemy
                        foreach (var block in grid.GetFatBlocks())
                        {
                            var moduleOwner = ((MyEntity)block) as IMyComponentOwner <MyIDModule>;
                            if (!(moduleOwner != null && moduleOwner.GetComponent(out module)))
                            {
                                continue;
                            }

                            var myID = block.OwnerId;
                            foreach (var owner in m_ownersA)
                            {
                                if (MyIDModule.GetRelation(owner, myID) == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies)
                                {
                                    enemy = true;
                                    break;
                                }
                            }
                            if (enemy)
                            {
                                break;
                            }
                        }

                        if (enemy)
                        {
                            ProfilerShort.Begin("grid.Hierarchy.QuerySphere");
                            var list = m_targetBlocks.GetOrAddList(grid);
                            grid.Hierarchy.QuerySphere(ref bs, list);
                            ProfilerShort.End();
                        }
                    }
                }
            }
            m_ownersA.Clear();

            ProfilerShort.Begin("Filter small objects");
            for (int i = m_targetRoots.Count - 1; i >= 0; i--)
            {
                var target = m_targetRoots[i];
                if (target is Sandbox.Game.Entities.Debris.MyDebrisBase ||
                    target is MyFloatingObject ||
                    (target.Physics != null && !target.Physics.Enabled) ||
                    target.GetTopMostParent().Physics == null || !target.GetTopMostParent().Physics.Enabled)
                {
                    m_targetRoots.RemoveAtFast(i);
                }
            }
            ProfilerShort.End();
            ProfilerShort.End();
        }