Ejemplo n.º 1
0
        private void DoWork()
        {
            var ftl = MyAPIGateway.Entities.GetEntityById(FTLId) as IMyFunctionalBlock;

            if (ftl == null)        // Something happened
            {
                return;
            }

            var ftld = ftl.GetFTLData();

            var players = new List <IMyPlayer>();

            MyAPIGateway.Players.GetPlayers(players, (x) => x.SteamUserId == SenderSteamId);
            ftld.jumpTargetGPS = FTLExtensions.GetGPSFromHash(GPSHash, players[0].IdentityId);

            if (GPSHash == 0 && Coords.HasValue)
            {
                ftld.jumpTargetGPS = MyAPIGateway.Session.GPS.Create("FTL Generated", string.Empty, Coords.Value, false, true);
            }

            if (ftld.jumpTargetGPS != null)
            {
                Logger.Instance.LogMessage(string.Format("Found GPS: " + ftld.jumpTargetGPS.Name));
            }
            else
            {
                Logger.Instance.LogMessage(string.Format("Cleared GPS"));
            }

            ftl.GameLogic.GetAs <FTLBase>().SaveTerminalValues();
        }
Ejemplo n.º 2
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();
            }
        }