public void PlayStopWarp(IMyCubeGrid grid) { StopEffect(); CheckSoundGrid(grid); sound.PlaySound(WarpConstants.jumpOutSound, true); sound.VolumeMultiplier = 2; if (bubble != null) { bubble.Close(); } }
private void RemoveFan() { if (fan != null) { fan.Close(); fan = null; } }
private void OpenCharacter(IMyEntity charEntity) { try { MyEntity entity = (MyEntity)charEntity; charEntity.Close(); } catch (Exception ex) { Logging.Instance.WriteLine(string.Format("OpenCharacter() Error: {0}", ex.ToString())); } }
public override void Handle() { try { HashSet <IMyEntity> entities = new HashSet <IMyEntity>(); MyAPIGateway.Entities.GetEntities(entities); foreach (IMyEntity oneEntity in entities) { if ((oneEntity is IMyVoxelMap)) // ! { continue; } if (!oneEntity.Save) { continue; } if (oneEntity.DisplayName.Contains("ommRelayOutpu")) { //oneEntity.Close(); if (!Conquest.CommRelayCleanup.Contains(oneEntity)) { Conquest.CommRelayCleanup.Add(oneEntity); } } } } catch (Exception) { // Continue on. } try { if (Conquest.CommRelayCleanup.Count >= 5) { // Delete the oldest entity in the list. IMyEntity closeMe = Conquest.CommRelayCleanup[0]; Conquest.CommRelayCleanup.Remove(closeMe); closeMe.Close(); } } catch (NullReferenceException) { // List is empty. Continue on. } base.Handle(); }
private void ManageEntities(IMyEntity entity) { try { if (entity.GetType() != typeof(MyCubeGrid)) { return; } WriteToLog("ManageEntities", $"Despawning: {entity.DisplayName}", LogType.General); //Messaging.ShowLocalNotification($"Despawning: {entity.DisplayName}"); entity.Close(); } catch (Exception e) { WriteToLog("ManageEntities", $"Exception! {e}", LogType.Exception); } }
public void Process() { lock (m_items) { if (!m_items.Any()) { return; } for (int r = m_items.Count() - 1; r >= 0; r--) { TimedEntityCleanupItem item = m_items[r]; if (DateTime.Now - item.addedTime > TimeSpan.FromSeconds(item.secondsAfterAdding)) { try { IMyEntity entity = null; Wrapper.GameAction(() => { MyAPIGateway.Entities.TryGetEntityById(item.entityId, out entity); }); if (entity != null) { Wrapper.GameAction(() => entity.Close( )); } else { Log.Info("Entity is null"); } } catch (Exception ex) { Log.Info(string.Format("Dispose Error: {0}", ex.ToString())); } m_items.RemoveAt(r); } } } }
private void OpenBag(IMyEntity bagEntity) { try { MyInventoryBagEntity bag = bagEntity as MyInventoryBagEntity; if (bag == null) { return; } foreach (var item in bag.GetInventory().GetItems().ToList()) { MyFloatingObjects.Spawn(new MyPhysicalInventoryItem(item.Amount, item.Content), bagEntity.WorldMatrix.Translation, bagEntity.WorldMatrix.Forward, bagEntity.WorldMatrix.Up); } bagEntity.Close(); } catch (Exception ex) { Logging.Instance.WriteLine(string.Format("OpenBag Error(): {0}", ex.ToString())); } }
//Do our actual removal. void Entities_OnEntityAdd(IMyEntity entity) { MyFloatingObject floaty = entity as MyFloatingObject; //Make sure its not null if (floaty?.Item != null) { //Also make sure its not null if (floaty.Item.Content?.SubtypeId != null) { MyStringHash subtype = floaty.Item.Content.SubtypeId; //Do a 2fast4u comparison if (m_scraphash.Equals(subtype)) { //Delete the entity entity.Close(); } } } }
private void SetDestructible(IMyEntity shipEntity, bool destructible, ulong steamId) { var gridObjectBuilder = shipEntity.GetObjectBuilder(true) as MyObjectBuilder_CubeGrid; if (gridObjectBuilder.DestructibleBlocks == destructible) { MyAPIGateway.Utilities.SendMessage(steamId, "destructible", "Ship '{0}' destructible is already set to {1}.", shipEntity.DisplayName, destructible ? "On" : "Off"); return; } gridObjectBuilder.EntityId = 0; gridObjectBuilder.DestructibleBlocks = destructible; // This will Delete the entity and sync to all. // Using this, also works with player ejection in the same Tick. shipEntity.Close(); var tempList = new List <MyObjectBuilder_EntityBase>(); tempList.Add(gridObjectBuilder); tempList.CreateAndSyncEntities(); MyAPIGateway.Utilities.SendMessage(steamId, "destructible", "Ship '{0}' destructible has been set to {1}.", shipEntity.DisplayName, destructible ? "On" : "Off"); }
public virtual void Close() { //Logging.Instance.WriteLine(string.Format("Close")); int pos = 0; try { if (m_performanceFriendly) { if (Sync.IsClient) { NaniteConstructionManager.ParticleManager.RemoveParticle(m_cubeEntityId, m_position); } else { m_constructionBlock.SendRemoveParticleEffect(m_cubeEntityId, m_position); } if (m_isGrinder && m_removed) { TransferRemainingComponents(); Logging.Instance.WriteLine(string.Format("GRINDING completed. Target block: {0} - (EntityID: {1} Elapsed: {2})", m_targetBlock.FatBlock != null ? m_targetBlock.FatBlock.GetType().Name : m_targetBlock.GetType().Name, m_targetBlock.FatBlock != null ? m_targetBlock.FatBlock.EntityId : 0, m_completeTime + m_waitTime)); } m_completed = true; return; } if (m_constructionBlock != null && m_constructionBlock.ConstructionBlock != null) { var toolInventory = ((MyEntity)m_tool).GetInventory(0); // Since grinding in creative gives no components. Insert hack. if (MyAPIGateway.Session.CreativeMode && m_tool is Sandbox.ModAPI.Ingame.IMyShipGrinder) { MyObjectBuilder_CubeBlock block = (MyObjectBuilder_CubeBlock)m_targetBlock.GetObjectBuilder(); MyCubeBlockDefinition blockDefinition; if (MyDefinitionManager.Static.TryGetCubeBlockDefinition(block.GetId(), out blockDefinition)) { foreach (var item in blockDefinition.Components) { var inventoryItem = (MyObjectBuilder_PhysicalObject)MyObjectBuilderSerializer.CreateNewObject(item.DeconstructItem.Id); toolInventory.AddItems(item.Count, inventoryItem); } } } if (toolInventory.GetItemsCount() > 0) { TransferFromTarget((MyCubeBlock)m_tool); } } m_completed = true; if (m_tool != null) { m_tool.Enabled = false; } if (!m_toolEntity.Closed) { m_toolEntity.Close(); } } catch (Exception ex) { Logging.Instance.WriteLine(string.Format("Close() {1}: {0}", ex.ToString(), pos)); } }
public void Update() { if (!valid) { return; } Log.DebugWrite(DebugLevel.Info, "Parachute Update Called"); try { if (Entity == null) { if (chute != null) { if (!chute.Closed && !chute.MarkedForClose) { chute.Close(); } } if (isupdating) { CoreParachute.updateChute -= Update; //stop updating isupdating = false; } return; } if (block?.Parent?.Physics == null) { return; } if (open && !isCut) { if (atmosphere > 0.1f) { switch (deployStage) { case 0: doDeployChute(); //spawns chute and attaches break; case 1: updateChute(); //deploying moveChute(); //constrain break; case 2: //double lastscale = scalex; double scale = 10d * (atmosphere - 0.6); if (scale <= 0.5d || double.IsNaN(scale)) { scale = 0.5d; } else { scale = Math.Log(scale - 0.99d) + 5; if (scale < 0.5d || double.IsNaN(scale)) { scale = 0.5d; } } scalex = scaley = (scale * 8d * block.CubeGrid.GridSize); moveChute(); //constrain break; } } } else { if (deployStage > 0) { deployStage = 0; cutChute(); step = 60; //60 ticks and delete } else if (step > 0) { playCut(); step--; } if (chute != null && step <= 0) { if (!chute.Closed && !chute.MarkedForClose) { chute.Close(); } if (isupdating) { CoreParachute.updateChute -= Update; //stop updating isupdating = false; } isCut = false; //make it false } } } catch (Exception ex) { Log.DebugWrite(DebugLevel.Error, ex); } }