Esempio n. 1
0
        public void StartBroadcast(IMyTerminalBlock source, string message, int maxHops)
        {
            Debug.Write("startbroadcast");
            if (message.Length > MAX_LENGTH)
            {
                return;
            }

            var laser = source.GetObjectBuilderCubeBlock() as MyObjectBuilder_LaserAntenna;

            if (laser?.targetEntityId != null)
            {
                IMyEntity entity;
                MyAPIGateway.Entities.TryGetEntityById(laser.targetEntityId, out entity);
                var endpoint = entity as IMyLaserAntenna;

                if (endpoint != null)
                {
                    ProcessMessage(endpoint, message);
                }

                return;
            }

            var excludeList = new HashSet <IMyTerminalBlock>();

            BroadcastRecursive(source, message, maxHops, excludeList, false);
        }
 private void Tool_AppendingCustomInfo(IMyTerminalBlock trash, StringBuilder Info)
 {
     Info.Clear();
     //MyAPIGateway.Utilities.ShowMessage("HyperDrive:", "Tool_AppendingCustomInfo");
     Info.AppendLine($">CROSS-SERVER JUMP STATUS:<");
     if ((trash.GetObjectBuilderCubeBlock() as MyObjectBuilder_JumpDrive).StoredPower >= (trash as MyJumpDrive).BlockDefinition.PowerNeededForJump)
     {
         Info.AppendLine($"Charged and Ready");
     }
     else
     {
         Info.AppendLine($"Not Charged and not ready");
     }
     // Info.AppendLine($"Current Input: {Math.Round(JumpDrv.ResourceSink.RequiredInputByType(Electricity), 2)} MW");
 }
        public static bool CanJump(IMyTerminalBlock Block)
        {
            try
            {
                MyAPIGateway.Utilities.ShowMessage("HyperDrive:", "CanJump???");
                if (((Block.GetObjectBuilderCubeBlock() as MyObjectBuilder_JumpDrive).StoredPower >= (Block as MyJumpDrive).BlockDefinition.PowerNeededForJump) && StaticLinkModCoreblock.stJumpGateLink != null && (Vector3D.DistanceSquared(StaticLinkModCoreblock.stJumpGateLink.GetPosition(), Block.GetPosition()) < 5000 * 5000))
                {
                    return(true);
                }
                return(false);
            }
            catch
            {
                MyAPIGateway.Utilities.ShowMessage("HyperDrive:", "CanJump catch false");

                return(false);
            }
        }
Esempio n. 4
0
        static void FTLJumpDrive_PropertiesChanged(IMyTerminalBlock obj)
        {
            var hash = (obj.GetObjectBuilderCubeBlock() as MyObjectBuilder_JumpDrive).JumpTarget;
            var ftld = obj.GameLogic.GetAs <FTLBase>().Data;

            if (ftld.flags.HasFlag(JumpFlags.GPSWaypoint))  // One-time GPS coordinate
            {
                return;
            }

            if (hash != null)
            {
                ftld.jumpTargetGPS = FTLExtensions.GetGPSFromHash(hash.Value);
                return;
            }
            else
            {
                ftld.jumpTargetGPS = null;
                ftld.jumpDistance  = obj.GameLogic.GetAs <FTLJumpDrive>().ComputeMaxDistance();
            }
        }