public MySolarPanel() { SourceComp = new MyResourceSourceComponent(); m_soundEmitter = new MyEntity3DSoundEmitter(this); NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; }
public override void OnRemovedFromScene(object source) { if (m_soundEmitter != null) m_soundEmitter.StopSound(true, true); m_soundEmitter = null; base.OnRemovedFromScene(source); }
public MyMotorStator() { CreateTerminalControls(); NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_canBeDetached = true; SyncType.PropertyChanged += SyncType_PropertyChanged; }
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; }
public MyMissile() { m_collidedEntity_OnClose = collidedEntity_OnClose; m_soundEmitter = new MyEntity3DSoundEmitter(this); if (MySession.Static.Settings.RealisticSound && MyFakes.ENABLE_NEW_SOUNDS) { Func <bool> expr = () => MySession.ControlledEntity != null && MySession.ControlledEntity.Entity is MyCharacter && MySession.ControlledEntity.Entity == m_collidedEntity; m_soundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add(expr); m_soundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add(expr); } (PositionComp as MyPositionComponent).WorldPositionChanged = WorldPositionChanged; }
public override void UpdateOnceBeforeFrame() { try { if (MyAPIGateway.Utilities.IsDedicated) { return; // DS doesn't need any of this } block = (MyCubeBlock)Entity; if (block.IsPreview || block.CubeGrid.IsPreview || block.CubeGrid.Physics == null) // ignore ghost grids { block = null; return; } blockDef = (MyCameraBlockDefinition)block.BlockDefinition; if (!CameraPanningMod.Instance.WidthLimits.TryGetValue(blockDef.Id, out zoomLimits)) { Log.Error($"{blockDef.Id.ToString()} didn't exist at BeforeStart() time so it has no stored limits! What is going on?!", Log.PRINT_MESSAGE); return; } NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME; zoomWidth = FovToWidth(MathHelper.ToRadians(60)); originalMatrix = Entity.LocalMatrix; rotatedMatrix = originalMatrix; // HACK temporary fix for camera being in the center of the block TryFixCameraPosition(); // moves the camera view's position towards the default mount point by gridSize/2. if (soundRotateEmitter == null) { soundRotateEmitter = new MyEntity3DSoundEmitter((MyEntity)Entity); soundRotateEmitter.CustomVolume = SOUND_ROTATE_VOLUME; } if (soundZoomEmitter == null) { soundZoomEmitter = new MyEntity3DSoundEmitter((MyEntity)Entity); soundZoomEmitter.CustomVolume = SOUND_ZOOM_VOLUME; } } catch (Exception e) { Log.Error(e); } }
public Splash(Vector3D Position, float Radius = 1f, float Volume = 1f) { position = Position; radius = Radius; maxLife = (int)MyUtils.GetRandomFloat(60, 80); if (Volume != 0) { splashSound = new MyEntity3DSoundEmitter(null); splashSound.SetPosition(position); splashSound.PlaySound(WaterData.SplashSound); splashSound.CustomVolume = Volume * WaterMod.Settings.Volume * ((25f - Math.Max(WaterMod.Session.InsideGrid - 10, 0)) / 25f); } }
public MiningHammerEffect(MyCubeBlock block) { m_block = block; CreateMiningHammer(m_block); m_soundPair = new MySoundPair("NaniteHammer"); m_soundEmitter = new MyEntity3DSoundEmitter(m_block, true); // m_dustEffectId = MyParticleEffectsNameEnum.Smoke_DrillDust; // m_dustEffectStonesId = MyParticleEffectsNameEnum.Smoke_DrillDust; // m_sparksEffectId = MyParticleEffectsNameEnum.Collision_Sparks; // m_sparksEffectId = m_smokeStarted = DateTime.MinValue; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; var timerBlockDefinition = BlockDefinition as MyTimerBlockDefinition; var sinkComp = new MyResourceSinkComponent(); sinkComp.Init( timerBlockDefinition.ResourceSinkGroup, 0.0000001f, () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInput : 0f); ResourceSink = sinkComp; base.Init(objectBuilder, cubeGrid); var ob = objectBuilder as MyObjectBuilder_TimerBlock; Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, 9, 10); Toolbar.Init(ob.Toolbar, this); Toolbar.ItemChanged += Toolbar_ItemChanged; if (ob.JustTriggered) { NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; } IsCountingDown = ob.IsCountingDown; m_countdownMsStart = ob.Delay; m_countdownMsCurrent = ob.CurrentTime; Silent = ob.Silent; if (m_countdownMsCurrent > 0) { NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME; } NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged; ResourceSink.Update(); AddDebugRenderComponent(new Sandbox.Game.Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink, this)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; m_beepStart = new MySoundPair(timerBlockDefinition.TimerSoundStart); m_beepMid = new MySoundPair(timerBlockDefinition.TimerSoundMid); m_beepEnd = new MySoundPair(timerBlockDefinition.TimerSoundEnd); m_beepEmitter = new MyEntity3DSoundEmitter(this); }
public MyProductionBlock() { #if XB1 // XB1_SYNC_NOREFLECTION m_useConveyorSystem = SyncType.CreateAndAddProp <bool>(); #endif // XB1 CreateTerminalControls(); m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_queue = new List <QueueItem>(); NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; IsProducing = false; Components.ComponentAdded += OnComponentAdded; }
private static void PlaySound(Vector3D position, string cueName) { MySoundPair objA = new MySoundPair(cueName, true); if (!ReferenceEquals(objA, MySoundPair.Empty)) { MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter != null) { emitter.SetPosition(new Vector3D?(position)); bool?nullable = null; emitter.PlaySound(objA, false, false, false, false, false, nullable); } } }
/// <summary> /// Use this only for 3d one-time nonloop sounds, emitter returns to pool after the sound is played /// Dont forget to set your entity /// </summary> /// <returns>Emitter or null if none is avaliable in pool</returns> public static MyEntity3DSoundEmitter TryGetSoundEmitter() { MyEntity3DSoundEmitter emitter = null; if (!m_singleUseEmitterPool.TryDequeue(out emitter)) { if (m_currentEmitters < POOL_CAPACITY) { emitter = new MyEntity3DSoundEmitter(null); emitter.StoppedPlaying += emitter_StoppedPlaying; m_currentEmitters++; } } return(emitter); }
/// <summary> /// Called when game logic is added to container /// </summary> public virtual void Init(WeaponControlLayer layer) { ControlLayer = layer; CubeBlock = (MyCubeBlock)layer.Entity; //Targeting = ; Block = CubeBlock as IMyFunctionalBlock; gun = CubeBlock as IMyGunObject <MyGunBase>; IsFixedGun = CubeBlock is IMySmallGatlingGun; PrimaryEmitter = new MyEntity3DSoundEmitter(CubeBlock, useStaticList: true); SecondaryEmitter = new MyEntity3DSoundEmitter(CubeBlock, useStaticList: true); InitializeSound(); Initialized = true; }
public Bubble(Vector3D Position, float Radius = 1f, bool Audible = false, float Volume = 1f) { position = Position; radius = Radius * MyUtils.GetRandomFloat(0.75f, 1.25f); maxLife = (int)(MyUtils.GetRandomFloat(250, 500) * radius); angle = MyUtils.GetRandomFloat(0, 360); if (Audible) { sizzleSound = new MyEntity3DSoundEmitter(null); sizzleSound.SetPosition(position); sizzleSound.PlaySound(WaterData.SizzleSound); sizzleSound.CustomVolume = Volume; } }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { JumpDrv = Container.Entity as IMyFunctionalBlock; base.Init(objectBuilder); Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME | MyEntityUpdateEnum.EACH_FRAME; if (!StaticLinkModCoreblock.HyperDriveList.Contains(Entity)) { StaticLinkModCoreblock.HyperDriveList.Add(Entity); } JumpDrv.AppendingCustomInfo += Tool_AppendingCustomInfo; JumpDrv.OnClose += OnClose; m_soundEmitter = new MyEntity3DSoundEmitter(Container.Entity as VRage.Game.Entity.MyEntity); LOOP_soundEmitter = new MyEntity3DSoundEmitter(Container.Entity as VRage.Game.Entity.MyEntity); magicblack = 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; } m_volume.ValueChanged += (x) => VolumeChanged(); m_soundRadius.ValueChanged += (x) => RadiusChanged(); m_cueId.ValueChanged += (x) => SelectionChanged(); }
public static void PlayContactSound(long entityId, Vector3D position, MyStringHash materialA, MyStringHash materialB, float volume = 1, Func <bool> canHear = null, Func <bool> shouldPlay2D = null) { ProfilerShort.Begin("GetCue"); MySoundPair cue = MyMaterialPropertiesHelper.Static.GetCollisionCue(m_startCue, materialA, materialB); if (!cue.SoundId.IsNull && MyAudio.Static.SourceIsCloseEnoughToPlaySound(position, cue.SoundId)) { MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter(); if (emitter == null) { ProfilerShort.End(); return; } ProfilerShort.BeginNextBlock("Emitter lambdas"); 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; } ProfilerShort.BeginNextBlock("PlaySound"); emitter.SetPosition(position); emitter.PlaySound(cue, true); if (emitter.Sound != null) { if (volume != 0) { emitter.Sound.SetVolume(volume); } } } ProfilerShort.End(); }
public override void ActiveUpdate() { m_owner.SetEmissiveParts("Emissive-Beacon", Color.Lime, 1f); m_owner.SetEmissiveParts("Emissive0", Color.Lime, 1f); MyCubeBlockEmissive.SetEmissiveParts((MyEntity)m_owner, 1f, Color.Lime, Color.White); if (m_soundEmitter == null) { m_soundPair = new MySoundPair("NaniteBeacon"); m_soundEmitter = new MyEntity3DSoundEmitter((MyEntity)m_owner, true); m_soundEmitter.PlaySound(m_soundPair, true); } else if (!m_soundEmitter.IsPlaying) { m_soundEmitter.PlaySound(m_soundPair, true); } }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { base.Init(objectBuilder); try { _objectBuilder = objectBuilder; NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME; // this.m_missileAmmoDefinition = weaponProperties.GetCurrentAmmoDefinitionAs<MyMissileAmmoDefinition>(); SetPowerSink(); cube = (IMyCubeBlock)Entity; block = (IMyFunctionalBlock)Entity; GetAmmoProperties(); //get shoot time for initial check _lastShootTime = GetLastShootTime(); GetTurretMaxRange(); soundEmitter = new MyEntity3DSoundEmitter((MyEntity)Entity, true); projectileData = new RailgunProjectileData() { DesiredSpeed = _desiredSpeed, MaxTrajectory = _maxTrajectory, ExplosionDamage = 0f, ExplosionRadius = 0f, PenetrationDamage = _projectileDamage, PenetrationRange = 50f, ProjectileTrailColor = _trailColor, ProjectileTrailScale = _trailScale, DrawTracer = true, Explode = true, Penetrate = true }; RailgunCore.RegisterRailgun(Entity.EntityId, projectileData); } catch (Exception e) { MyAPIGateway.Utilities.ShowNotification("Exception in init", 10000, MyFontEnum.Red); MyLog.Default.WriteLine(e); } }
private MyEntity3DSoundEmitter getOrCreateEmitter(string snd) { MyEntity3DSoundEmitter em = null; playingSounds.TryGetValue(snd, out em); if (em == null) { em = new MyEntity3DSoundEmitter(entity); if (entity == null) { em.SetPosition(position); em.SetVelocity(Vector3.Zero); } playingSounds.Add(snd, em); } return(em); }
internal void StartShootSound(MyEntity3DSoundEmitter soundEmitter) { if (ShootSound != null && soundEmitter != null) { if (soundEmitter.IsPlaying) { if (!soundEmitter.Loop) { soundEmitter.PlaySound(ShootSound, true); } } else { soundEmitter.PlaySound(ShootSound, true); } } }
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(); IsWorking = MyCube.IsWorking; IsFunctional = MyCube.IsFunctional; 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"); } }
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; }
public EffectSoundEmitter(uint id, Vector3 position, MySoundPair sound) { ParticleSoundId = id; Updated = true; Emitter = new MyEntity3DSoundEmitter(null); Emitter.SetPosition(position); Emitter.PlaySound(sound); if (Emitter.Sound != null) { OriginalVolume = Emitter.Sound.Volume; } else { OriginalVolume = 1f; } Emitter.Update(); }
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 }
public override void Init(MyObjectBuilder_EntityBase builder) { base.Init(builder); if (PhysicalObject != null) { PhysicalObject.GunEntity = builder; } m_sensor = new MyDrillSensorRayCast(0f, 1.8f); PowerReceiver = new MyPowerReceiver( MyConsumerGroupEnum.Utility, false, MyEnergyConstants.REQUIRED_INPUT_ENGINEERING_TOOL, CalculateRequiredPower); m_soundEmitter = new MyEntity3DSoundEmitter(this); }
public void Engage_OnOff() { if (HyperEngaged) { HyperEngaged = false; hyper = false; HyperFunctions._powerPercent = 0f; MyEntity3DSoundEmitter.ClearEntityEmitters(); HyperFunctions.emitter.StopSound(false, true); } else if (!HyperEngaged) { HyperEngaged = true; hyper = false; HyperFunctions.emitter.PlaySound(HyperFunctions.pair); } //Logging.Logging.Instance.WriteLine("Hyper Jump Disengaged Successfully"); }
/// <summary> /// Play sound from particular location. - not working yet /// Code created with assistance of Digi. /// </summary> /// <param name="soundName"></param> /// <param name="position"></param> /// <param name="volume"></param> public static void PlaySoundFrom(string soundName, Vector3D position, float?volume = null) { var emitter = new MyEntity3DSoundEmitter(null) { CustomVolume = volume, CustomMaxDistance = 100 }; emitter.SetPosition(position); emitter.PlaySingleSound(new MySoundPair(soundName)); //emitter.PlaySoundWithDistance(new MyCueId()); // MyCueId is not whitelisted and we need a MySoundPair version. emitter.Cleanup(); // This is what we should use, but it doesn't work. At all. //Sandbox.Game.MyVisualScriptLogicProvider.CreateSoundEmitterAtPosition(position.ToString(), position); //Sandbox.Game.MyVisualScriptLogicProvider.PlaySound(position.ToString(), soundName, false); }
public MyAutomaticRifleGun() { NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME; Render.NeedsDraw = true; #if XB1 // XB1_SYNC_NOREFLECTION SyncType = new SyncType(new List <SyncBase>()); m_gunBase = new MyGunBase(SyncType); #else // !XB1 m_gunBase = new MyGunBase(); #endif // !XB1 m_soundEmitter = new MyEntity3DSoundEmitter(this); (PositionComp as MyPositionComponent).WorldPositionChanged = WorldPositionChanged; this.Render = new MyRenderComponentAutomaticRifle(); #if !XB1 // !XB1_SYNC_NOREFLECTION SyncType = SyncHelpers.Compose(this); SyncType.Append(m_gunBase); #endif // !XB1 }
public Seagull(Vector3D Position, Vector3D Velocity, Vector3 GravityDirection, int MaxLife = 0) { this.Position = Position; this.Velocity = Velocity; this.UpVector = Vector3.Normalize(Velocity); this.LeftVector = Vector3.Normalize(Vector3.Cross(GravityDirection, Velocity)); if (MaxLife == 0) { this.MaxLife = MyUtils.GetRandomInt(1000, 2000); } else { this.MaxLife = MaxLife; } cawSound = new MyEntity3DSoundEmitter(null); }
public MySmallMissileLauncher() { #if XB1 // XB1_SYNC_NOREFLECTION m_useConveyorSystem = SyncType.CreateAndAddProp <bool>(); #endif // XB1 CreateTerminalControls(); #if XB1 // XB1_SYNC_NOREFLECTION m_gunBase = new MyGunBase(SyncType); #else // !XB1 m_gunBase = new MyGunBase(); #endif // !XB1 m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_useConveyorSystem.Value = true; #if !XB1 // !XB1_SYNC_NOREFLECTION SyncType.Append(m_gunBase); #endif // !XB1 }
static void emitter_StoppedPlaying(MyEntity3DSoundEmitter emitter) { if (emitter == null) { return; } emitter.Entity = null; emitter.SoundId = new MyCueId(MyStringHash.NullOrEmpty); if (m_borrowedEmittors.Count > 0) { int index = m_borrowedEmittors.IndexOf(emitter); if (index >= 0 && index < m_borrowedEmittors.Count) { m_borrowedEmittors.RemoveAt(index); } } m_singleUseEmitterPool.Enqueue(emitter); }
public MyCharacterSoundComponent() { m_soundEmitters = new List <MyEntity3DSoundEmitter>(Enum.GetNames(typeof(MySoundEmitterEnum)).Length); foreach (var name in Enum.GetNames(typeof(MySoundEmitterEnum))) { m_soundEmitters.Add(new MyEntity3DSoundEmitter(Entity as MyEntity)); } for (int i = 0; i < Enum.GetNames(typeof(CharacterSoundsEnum)).Length; i++) { CharacterSounds.Add(i, EmptySoundPair); } if (MySession.Static != null && (MySession.Static.Settings.EnableOxygen || MySession.Static.CreativeMode)) { m_oxygenEmitter = new MyEntity3DSoundEmitter(Entity as MyEntity); } }
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 MyFunctionalBlock() { m_soundEmitter = new MyEntity3DSoundEmitter(this); NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; }
public MyMedicalRoom() { m_idleSoundEmitter = new MyEntity3DSoundEmitter(this); m_progressSoundEmitter = new MyEntity3DSoundEmitter(this); m_progressSoundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add((Func<bool>) (() => MySession.ControlledEntity != null && m_user == MySession.ControlledEntity.Entity)); if (MySession.Static != null && MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.Settings.RealisticSound) { m_progressSoundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add((Func<bool>) (() => MySession.ControlledEntity != null && m_user == MySession.ControlledEntity.Entity)); } m_requiredPowerInput = MyEnergyConstants.MAX_REQUIRED_POWER_MEDICAL_ROOM/10f; }
public MyMedicalRoom() { m_idleSoundEmitter = new MyEntity3DSoundEmitter(this); m_progressSoundEmitter = new MyEntity3DSoundEmitter(this); m_progressSoundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add((Func<bool>) (() => MySession.Static.ControlledEntity != null && m_user == MySession.Static.ControlledEntity.Entity)); if (MySession.Static != null && MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.Settings.RealisticSound) { m_progressSoundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.CanHear].Add((Func<bool>) (() => MySession.Static.ControlledEntity != null && m_user == MySession.Static.ControlledEntity.Entity)); } }
public MyLandingGear() { m_physicsChangedHandler = new Action<Sandbox.ModAPI.IMyEntity>(PhysicsChanged); m_soundEmitter = new MyEntity3DSoundEmitter(this); }
public MyMotorStator() { NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; m_soundEmitter = new MyEntity3DSoundEmitter(this); m_canBeDetached = true; }
public MyProductionBlock() { #if XB1 // XB1_SYNC_NOREFLECTION m_useConveyorSystem = SyncType.CreateAndAddProp<bool>(); #endif // XB1 CreateTerminalControls(); m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_queue = new List<QueueItem>(); NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME; IsProducing = false; Components.ComponentAdded += OnComponentAdded; }
public MyProductionBlock() { m_soundEmitter = new MyEntity3DSoundEmitter(this); m_queue = new List<QueueItem>(); NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; IsProducing = false; }
public MyProductionBlock() { CreateTerminalControls(); m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_queue = new List<QueueItem>(); NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; IsProducing = false; Components.ComponentAdded += OnComponentAdded; }
public MySlimBlock() { m_soundEmitter = new MyEntity3DSoundEmitter(null); UniqueId = MyRandom.Instance.Next(); }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary<MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for(int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) continue; m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if(m_storedGases == null) m_storedGases = new GasData[0]; Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; OxygenLevelAtCharacterLocation = 0f; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required // todo: this should be independent on animation/layer names string animationOpenHelmet; string animationCloseHelmet; Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetOpen", out animationOpenHelmet); Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetClose", out animationCloseHelmet); if ((animationOpenHelmet != null && animationCloseHelmet != null) || (Character.UseNewAnimationSystem && Character.AnimationController.Controller.GetLayerByName("Helmet") != null)) { NeedsOxygenFromSuit = characterOb.NeedsOxygenFromSuit; } else { NeedsOxygenFromSuit = Definition.NeedsOxygen; // compatibility } NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; if (m_soundEmitter == null) m_soundEmitter = new MyEntity3DSoundEmitter(Character); if (!HelmetEnabled) // default state == helmet is enabled AnimateHelmet(); }
public MyMotorStator() { #if XB1 // XB1_SYNC_NOREFLECTION m_dummyDisplacement = SyncType.CreateAndAddProp<float>(); //<== from base class Torque = SyncType.CreateAndAddProp<float>(); BrakingTorque = SyncType.CreateAndAddProp<float>(); TargetVelocity = SyncType.CreateAndAddProp<float>(); m_minAngle = SyncType.CreateAndAddProp<float>(); m_maxAngle = SyncType.CreateAndAddProp<float>(); #endif // XB1 CreateTerminalControls(); NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; m_soundEmitter = new MyEntity3DSoundEmitter(this, true); m_canBeDetached = true; SyncType.PropertyChanged += SyncType_PropertyChanged; }