Exemplo n.º 1
0
        private void CreateEffect()
        {
            if (m_effect != null)
            {
                m_effect.Stop();
                m_effect = null;
            }

            if (MyParticlesManager.TryCreateParticleEffect(48, out m_effect))
            {
                Matrix mat;
                Orientation.GetMatrix(out mat);

                var orientation = mat;

                if (IsDepressurizing)
                {
                    orientation.Left    = mat.Right;
                    orientation.Up      = mat.Down;
                    orientation.Forward = mat.Backward;
                }

                orientation             = Matrix.Multiply(orientation, CubeGrid.PositionComp.WorldMatrix.GetOrientation());
                orientation.Translation = CubeGrid.GridIntegerToWorld(Position + mat.Forward / 4f);

                m_effect.WorldMatrix = orientation;

                m_effect.UserScale = 3f;
            }
        }
Exemplo n.º 2
0
        void previewGrid_OnBlockAdded(MySlimBlock obj)
        {
            m_shouldUpdateProjection = true;
            m_shouldUpdateTexts      = true; // Text should always be updated, not only when terminal block is added, armor blocks etc also count!

            //Update groups
            if (m_originalGridBuilder == null || !IsProjecting())
            {
                return;
            }

            Vector3I transformed = ProjectedGrid.WorldToGridInteger(CubeGrid.GridIntegerToWorld(obj.Position));

            var terminalBlock = obj.FatBlock as MyTerminalBlock;

            if (terminalBlock != null)
            {
                foreach (var groupBuilder in m_originalGridBuilder.BlockGroups)
                {
                    foreach (var block in groupBuilder.Blocks)
                    {
                        if (transformed == block)
                        {
                            //Search if group already exits and add the terminal block to it
                            bool found = false;
                            for (int i = 0; i < CubeGrid.BlockGroups.Count; i++)
                            {
                                var group = CubeGrid.BlockGroups[i];
                                if (group.Name.ToString() == groupBuilder.Name)
                                {
                                    if (!group.Blocks.Contains(terminalBlock))
                                    {
                                        MyBlockGroup newGroup = new MyBlockGroup(CubeGrid);
                                        newGroup.Name = group.Name;
                                        newGroup.Blocks.Add(terminalBlock);
                                        newGroup.Blocks.AddList(group.Blocks);

                                        CubeGrid.RemoveGroup(group);

                                        CubeGrid.AddGroup(newGroup);
                                    }
                                    found = true;
                                    break;
                                }
                            }

                            //Group was not found
                            if (!found)
                            {
                                MyBlockGroup newGroup = new MyBlockGroup(CubeGrid);
                                newGroup.Name = new StringBuilder(groupBuilder.Name);
                                newGroup.Blocks.Add(terminalBlock);
                                CubeGrid.AddGroup(newGroup);
                            }
                        }
                    }
                }
            }
        }