public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); var ob = (MyObjectBuilder_FunctionalBlock)objectBuilder; m_enabled = ob.Enabled; IsWorkingChanged += CubeBlock_IsWorkingChanged; m_baseIdleSound = BlockDefinition.PrimarySound; m_actionSound = BlockDefinition.ActionSound; }
private void PlayHitSound(MyStringHash materialType, IMyEntity entity, Vector3D position, MyStringHash thisType) { if ((OwnerEntity == null) || !(OwnerEntity is MyWarhead)) // do not play bullet sound when coming from warheads { ProfilerShort.Begin("Play projectile sound"); MyAutomaticRifleGun rifleGun = m_weapon as MyAutomaticRifleGun; MySoundPair cueEnum = null; cueEnum = MyMaterialPropertiesHelper.Static.GetCollisionCue(MyMaterialPropertiesHelper.CollisionType.Hit, thisType, materialType); if (cueEnum == null || cueEnum == MySoundPair.Empty) { cueEnum = MyMaterialPropertiesHelper.Static.GetCollisionCue(MyMaterialPropertiesHelper.CollisionType.Start, thisType, materialType); } if (cueEnum.SoundId.IsNull && entity is MyVoxelBase) // Play rock sounds if we have a voxel material that doesn't have an assigned sound for thisType { materialType = MyMaterialType.ROCK; cueEnum = MyMaterialPropertiesHelper.Static.GetCollisionCue(MyMaterialPropertiesHelper.CollisionType.Start, thisType, materialType); } if (cueEnum == null || cueEnum == MySoundPair.Empty) { ProfilerShort.End(); return; } var emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter == null) { return; } emitter.Entity = (MyEntity)entity; emitter.SetPosition(m_position); emitter.SetVelocity(Vector3.Zero); if (MySession.Static != null && MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.Settings.RealisticSound) { Func <bool> canHear = () => MySession.Static.ControlledEntity != null && MySession.Static.ControlledEntity.Entity == entity; emitter.StoppedPlaying += (e) => { e.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Remove(canHear); }; emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add(canHear); } emitter.PlaySound(cueEnum, false); ProfilerShort.End(); } }
public EffectSoundEmitter(uint id, Vector3 position, MySoundPair sound) { ParticleSoundId = id; Updated = true; MyEntity entity = null; if (MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.Settings.RealisticSound)//snap emitter to closest block - used for realistic sounds { List <MyEntity> m_detectedObjects = new List <MyEntity>(); BoundingSphereD effectSphere = new BoundingSphereD(MySession.Static.LocalCharacter != null ? MySession.Static.LocalCharacter.PositionComp.GetPosition() : MySector.MainCamera.Position, 2f); MyGamePruningStructure.GetAllEntitiesInSphere(ref effectSphere, m_detectedObjects); float distBest = float.MaxValue; float dist; for (int i = 0; i < m_detectedObjects.Count; i++) { MyCubeBlock block = m_detectedObjects[i] as MyCubeBlock; if (block != null) { dist = Vector3.DistanceSquared(MySession.Static.LocalCharacter.PositionComp.GetPosition(), block.PositionComp.GetPosition()); if (dist < distBest) { dist = distBest; entity = block; } } } m_detectedObjects.Clear(); } Emitter = new MyEntity3DSoundEmitter(entity); Emitter.SetPosition(position); if (sound == null) { sound = MySoundPair.Empty; } Emitter.PlaySound(sound); if (Emitter.Sound != null) { OriginalVolume = Emitter.Sound.Volume; } else { OriginalVolume = 1f; } Emitter.Update(); SoundPair = sound; }
protected override void PlayLoopSound(bool activated) { if (m_soundEmitter == null) { return; } MySoundPair cueEnum = activated ? METAL_SOUND : IDLE_SOUND; if (m_soundEmitter.Sound != null && (m_soundEmitter.SoundPair.Equals(METAL_SOUND) || m_soundEmitter.SoundPair.Equals(IDLE_SOUND)) && m_soundEmitter.Sound.IsPlaying) { m_soundEmitter.PlaySingleSound(cueEnum, true, true); } else { m_soundEmitter.PlaySound(cueEnum); } }
public static void PlayContactSound(long entityId, Vector3D position, MyStringHash materialA, MyStringHash materialB, float volume = 1, Func <bool> canHear = null, Func <bool> shouldPlay2D = null) { MySoundPair cue = MyMaterialSoundsHelper.Static.GetCollisionCue(m_startCue, materialA, materialB); if (!cue.SoundId.IsNull) { MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter == null) { ProfilerShort.End(); return; } MyAudioComponent.ContactSoundsPool.TryAdd(entityId, 0); emitter.StoppedPlaying += (e) => { byte val; MyAudioComponent.ContactSoundsPool.TryRemove(entityId, out val); }; if (MySession.Static.Settings.RealisticSound && MyFakes.ENABLE_NEW_SOUNDS) { Action <MyEntity3DSoundEmitter> remove = null; remove = (e) => { emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Remove(canHear); emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Remove(shouldPlay2D); emitter.StoppedPlaying -= remove; }; emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add(canHear); emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add(shouldPlay2D); emitter.StoppedPlaying += remove; } emitter.SetPosition(position); emitter.PlaySound(cue, true); if (emitter.Sound != null) { if (volume != 0) { emitter.Sound.SetVolume(volume); } } } }
private void BeforeInit() { if (Shield.CubeGrid.Physics == null) { return; } _isServer = Session.Instance.IsServer; _isDedicated = Session.Instance.DedicatedServer; _mpActive = Session.Instance.MpActive; PowerInit(); MyAPIGateway.Session.OxygenProviderSystem.AddOxygenGenerator(_ellipsoidOxyProvider); if (_isServer) { Enforcements.SaveEnforcement(Shield, Session.Enforced, true); } Session.Instance.FunctionalShields[this] = false; Session.Instance.Controllers.Add(this); //if (MyAPIGateway.Session.CreativeMode) CreativeModeWarning(); NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; InitTick = Session.Instance.Tick; _bTime = 1; _bInit = true; if (Session.Enforced.Debug == 3) { Log.Line($"UpdateOnceBeforeFrame: ShieldId [{Shield.EntityId}]"); } if (!_isDedicated) { _alertAudio = new MyEntity3DSoundEmitter(null, true, 1f); _audioReInit = new MySoundPair("Arc_reinitializing"); _audioSolidBody = new MySoundPair("Arc_solidbody"); _audioOverload = new MySoundPair("Arc_overloaded"); _audioEmp = new MySoundPair("Arc_EMP"); _audioRemod = new MySoundPair("Arc_remodulating"); _audioLos = new MySoundPair("Arc_noLOS"); _audioNoPower = new MySoundPair("Arc_insufficientpower"); } }
private void PlayClip(IAudioClip clip) { var player = MyAPIGateway.Session.Player; var ent = player?.Controller?.ControlledEntity?.Entity; if (ent != null) { if (playerEntityId != ent.EntityId) { if (localPlayerSoundEmitter != null) // Player has died and lost their old sound emitter { localPlayerSoundEmitter.StopSound(true); } localPlayerSoundEmitter = new MyEntity3DSoundEmitter(ent as VRage.Game.Entity.MyEntity); playerEntityId = ent.EntityId; } string audiofile = clip.Filename; if (!string.IsNullOrWhiteSpace(audiofile)) { var soundPair = new MySoundPair(audiofile); localPlayerSoundEmitter.StopSound(true); localPlayerSoundEmitter.PlaySingleSound(soundPair); } } // Added V22 //MyAPIGateway.Multiplayer.MultiplayerActive if (MyAPIGateway.Multiplayer.IsServer) { // MyVisualScriptLogicProvider.SendChatMessage(clip.Subtitle, clip.Speaker, 0, clip.Font); string[] aLines = clip.Subtitle.Split('\n'); foreach (var line in aLines) { if (!string.IsNullOrEmpty(line)) { MyVisualScriptLogicProvider.SendChatMessage(line, clip.Speaker, 0, clip.Font); } } } // chat, notifications, billboards... Bad on DS. // The following should NOT be done on DS because nowhere to show it.. MyAPIGateway.Utilities.ShowNotification(clip.Speaker + ": " + clip.Subtitle, clip.DisappearTimeMs, clip.Font); timeUntilNextAudioSeconds = clip.DisappearTimeMs / 1000 + 2; // Add a little 2 second pause between them }
private void StartIdleSound(MySoundPair cuePair) { if (m_soundEmitter == null) { return; } if (!m_soundEmitter.IsPlaying) { //no sound is playing, start idle sound normally m_soundEmitter.PlaySound(cuePair); } else if (!m_soundEmitter.SoundPair.Equals(cuePair)) { //different sound is playing, play end sound for currently playing and start idle sound without intro m_soundEmitter.StopSound(false); m_soundEmitter.PlaySound(cuePair, false, true); } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var airVent = builder as MyObjectBuilder_AirVentDefinition; MyDebug.AssertDebug(airVent != null, "Initializing air vent definition using wrong object builder."); ResourceSinkGroup = MyStringHash.GetOrCompute(airVent.ResourceSinkGroup); ResourceSourceGroup = MyStringHash.GetOrCompute(airVent.ResourceSourceGroup); StandbyPowerConsumption = airVent.StandbyPowerConsumption; OperationalPowerConsumption = airVent.OperationalPowerConsumption; VentilationCapacityPerSecond = airVent.VentilationCapacityPerSecond; PressurizeSound = new MySoundPair(airVent.PressurizeSound); DepressurizeSound = new MySoundPair(airVent.DepressurizeSound); IdleSound = new MySoundPair(airVent.IdleSound); }
public override void Init(Sandbox.Common.ObjectBuilders.MyObjectBuilder_EntityBase objectBuilder) { this.avgGuidance = new SlidingAverageVector(0.3); this.avgCorrectF = new SlidingAverageVector(0.9); this.avgDampenF = new SlidingAverageVector(0.9); Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; this.objectBuilder = objectBuilder; this.id = HoverRailEngine.attachcount++; this.activeRailGuides = new HashSet <RailGuide>(); this.sound_engine_start = new MySoundPair("HoverEngine_Startup"); this.sound_engine_loop = new MySoundPair("HoverEngine_Loop"); MyEntity3DSoundEmitter.PreloadSound(sound_engine_start); MyEntity3DSoundEmitter.PreloadSound(sound_engine_loop); this.engine_sound = new MyEntity3DSoundEmitter(Entity as VRage.Game.Entity.MyEntity); this.engine_sound.Force3D = true; // MyLog.Default.WriteLine(String.Format("ATTACH TO OBJECT {0}", this.id)); InitPowerComp(); }
public MySoundBlock() : base() { CreateTerminalControls(); m_soundPair = new MySoundPair(); m_soundEmitterIndex = 0; m_soundEmitters = new MyEntity3DSoundEmitter[EMITTERS_NUMBER]; for (int i = 0; i < EMITTERS_NUMBER; i++) { m_soundEmitters[i] = new MyEntity3DSoundEmitter(this); m_soundEmitters[i].Force3D = true; } m_volume.ValueChanged += (x) => VolumeChanged(); m_soundRadius.ValueChanged += (x) => RadiusChanged(); m_cueId.ValueChanged += (x) => SelectionChanged(); }
private static void PlaySound(Vector3D position, string cueName) { MySoundPair sound = new MySoundPair(cueName); if (sound == MySoundPair.Empty) { return; } var emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter == null) { return; } emitter.SetPosition(position); emitter.PlaySound(sound); }
private void PlayHitSound(MyStringHash materialType, IMyEntity entity, Vector3D position) { if ((OwnerEntity == null) || !(OwnerEntity is MyWarhead)) // do not play bullet sound when coming from warheads { var emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter == null) { return; } ProfilerShort.Begin("Play projectile sound"); emitter.SetPosition(m_position); emitter.SetVelocity(Vector3.Zero); MyAutomaticRifleGun rifleGun = m_weapon as MyAutomaticRifleGun; MySoundPair cueEnum = null; MyStringHash thisType; if (m_projectileAmmoDefinition.IsExplosive) { thisType = MyMaterialType.EXPBULLET; } else if (rifleGun != null && rifleGun.GunBase.IsAmmoProjectile) { thisType = MyMaterialType.RIFLEBULLET; } else { thisType = MyMaterialType.GUNBULLET; } cueEnum = MyMaterialSoundsHelper.Static.GetCollisionCue(MyMaterialSoundsHelper.CollisionType.Start, thisType, materialType); if (MySession.Static != null && MySession.Static.Settings.RealisticSound) { Func <bool> canHear = () => MySession.ControlledEntity != null && MySession.ControlledEntity.Entity == entity; emitter.StoppedPlaying += (e) => { e.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Remove(canHear); }; emitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add(canHear); } emitter.PlaySound(cueEnum, false); ProfilerShort.End(); } }
private void BroadcastSound(IMyPlayer player, PlayerNotice notice) { var soundEmitter = Session.Instance.SoundEmitter; soundEmitter.Entity = (MyEntity)player.Character; MySoundPair pair = null; switch (notice) { case PlayerNotice.EmitterInit: pair = new MySoundPair("Arc_reinizializing"); break; case PlayerNotice.FieldBlocked: pair = new MySoundPair("Arc_solidbody"); break; case PlayerNotice.OverLoad: pair = new MySoundPair("Arc_overloaded"); break; case PlayerNotice.EmpOverLoad: pair = new MySoundPair("Arc_EMP"); break; case PlayerNotice.Remodulate: pair = new MySoundPair("Arc_remodulating"); break; case PlayerNotice.NoLos: pair = new MySoundPair("Arc_noLOS"); break; case PlayerNotice.NoPower: pair = new MySoundPair("Arc_insufficientpower"); break; } if (soundEmitter.Entity != null && pair != null) { soundEmitter.PlaySingleSound(pair, true); } }
public void OnUse(long hookIdTarget) { bool flag = false; MyEntity entity = null; if (MyEntities.TryGetEntityById(hookIdTarget, out entity, false)) { if (hookIdTarget != this.m_hookIdFrom) { if (this.m_hookIdFrom == 0) { this.m_hookIdFrom = hookIdTarget; entity.OnClosing += this.m_selectedHook_OnClosing; flag = true; } else if (MyRopeComponent.HasRope(this.m_hookIdFrom)) { this.m_hookIdFrom = hookIdTarget; flag = true; } else { if (MyRopeComponent.CanConnectHooks(this.m_hookIdFrom, hookIdTarget, this.m_ropeDefinition)) { MyRopeComponent.AddRopeRequest(this.m_hookIdFrom, hookIdTarget, this.m_ropeDefinition.Id); flag = true; } this.Clear(); } } MySoundPair soundId = flag ? this.m_ropeDefinition.AttachSound : null; if (soundId != null) { MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter != null) { emitter.SetPosition(new Vector3D?(entity.PositionComp.GetPosition())); bool?nullable = null; emitter.PlaySound(soundId, false, false, false, false, false, nullable); } } } }
public override void UpdateOnceBeforeFrame() { try { if (MyAPIGateway.Session.IsServer && MyAPIGateway.Utilities.IsDedicated) { return; // DS doesn't need to play sounds } block = (IMyFunctionalBlock)Entity; if (block?.CubeGrid?.Physics == null) { return; // ignore projected grids } gun = (IMyGunObject <MyGunBase>)Entity; if (!gun.GunBase.HasProjectileAmmoDefined && !allMisTurrets) { return; // ignore missile turrets that don't have projectile ammo } var def = (MyWeaponBlockDefinition)block.SlimBlock.BlockDefinition; var weaponDef = MyDefinitionManager.Static.GetWeaponDefinition(def.WeaponDefinitionId); if (gun.GunBase.IsAmmoProjectile) { soundPair = weaponDef.WeaponAmmoDatas[0].ShootSound; } else { soundPair = weaponDef.WeaponAmmoDatas[1].ShootSound; } lastShotTime = gun.GunBase.LastShootTime.Ticks; soundEmitter = new MyEntity3DSoundEmitter((MyEntity)Entity); // create a sound emitter following this block entity block.IsWorkingChanged += BlockWorkingChanged; BlockWorkingChanged(block); } catch (Exception e) { LogError(e); } }
private void FillListContent(ICollection <MyGuiControlListbox.Item> listBoxContent, ICollection <MyGuiControlListbox.Item> listBoxSelectedItems) { foreach (var soundCategory in MyDefinitionManager.Static.GetSoundCategoryDefinitions()) { foreach (var sound in soundCategory.Sounds) { m_helperSB.Clear().Append(sound.SoundText); var stringId = MySoundPair.GetCueId(sound.SoundId); var item = new MyGuiControlListbox.Item(text: m_helperSB, userData: stringId); listBoxContent.Add(item); if (stringId == CueId) { listBoxSelectedItems.Add(item); } } } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var materialBuilder = builder as MyObjectBuilder_PhysicalMaterialDefinition; if (materialBuilder != null) { //MyDebug.AssertDebug(materialBuilder != null, "Initializing physical material definition using wrong object builder."); Density = materialBuilder.Density; HorisontalTransmissionMultiplier = materialBuilder.HorisontalTransmissionMultiplier; HorisontalFragility = materialBuilder.HorisontalFragility; SupportMultiplier = materialBuilder.SupportMultiplier; CollisionMultiplier = materialBuilder.CollisionMultiplier; DamageDecal = materialBuilder.DamageDecal; } var soundBuilder = builder as MyObjectBuilder_MaterialSoundsDefinition; if (soundBuilder != null) { InheritSoundsFrom = MyStringHash.GetOrCompute(soundBuilder.InheritFrom); foreach (var sound in soundBuilder.ContactSounds) { var type = MyStringId.GetOrCompute(sound.Type); if (!CollisionSounds.ContainsKey(type)) { CollisionSounds[type] = new Dictionary <MyStringHash, MySoundPair>(MyStringHash.Comparer); } var material = MyStringHash.GetOrCompute(sound.Material); Debug.Assert(!CollisionSounds[type].ContainsKey(material), "Overwriting material sound!"); CollisionSounds[type][material] = new MySoundPair(sound.Cue); } foreach (var sound in soundBuilder.GeneralSounds) { GeneralSounds[MyStringId.GetOrCompute(sound.Type)] = new MySoundPair(sound.Cue); } } }
public MyCharacterBreath(MyCharacter character) { this.CurrentState = State.NoBreath; this.m_character = character; string cueName = string.IsNullOrEmpty(character.Definition.BreathCalmSoundName) ? this.BREATH_CALM : character.Definition.BreathCalmSoundName; this.m_breathCalm = new MySoundPair(cueName, true); string str2 = string.IsNullOrEmpty(character.Definition.BreathHeavySoundName) ? this.BREATH_HEAVY : character.Definition.BreathHeavySoundName; this.m_breathHeavy = new MySoundPair(str2, true); string str3 = string.IsNullOrEmpty(character.Definition.OxygenChokeNormalSoundName) ? this.OXYGEN_CHOKE_NORMAL : character.Definition.OxygenChokeNormalSoundName; this.m_oxygenChokeNormal = new MySoundPair(str3, true); string str4 = string.IsNullOrEmpty(character.Definition.OxygenChokeLowSoundName) ? this.OXYGEN_CHOKE_LOW : character.Definition.OxygenChokeLowSoundName; this.m_oxygenChokeLow = new MySoundPair(str4, true); string str5 = string.IsNullOrEmpty(character.Definition.OxygenChokeCriticalSoundName) ? this.OXYGEN_CHOKE_CRITICAL : character.Definition.OxygenChokeCriticalSoundName; this.m_oxygenChokeCritical = new MySoundPair(str5, true); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); if (BlockDefinition is MyLandingGearDefinition) { var landingGearDefinition = (MyLandingGearDefinition)BlockDefinition; m_lockSound = new MySoundPair(landingGearDefinition.LockSound); m_unlockSound = new MySoundPair(landingGearDefinition.UnlockSound); m_failedAttachSound = new MySoundPair(landingGearDefinition.FailedAttachSound); } else { m_lockSound = new MySoundPair("ShipLandGearOn"); m_unlockSound = new MySoundPair("ShipLandGearOff"); m_failedAttachSound = new MySoundPair("ShipLandGearNothing01"); } SyncObject = new MySyncLandingGear(this); Flags |= Sandbox.ModAPI.EntityFlags.NeedsUpdate10 | Sandbox.ModAPI.EntityFlags.NeedsUpdate; LoadDummies(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; var builder = objectBuilder as MyObjectBuilder_LandingGear; if (builder.IsLocked) { // This mode will be applied during one-time update, when we have scene prepared. LockMode = LandingGearMode.Locked; m_needsToRetryLock = true; } BreakForce = RatioToThreshold(builder.BrakeForce); AutoLock = builder.AutoLock; IsWorkingChanged += MyLandingGear_IsWorkingChanged; UpdateText(); AddDebugRenderComponent(new Components.MyDebugRenderComponentLandingGear(this)); }
public override void Init(MyComponentDefinitionBase definition) { base.Init(definition); var craftDefinition = definition as MyCraftingComponentBasicDefinition; System.Diagnostics.Debug.Assert(craftDefinition != null, "Trying to initialize crafting component from wrong definition type?"); if (craftDefinition != null) { ActionSound = new MySoundPair(craftDefinition.ActionSound); m_craftingSpeedMultiplier = craftDefinition.CraftingSpeedMultiplier; foreach (var blueprintClass in craftDefinition.AvailableBlueprintClasses) { var classDefinition = MyDefinitionManager.Static.GetBlueprintClass(blueprintClass); System.Diagnostics.Debug.Assert(classDefinition != null, blueprintClass + " blueprint class definition was not found."); m_blueprintClasses.Add(classDefinition); } } }
public MySoundBlock() : base() { #if XB1 // XB1_SYNC_NOREFLECTION m_soundRadius = SyncType.CreateAndAddProp <float>(); m_volume = SyncType.CreateAndAddProp <float>(); m_cueId = SyncType.CreateAndAddProp <MyCueId>(); m_loopPeriod = SyncType.CreateAndAddProp <float>(); #endif // XB1 CreateTerminalControls(); m_soundEmitterIndex = 0; m_soundEmitters = new MyEntity3DSoundEmitter[EMITTERS_NUMBER]; for (int i = 0; i < EMITTERS_NUMBER; i++) { m_soundEmitters[i] = new MyEntity3DSoundEmitter(this); m_soundEmitters[i].Force3D = true; } m_volume.ValueChanged += (x) => VolumeChanged(); m_soundRadius.ValueChanged += (x) => RadiusChanged(); m_cueIdString.ValueChanged += (x) => SelectionChanged(); }
void SelectionChanged() { if (!MySandboxGame.IsDedicated) { if (m_cueIdString.Value.Length > 0) { m_cueId = new MySoundPair(m_cueIdString.Value); } else { m_cueId = MySoundPair.Empty; } var soundData = MyAudio.Static.GetCue(m_cueId.Arcade); if (soundData != null) { IsLoopable = soundData.Loopable; } } m_loopableTimeSlider.UpdateVisual(); m_playButton.UpdateVisual(); m_stopButton.UpdateVisual(); }
private void InitializeSound() { if (!string.IsNullOrWhiteSpace(NoAmmoSound)) { NoAmmoSoundPair = new MySoundPair(NoAmmoSound); } if (!string.IsNullOrWhiteSpace(SecondarySound)) { SecondarySoundPair = new MySoundPair(SecondarySound); } if (!string.IsNullOrWhiteSpace(ReloadSound)) { ReloadSoundPair = new MySoundPair(ReloadSound); } if (AmmoData != null && !string.IsNullOrWhiteSpace(AmmoData.ShootSound)) { AmmoData.ShootSoundPair = new MySoundPair(AmmoData.ShootSound); } }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { m_physicalItemId = new MyDefinitionId(typeof(MyObjectBuilder_PhysicalGunObject), "AngleGrinderItem"); if (objectBuilder.SubtypeName != null && objectBuilder.SubtypeName.Length > 0) { m_physicalItemId = new MyDefinitionId(typeof(MyObjectBuilder_PhysicalGunObject), objectBuilder.SubtypeName + "Item"); } PhysicalObject = (MyObjectBuilder_PhysicalGunObject)MyObjectBuilderSerializer.CreateNewObject(m_physicalItemId); base.Init(objectBuilder, m_physicalItemId); var definition = MyDefinitionManager.Static.GetPhysicalItemDefinition(m_physicalItemId); Init(null, definition.Model, null, null, null); Render.CastShadows = true; Render.NeedsResolveCastShadow = false; PhysicalObject.GunEntity = (MyObjectBuilder_EntityBase)objectBuilder.Clone(); PhysicalObject.GunEntity.EntityId = this.EntityId; foreach (ToolSound toolSound in m_handItemDef.ToolSounds) { if (toolSound.type == null || toolSound.subtype == null || toolSound.sound == null) { continue; } if (toolSound.type.Equals("Main")) { if (toolSound.subtype.Equals("Idle")) { m_idleSound = new MySoundPair(toolSound.sound); } if (toolSound.subtype.Equals("Soundset")) { m_source = MyStringHash.GetOrCompute(toolSound.sound); } } } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { MyObjectBuilder_RopeDefinition definition = (MyObjectBuilder_RopeDefinition)builder; this.EnableRayCastRelease = definition.EnableRayCastRelease; this.IsDefaultCreativeRope = definition.IsDefaultCreativeRope; this.ColorMetalTexture = definition.ColorMetalTexture; this.NormalGlossTexture = definition.NormalGlossTexture; this.AddMapsTexture = definition.AddMapsTexture; if (!string.IsNullOrEmpty(definition.AttachSound)) { this.AttachSound = new MySoundPair(definition.AttachSound, true); } if (!string.IsNullOrEmpty(definition.DetachSound)) { this.DetachSound = new MySoundPair(definition.DetachSound, true); } if (!string.IsNullOrEmpty(definition.WindingSound)) { this.WindingSound = new MySoundPair(definition.WindingSound, true); } base.Init(builder); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var obDefinition = builder as MyObjectBuilder_OxygenGeneratorDefinition; IceConsumptionPerSecond = obDefinition.IceConsumptionPerSecond; GenerateSound = new MySoundPair(obDefinition.GenerateSound); IdleSound = new MySoundPair(obDefinition.IdleSound); ResourceSourceGroup = MyStringHash.GetOrCompute(obDefinition.ResourceSourceGroup); ProducedGases = null; if (obDefinition.ProducedGases != null) { ProducedGases = new List <MyGasGeneratorResourceInfo>(obDefinition.ProducedGases.Count); foreach (var producedGasInfo in obDefinition.ProducedGases) { ProducedGases.Add(producedGasInfo); } } }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); MyObjectBuilder_OxygenGeneratorDefinition definition = builder as MyObjectBuilder_OxygenGeneratorDefinition; this.IceConsumptionPerSecond = definition.IceConsumptionPerSecond; this.GenerateSound = new MySoundPair(definition.GenerateSound, true); this.IdleSound = new MySoundPair(definition.IdleSound, true); this.ResourceSourceGroup = MyStringHash.GetOrCompute(definition.ResourceSourceGroup); this.ProducedGases = null; if (definition.ProducedGases != null) { this.ProducedGases = new List <MyGasGeneratorResourceInfo>(definition.ProducedGases.Count); foreach (MyObjectBuilder_GasGeneratorResourceInfo info in definition.ProducedGases) { MyGasGeneratorResourceInfo item = new MyGasGeneratorResourceInfo { Id = info.Id, IceToGasRatio = info.IceToGasRatio }; this.ProducedGases.Add(item); } } }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public override void Start(Vector3D position, Vector3D initialVelocity, Vector3D direction, long owner) { m_collidedEntity = null; m_collisionPoint = null; m_maxTrajectory = m_missileAmmoDefinition.MaxTrajectory; m_owner = owner; m_isExploded = false; base.Start(position, initialVelocity, direction, owner); Physics.RigidBody.MaxLinearVelocity = m_missileAmmoDefinition.DesiredSpeed; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; MySoundPair shootSound = m_weaponDefinition.WeaponAmmoDatas[(int)MyAmmoType.Missile].ShootSound; if (shootSound != null) { // Plays cue (looping) m_soundEmitter.PlaySingleSound(shootSound, true); } m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, (Vector3)PositionComp.GetPosition(), GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile, out m_smokeEffect)) { var matrix = PositionComp.WorldMatrix; matrix.Translation -= matrix.Forward * m_smokeEffectOffsetMultiplier; m_smokeEffect.WorldMatrix = matrix; m_smokeEffect.AutoDelete = false; m_smokeEffect.CalculateDeltaMatrix = true; } }
public static void PlayLocalSound(MySoundPair soundPair, float volume = 0.3f, uint timeout = 0) { var mod = ConcreteToolMod.Instance; if (!mod.init) { return; } if (mod.isThisDedicated) { throw new Exception("Sounds shouldn't play on DS side!"); } if (timeout > 0) { var tick = mod.tick; if (mod.hudSoundTimeout > tick) { return; } mod.hudSoundTimeout = tick + timeout; } var emitter = mod.hudSoundEmitter; if (emitter == null) { mod.hudSoundEmitter = emitter = new MyEntity3DSoundEmitter(null); } emitter.SetPosition(MyAPIGateway.Session.Camera.WorldMatrix.Translation); emitter.CustomVolume = volume; emitter.PlaySound(soundPair, stopPrevious: false, alwaysHearOnRealistic: true, force2D: true); }
private void UpdateProductionSound() { if (m_soundEmitter == null) { m_soundEmitter = new MyEntity3DSoundEmitter(Entity as MyEntity); } if (this.m_currentItemStatus < 1f) { var blueprint = this.GetCurrentItemInProduction(); if (blueprint != null && blueprint.Blueprint.ProgressBarSoundCue != null) { m_soundEmitter.PlaySingleSound(MySoundPair.GetCueId(blueprint.Blueprint.ProgressBarSoundCue)); } else { m_soundEmitter.PlaySingleSound(ActionSound); } } else { m_soundEmitter.StopSound(true); } }
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid) { base.Init(builder, cubeGrid); var ob = (MyObjectBuilder_AirtightDoorGeneric)builder; m_open = ob.Open; m_currOpening = ob.CurrOpening; m_openingSpeed = BlockDefinition.OpeningSpeed; m_sound = new MySoundPair(BlockDefinition.Sound); m_subpartMovementDistance = BlockDefinition.SubpartMovementDistance; PowerReceiver = new MyPowerReceiver(MyConsumerGroupEnum.Doors, false, BlockDefinition.PowerConsumptionMoving, () => UpdatePowerInput()); PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged; PowerReceiver.Update(); if (!Enabled || !PowerReceiver.IsPowered) UpdateDoorPosition(); OnStateChange(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; PowerReceiver.Update(); }
private void StartSound(MySoundPair cuePair) { if ((m_soundEmitter.Sound != null) && (m_soundEmitter.Sound.IsPlaying) && (m_soundEmitter.SoundId == cuePair.SoundId)) return; m_soundEmitter.StopSound(true); m_soundEmitter.PlaySingleSound(cuePair, true); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { var medicalRoomDefinition = BlockDefinition as MyMedicalRoomDefinition; MyStringHash resourceSinkGroup; if (medicalRoomDefinition != null) { m_idleSound = new MySoundPair(medicalRoomDefinition.IdleSound); m_progressSound = new MySoundPair(medicalRoomDefinition.ProgressSound); resourceSinkGroup = MyStringHash.GetOrCompute(medicalRoomDefinition.ResourceSinkGroup); } else { m_idleSound = new MySoundPair("BlockMedical"); m_progressSound = new MySoundPair("BlockMedicalProgress"); resourceSinkGroup = MyStringHash.GetOrCompute("Utility"); } SinkComp = new MyResourceSinkComponent(); SinkComp.Init( resourceSinkGroup, MyEnergyConstants.MAX_REQUIRED_POWER_MEDICAL_ROOM, () => (Enabled && IsFunctional) ? SinkComp.MaxRequiredInput : 0f); SinkComp.IsPoweredChanged += Receiver_IsPoweredChanged; base.Init(objectBuilder, cubeGrid); m_rechargeSocket = new MyRechargeSocket(); NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; SteamUserId = (objectBuilder as MyObjectBuilder_MedicalRoom).SteamUserId; if (SteamUserId != 0) //backward compatibility { MyPlayer controller = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(SteamUserId)); if (controller != null) { IDModule.Owner = controller.Identity.IdentityId; IDModule.ShareMode = MyOwnershipShareModeEnum.Faction; } } SteamUserId = 0; m_takeSpawneeOwnership = (objectBuilder as MyObjectBuilder_MedicalRoom).TakeOwnership; m_setFactionToSpawnee = (objectBuilder as MyObjectBuilder_MedicalRoom).SetFaction; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; InitializeConveyorEndpoint(); SinkComp.Update(); AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(SinkComp, this)); if (this.CubeGrid.CreatePhysics) Components.Add<MyRespawnComponent>(new MyRespawnComponent()); m_healingAllowed = medicalRoomDefinition.HealingAllowed; m_refuelAllowed = medicalRoomDefinition.RefuelAllowed; m_suitChangeAllowed = medicalRoomDefinition.SuitChangeAllowed; m_customWardrobesEnabled = medicalRoomDefinition.CustomWardrobesEnabled; m_forceSuitChangeOnRespawn = medicalRoomDefinition.ForceSuitChangeOnRespawn; m_customWardrobeNames = medicalRoomDefinition.CustomWardrobeNames; m_respawnSuitName = medicalRoomDefinition.RespawnSuitName; m_spawnWithoutOxygenEnabled = medicalRoomDefinition.SpawnWithoutOxygenEnabled; RespawnAllowed = medicalRoomDefinition.RespawnAllowed; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); NeedsUpdate &= ~MyEntityUpdateEnum.EACH_100TH_FRAME; if (BlockDefinition is MyLandingGearDefinition) { var landingGearDefinition = (MyLandingGearDefinition)BlockDefinition; m_lockSound = new MySoundPair(landingGearDefinition.LockSound); m_unlockSound = new MySoundPair(landingGearDefinition.UnlockSound); m_failedAttachSound = new MySoundPair(landingGearDefinition.FailedAttachSound); } else { m_lockSound = new MySoundPair("ShipLandGearOn"); m_unlockSound = new MySoundPair("ShipLandGearOff"); m_failedAttachSound = new MySoundPair("ShipLandGearNothing01"); } Flags |= EntityFlags.NeedsUpdateBeforeNextFrame | EntityFlags.NeedsUpdate10 | EntityFlags.NeedsUpdate; LoadDummies(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; var builder = objectBuilder as MyObjectBuilder_LandingGear; if (builder.IsLocked) { // This mode will be applied during one-time update, when we have scene prepared. LockMode = LandingGearMode.Locked; m_needsToRetryLock = true; if (Sync.IsServer) { m_attachedEntityId = builder.AttachedEntityId; } m_attachedState.Value = new State() { OtherEntityId = builder.AttachedEntityId, GearPivotPosition = builder.GearPivotPosition, OtherPivot = builder.OtherPivot, MasterToSlave = builder.MasterToSlave }; } if (MyFakes.LANDING_GEAR_BREAKABLE) { m_savedBreakForce = RatioToThreshold(builder.BrakeForce); } else { m_savedBreakForce = RatioToThreshold(MyObjectBuilder_LandingGear.MaxSolverImpulse); } AutoLock = builder.AutoLock; m_lockModeSync.Value = builder.LockMode; IsWorkingChanged += MyLandingGear_IsWorkingChanged; UpdateText(); AddDebugRenderComponent(new Components.MyDebugRenderComponentLandingGear(this)); }
private void StartSound(MySoundPair cueEnum) { if (m_soundEmitter != null) m_soundEmitter.PlaySound(cueEnum, true); }
public MySoundBlock() : base() { m_soundPair = new MySoundPair(); m_soundEmitterIndex = 0; m_soundEmitters = new MyEntity3DSoundEmitter[EMITTERS_NUMBER]; for (int i = 0; i < EMITTERS_NUMBER; i++) { m_soundEmitters[i] = new MyEntity3DSoundEmitter(this); m_soundEmitters[i].Force3D = true; } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); if (BlockDefinition is MyMedicalRoomDefinition) { var def = (MyMedicalRoomDefinition)BlockDefinition; m_idleSound = new MySoundPair(def.IdleSound); m_progressSound = new MySoundPair(def.ProgressSound); } else { m_idleSound = new MySoundPair("BlockMedical"); m_progressSound = new MySoundPair("BlockMedicalProgress"); } m_rechargeSocket = new MyRechargeSocket(); NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; SteamUserId = (objectBuilder as MyObjectBuilder_MedicalRoom).SteamUserId; if (SteamUserId != 0) //backward compatibility { MyPlayer controller = Sync.Players.TryGetPlayerById(new MyPlayer.PlayerId(SteamUserId)); if (controller != null) { IDModule.Owner = controller.Identity.IdentityId; IDModule.ShareMode = MyOwnershipShareModeEnum.Faction; } } SteamUserId = 0; SyncObject = new SyncClass(this); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; InitializeConveyorEndpoint(); PowerReceiver = new MyPowerReceiver( group: MyConsumerGroupEnum.Utility, isAdaptible: false, maxRequiredInput: MyEnergyConstants.MAX_REQUIRED_POWER_MEDICAL_ROOM, requiredInputFunc: () => (Enabled && IsFunctional) ? PowerReceiver.MaxRequiredInput : 0f); PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged; PowerReceiver.Update(); AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(PowerReceiver,this)); }
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid) { base.Init(builder, cubeGrid); var ob = (MyObjectBuilder_AirtightDoorGeneric)builder; m_open = ob.Open; m_currOpening = ob.CurrOpening; m_openingSpeed = BlockDefinition.OpeningSpeed; m_sound = new MySoundPair(BlockDefinition.Sound); m_subpartMovementDistance = BlockDefinition.SubpartMovementDistance; ResourceSink = new MyResourceSinkComponent(); ResourceSink.Init( MyStringHash.GetOrCompute(BlockDefinition.ResourceSinkGroup), BlockDefinition.PowerConsumptionMoving, UpdatePowerInput); ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged; ResourceSink.Update(); if (!Enabled || !ResourceSink.IsPowered) UpdateDoorPosition(); OnStateChange(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; ResourceSink.Update(); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); var ob = (MyObjectBuilder_FunctionalBlock)objectBuilder; m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_enabled.Value = ob.Enabled; IsWorkingChanged += CubeBlock_IsWorkingChanged; m_baseIdleSound = BlockDefinition.PrimarySound; m_actionSound = BlockDefinition.ActionSound; }
private void StartSound(MySoundPair cueEnum) { m_soundEmitter.PlaySound(cueEnum, true); }