Exemple #1
0
        public void PlayConstructionSound(MyIntegrityChangeEnum integrityChangeType, bool deconstruction = false)
        {
            MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter();
            if (emitter == null)
                return;
            if(FatBlock != null)
                emitter.SetPosition(FatBlock.PositionComp.GetPosition());
            else
                emitter.SetPosition(CubeGrid.PositionComp.GetPosition() + (Position - 1) * CubeGrid.GridSize);
            switch (integrityChangeType)
            {
                case MyIntegrityChangeEnum.ConstructionBegin:
                    if (deconstruction)
                        emitter.PlaySound(DECONSTRUCTION_START, true, alwaysHearOnRealistic: true);
                    else
                        emitter.PlaySound(CONSTRUCTION_START, true, alwaysHearOnRealistic: true);
                    break;

                case MyIntegrityChangeEnum.ConstructionEnd:
                    if (deconstruction)
                        emitter.PlaySound(DECONSTRUCTION_END, true, alwaysHearOnRealistic: true);
                    else
                        emitter.PlaySound(CONSTRUCTION_END, true, alwaysHearOnRealistic: true);
                    break;

                case MyIntegrityChangeEnum.ConstructionProcess:
                    if (deconstruction)
                        emitter.PlaySound(DECONSTRUCTION_PROG, true, alwaysHearOnRealistic: true);
                    else
                        emitter.PlaySound(CONSTRUCTION_PROG, true, alwaysHearOnRealistic: true);
                    break;

                default:
                    emitter.PlaySound(MySoundPair.Empty);
                    break;
            }
        }
Exemple #2
0
        public void SetIntegrity(float buildIntegrity, float integrity, MyIntegrityChangeEnum integrityChangeType, long grinderOwner)
        {
            float oldRatio = m_componentStack.BuildRatio;
            m_componentStack.SetIntegrity(buildIntegrity, integrity);

            if (FatBlock != null && !BlockDefinition.RatioEnoughForOwnership(oldRatio) && BlockDefinition.RatioEnoughForOwnership(m_componentStack.BuildRatio))
                FatBlock.OnIntegrityChanged(buildIntegrity, integrity, true, MySession.Static.LocalPlayerId);

            UpdateHackingIndicator(m_componentStack.BuildRatio, oldRatio, grinderOwner);

            if (MyFakes.SHOW_DAMAGE_EFFECTS && FatBlock != null)
            {
                if (!BlockDefinition.RatioEnoughForDamageEffect(Integrity / MaxIntegrity))
                    FatBlock.SetDamageEffect(false);
            }

            bool removeDecals = IsFullIntegrity;

            if (ModelChangeIsNeeded(m_componentStack.BuildRatio, oldRatio))
            {
                removeDecals = true;
                UpdateVisual();

                if (integrityChangeType != MyIntegrityChangeEnum.Damage)
                    CreateConstructionSmokes();

                PlayConstructionSound(integrityChangeType);

                if (CubeGrid.GridSystems.GasSystem != null)
                {
                    CubeGrid.GridSystems.GasSystem.Pressurize();
                }
            }

            if (removeDecals)
                CubeGrid.RenderData.RemoveDecals(Position);

            if (MyFakes.ENABLE_GENERATED_BLOCKS && !BlockDefinition.IsGeneratedBlock && BlockDefinition.GeneratedBlockDefinitions != null && BlockDefinition.GeneratedBlockDefinitions.Length > 0)
            {
                UpdateProgressGeneratedBlocks(oldRatio);
            }
        }