Ejemplo n.º 1
0
 public static void ApplyEMP(BoundingSphereD location, float strength, TimeSpan duration)
 {
     MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
         MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref location, s_entitiesEMP);
         foreach (IMyEntity entity in s_entitiesEMP)
         {
             IMyCubeGrid grid = entity as IMyCubeGrid;
             if (grid != null)
             {
                 EMP e = new EMP();
                 e.Start(grid, duration, ref strength, long.MinValue);
             }
         }
         s_entitiesEMP.Clear();
     });
 }
Ejemplo n.º 2
0
 public static void ApplyEMP(BoundingSphereD location, float strength, TimeSpan duration)
 {
     MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
         MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref location, s_entitiesEMP);
         foreach (IMyEntity entity in s_entitiesEMP)
         {
             IMyCubeGrid grid = entity as IMyCubeGrid;
             if (grid != null)
             {
                 EMP e = new EMP();
                 e.Start(grid, duration, ref strength, long.MinValue);
             }
         }
         s_entitiesEMP.Clear();
     });
 }
Ejemplo n.º 3
0
		public static void ApplyEMP(BoundingSphereD location, int strength, TimeSpan duration)
		{
			MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
				MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref location, s_entitiesEMP);
				foreach (IMyEntity entity in s_entitiesEMP)
				{
					IMyCubeGrid grid = entity as IMyCubeGrid;
					if (grid != null)
					{
						EMP e;
						if (!Registrar.TryGetValue(grid, out e))
							e = new EMP(grid);
						e.AddEffect(duration, strength);
					}
				}
				s_entitiesEMP.Clear();
			}, s_logger);
		}
Ejemplo n.º 4
0
        private void LoadData()
        {
            if (m_data == null)
            {
                m_logger.debugLog("No data to load");
                return;
            }

            m_logger.alwaysLog("Save version: " + m_data.ModVersion, Logger.severity.INFO);

            // network

            Dictionary<Message.Builder_Message, Message> messages = new Dictionary<Message.Builder_Message, Message>();
            SerializableGameTime.Adjust = new TimeSpan(m_data.SaveTime);
            foreach (RelayStorage.Builder_NetworkStorage bns in m_data.AntennaStorage)
            {
                RelayNode node;
                if (!Registrar.TryGetValue(bns.PrimaryNode, out node))
                {
                    m_logger.alwaysLog("Failed to get node for: " + bns.PrimaryNode, Logger.severity.WARNING);
                    continue;
                }
                RelayStorage store = node.Storage;
                if (store == null) // probably always true
                {
                    node.ForceCreateStorage();
                    store = node.Storage;
                    if (store == null)
                    {
                        m_logger.debugLog("failed to create storage for " + node.LoggingName, Logger.severity.ERROR);
                        continue;
                    }
                }

                foreach (LastSeen.Builder_LastSeen bls in bns.LastSeenList)
                {
                    LastSeen ls = new LastSeen(bls);
                    if (ls.IsValid)
                        store.Receive(ls);
                    else
                        m_logger.debugLog("failed to create a valid last seen from builder for " + bls.EntityId, Logger.severity.WARNING);
                }

                m_logger.debugLog("added " + bns.LastSeenList.Length + " last seen to " + store.PrimaryNode.LoggingName, Logger.severity.DEBUG);

                foreach (Message.Builder_Message bm in bns.MessageList)
                {
                    Message msg;
                    if (!messages.TryGetValue(bm, out msg))
                    {
                        msg = new Message(bm);
                        messages.Add(bm, msg);
                    }
                    else
                    {
                        m_logger.debugLog("found linked message", Logger.severity.TRACE);
                    }
                    if (msg.IsValid)
                        store.Receive(msg);
                    else
                        m_logger.debugLog("failed to create a valid message from builder for " + bm.DestCubeBlock, Logger.severity.WARNING);
                }

                m_logger.debugLog("added " + bns.MessageList.Length + " message to " + store.PrimaryNode.LoggingName, Logger.severity.DEBUG);
            }

            // system disruption

            foreach (Disruption.Builder_Disruption bd in m_data.SystemDisruption)
            {
                Disruption disrupt;
                switch (bd.Type)
                {
                    case "AirVentDepressurize":
                        disrupt = new AirVentDepressurize();
                        break;
                    case "CryoChamberMurder":
                        disrupt = new CryoChamberMurder();
                        break;
                    case "DisableTurret":
                        disrupt = new DisableTurret();
                        break;
                    case "DoorLock":
                        disrupt = new DoorLock();
                        break;
                    case "EMP":
                        disrupt = new EMP();
                        break;
                    case "GravityReverse":
                        disrupt = new GravityReverse();
                        break;
                    case "JumpDriveDrain":
                        disrupt = new JumpDriveDrain();
                        break;
                    case "MedicalRoom":
                        disrupt = new MedicalRoom();
                        break;
                    case "TraitorTurret":
                        disrupt = new TraitorTurret();
                        break;
                    default:
                        m_logger.alwaysLog("Unknown disruption: " + bd.Type, Logger.severity.WARNING);
                        continue;
                }
                disrupt.Start(bd);
            }

            // autopilot

            if (m_data.Autopilot != null)
                foreach (ShipAutopilot.Builder_Autopilot ba in m_data.Autopilot)
                {
                    ShipAutopilot autopilot;
                    if (Registrar.TryGetValue(ba.AutopilotBlock, out autopilot))
                        autopilot.Resume = ba;
                    else
                        m_logger.alwaysLog("failed to find autopilot block " + ba.AutopilotBlock, Logger.severity.WARNING);
                }

            // programmable block

            if (m_data.ProgrammableBlock != null)
                foreach (ProgrammableBlock.Builder_ProgrammableBlock bpa in m_data.ProgrammableBlock)
                {
                    ProgrammableBlock pb;
                    if (Registrar.TryGetValue(bpa.BlockId, out pb))
                        pb.ResumeFromSave(bpa);
                    else
                        m_logger.alwaysLog("failed to find programmable block " + bpa.BlockId, Logger.severity.WARNING);
                }

            // text panel

            if (m_data.TextPanel != null)
                foreach (TextPanel.Builder_TextPanel btp in m_data.TextPanel)
                {
                    TextPanel panel;
                    if (Registrar.TryGetValue(btp.BlockId, out panel))
                        panel.ResumeFromSave(btp);
                    else
                        m_logger.alwaysLog("failed to find text panel " + btp.BlockId, Logger.severity.WARNING);
                }

            // weapon

            if (m_data.Weapon != null)
                foreach (WeaponTargeting.Builder_WeaponTargeting bwt in m_data.Weapon)
                {
                    WeaponTargeting targeting;
                    if (WeaponTargeting.TryGetWeaponTargeting(bwt.WeaponId, out targeting))
                        targeting.ResumeFromSave(bwt);
                    else
                        m_logger.alwaysLog("failed to find weapon " + bwt.WeaponId, Logger.severity.WARNING);
                }

            // entity values

            if (m_data.EntityValues != null)
                EntityValue.ResumeFromSave(m_data.EntityValues);

            m_data = null;
        }