Ejemplo n.º 1
0
        void SetPadStatus(string text, string font, int aliveTime = 200)
        {
            try
            {
                if (!SeeWeldPadInfo())
                {
                    return;
                }

                if (Notification == null)
                {
                    Notification = MyAPIGateway.Utilities.CreateNotification(text, aliveTime, font);
                }
                else
                {
                    Notification.Hide(); // required since SE v1.194
                    Notification.Font      = font;
                    Notification.Text      = text;
                    Notification.AliveTime = aliveTime;
                }

                Notification.Show();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 2
0
        void ComplainMissing(Dictionary <IMySlimBlock, Dictionary <string, int> > MissingPerBlock)
        {
            var Player = MyAPIGateway.Session.Player;

            if (Player == null)
            {
                return;
            }
            if (Player.IdentityId != Tool.OwnerId)
            {
                return;
            }
            if (Player.GetPosition().DistanceTo(Tool.GetPosition()) > 200)
            {
                return;
            }

            StringBuilder Text = new StringBuilder();

            if (MissingPerBlock.Count == 1)
            {
                IMySlimBlock Block       = MissingPerBlock.Keys.First();
                var          Missing     = MissingPerBlock[Block];
                bool         IsProjected = Block.IsProjectable();
                if (Missing != null && Missing.Count > 0)
                {
                    Text.AppendLine($"{Tool.CustomName}: can't proceed to {(!IsProjected ? "build" : "place")} {Block.BlockDefinition.DisplayNameText}, missing:\n");
                    foreach (var ItemPair in Missing)
                    {
                        Text.AppendLine($"{ItemPair.Key}: {(!IsProjected ? 1 : ItemPair.Value)}");
                        if (IsProjected)
                        {
                            break;
                        }
                    }
                }
            }
            else if (UnbuiltBlocks.Count > 1 && MissingPerBlock.Values.Any(x => x.Count > 0))
            {
                Text.AppendLine($"{Tool.CustomName}: can't proceed to build {MissingPerBlock.Count} blocks:\n");
                foreach (IMySlimBlock Block in MissingPerBlock.Keys)
                {
                    var Missing = MissingPerBlock[Block];
                    if (Missing.Count == 0)
                    {
                        continue;
                    }
                    Text.AppendLine($"{Block.BlockDefinition.DisplayNameText}: missing:");
                    foreach (var ItemPair in Missing)
                    {
                        Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}");
                    }
                    Text.AppendLine();
                }
            }
            Text.RemoveTrailingNewlines();
            IMyHudNotification hud = MyAPIGateway.Utilities.CreateNotification(Text.ToString(), (int)Math.Ceiling(SessionCore.TickLengthMs * 101), "Red"); // Adding 1 excess tick is needed, otherwise notification can flicker

            hud.Show();
        }
Ejemplo n.º 3
0
        public static void Error(string msg)
        {
            Info("ERROR: " + msg);

            try
            {
                string text = ModName + " error - open %AppData%/SpaceEngineers/Storage/..._" + ModName + "/" + LogFile + " for details";

                MyLog.Default.WriteLineAndConsole(text);

                if (_notify == null)
                {
                    _notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red);
                }
                else
                {
                    _notify.Text = text;
                    _notify.ResetAliveTime();
                }

                _notify.Show();
            }
            catch (Exception e)
            {
                Info("ERROR: Could not send notification to local client: " + e.ToString());
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Warn the player of incoming missile by displaying a message on the HUD.
 /// </summary>
 private void MissileHudWarning()
 {
     if (m_threat != null)
     {
         m_missileWarning.Show();
     }
 }
Ejemplo n.º 5
0
 public override void UpdateOnceBeforeFrame()
 {
     try
     {
         if (Tool.CubeGrid.Physics == null)
         {
             NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
             return;
         }
         Term      = Grid.GetTerminalSystem();
         ToolCargo = Tool.GetInventory();
         CheckInitControls();
         SyncBeamLength   = new AutoSet <float>(Tool, "BeamLength", Checker: val => val >= MinBeamLengthBlocks && val <= MaxBeamLengthBlocks);
         SyncDistanceMode = new AutoSet <bool>(Tool, "DistanceBasedMode");
         SyncBeamLength.Ask();
         SyncDistanceMode.Ask();
         BeamLength = 1;
         Tool.AppendingCustomInfo += Tool_AppendingCustomInfo;
         Load();
         NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
         DebugNote    = MyAPIGateway.Utilities.CreateNotification($"{Tool.CustomName}", int.MaxValue, (IsWelder ? "Blue" : "Red"));
         if (SessionCore.Debug)
         {
             DebugNote.Show();
         }
     }
     catch { }
 }
Ejemplo n.º 6
0
        public void Show(int line, string text, string font = MyFontEnum.Debug, int aliveTime = DEFAULT_TIMEOUT_MS)
        {
            if (line < 0 || line >= notifications.Length)
            {
                throw new ArgumentException($"Notification line ({line.ToString()}) is either negative or above max of {(notifications.Length - 1).ToString()}.");
            }

            IMyHudNotification notify = notifications[line];

            if (text == null)
            {
                if (notify != null)
                {
                    notify.Hide();
                }

                return;
            }

            if (notify == null)
            {
                notify = notifications[line] = MyAPIGateway.Utilities.CreateNotification(string.Empty);
            }

            notify.Hide(); // required since SE v1.194
            notify.Font      = font;
            notify.Text      = text;
            notify.AliveTime = aliveTime;
            notify.Show();
        }
Ejemplo n.º 7
0
        public override void UpdateOnceBeforeFrame()
        {
            try
            {
                if (Drill.CubeGrid.Physics?.Enabled != true || !Networker.Inited)
                {
                    NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
                    if (!Networker.Inited)
                    {
                        Networker.Init(SessionCore.ModID);
                    }
                    return;
                }
                SyncHarvestEfficiency = new Syncer <float>(Drill, "HarvestEfficiency", 1, Checker: val => val >= 1 && val <= 4);
                SyncHarvestEfficiency.GotValueFromServer += Drill.UpdateVisual;
                Drill.PowerConsumptionMultiplier          = PowerConsumptionMultiplier();

                CheckInitControls();
                Load();

                SessionCore.SaveRegister(Save);
                NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
                DebugNote    = MyAPIGateway.Utilities.CreateNotification($"{Drill?.CustomName}", int.MaxValue, "Blue");
                Owner        = MyAPIGateway.Players.GetPlayer(Drill.OwnerId);
                if (SessionCore.Settings.Debug)
                {
                    DebugNote.Show();
                }
            }
            catch { }
        }
Ejemplo n.º 8
0
        public static void Error(string msg, string printText)
        {
            Info("ERROR: " + msg);

            try
            {
                MyLog.Default.WriteLineAndConsole(modName + " error/exception: " + msg);

                if (MyAPIGateway.Session != null)
                {
                    if (notify == null)
                    {
                        notify = MyAPIGateway.Utilities.CreateNotification(printText, 10000, MyFontEnum.Red);
                    }
                    else
                    {
                        notify.Text = printText;
                        notify.ResetAliveTime();
                    }

                    notify.Show();
                }
            }
            catch (Exception e)
            {
                Info("ERROR: Could not send notification to local client: " + e);
                MyLog.Default.WriteLineAndConsole(modName + " error/exception: Could not send notification to local client: " + e);
            }
        }
 private void NotifyInventoryInteractionFailure(long entityId)
 {
     if (MySession.Static.PlayerEntity != null && MySession.Static.PlayerEntity.EntityId == entityId)
     {
         _failureNotification?.Show();
     }
 }
Ejemplo n.º 10
0
        public static void Error(string msg)
        {
            Info("ERROR: " + msg);

            try
            {
                MyLog.Default.WriteLineAndConsole(MOD_NAME + " error: " + msg);

                string text = MOD_NAME + " error - open %AppData%/SpaceEngineers/Storage/" + WORKSHOP_ID + "_" + MOD_NAME + "/" + LOG_FILE + " for details";

                if (notify == null)
                {
                    notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red);
                }
                else
                {
                    notify.Text = text;
                    notify.ResetAliveTime();
                }

                notify.Show();
            }
            catch (Exception e)
            {
                Info("ERROR: Could not send notification to local client: " + e.ToString());
            }
        }
Ejemplo n.º 11
0
        private static void PrintError(string msg)
        {
            Info("ERROR: " + msg);

            try
            {
                MyLog.Default.WriteLineAndConsole(ModName + " error: " + msg);

                if (MyAPIGateway.Session != null)
                {
                    var text = ModName + " error - open %AppData%/SpaceEngineers/Storage/" + WorkshopId + ".sbm_" + ModName + "/" +
                               LogFile +
                               " for details";

                    if (_notify == null)
                    {
                        _notify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red);
                    }
                    else
                    {
                        _notify.Text = text;
                        _notify.ResetAliveTime();
                    }

                    _notify.Show();
                }
            }
            catch (Exception e)
            {
                Info("ERROR: Could not send notification to local client: " + e);
            }
        }
Ejemplo n.º 12
0
        public static void refresh_local_player_HUD()
        {
            if (!_UI_handlers_registered)
            {
                return;
            }

            bool player_in_cockpit = local_controller is MyShipController;

            foreach (var message_entry in _HUD_messages)
            {
                HUD_notification cur_message  = message_entry.Value;
                bool             show_message = player_in_cockpit && _HUD_messages[message_entry.Key].toggled_on && cur_message.set_to_visible;

                IMyHudNotification contents = cur_message.contents;

                /*
                 * if (cur_message.currently_visible != show_message)
                 * {
                 *  if (show_message)
                 *      contents.Show();
                 *  else
                 *      contents.Hide();
                 *  cur_message.currently_visible = show_message;
                 * }
                 */
                contents.Hide();
                if (show_message)
                {
                    contents.Show();
                }
            }
        }
Ejemplo n.º 13
0
            /// <summary>
            /// Updates text colors and resets alive time for fallback hud.
            /// </summary>
            private void UpdateText()
            {
                int elements = Utilities.Clamp(visEnd - visStart, 0, Cfg.maxVisible), i, action;

                header.Show();
                header.ResetAliveTime();
                header.Text = $"{headerText} ({visStart + 1} - {visEnd} of {target.ScrollableCount})";

                for (int notif = 0; notif < elements; notif++)
                {
                    if (list[notif] == null)
                    {
                        list[notif] = MyAPIGateway.Utilities.CreateNotification("");
                    }

                    i      = notif + visStart;
                    action = i - target.Properties.Count;

                    // make sure its still being shown
                    list[notif].Show();
                    list[notif].ResetAliveTime();

                    // get name
                    if (i >= target.Properties.Count)
                    {
                        list[notif].Text = target.Actions[action].GetDisplay();
                    }
                    else
                    {
                        list[notif].Text = target.Properties[i].GetDisplay();
                    }

                    // get color
                    if (i == selection)
                    {
                        list[notif].Font = MyFontEnum.Green;
                    }
                    else if (i == index)
                    {
                        list[notif].Font = MyFontEnum.Red;
                    }
                    else
                    {
                        list[notif].Font = MyFontEnum.White;
                    }
                }

                // hide everything else
                for (int n = elements; n < list.Length; n++)
                {
                    if (list[n] == null)
                    {
                        list[n] = MyAPIGateway.Utilities.CreateNotification("");
                    }

                    list[n].Text = "";
                    list[n].Hide();
                }
            }
Ejemplo n.º 14
0
        public override void UpdateOnceBeforeFrame()
        {
            try
            {
                if (RadarBlock.CubeGrid.Physics == null)
                {
                    NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
                    return;
                }

                if (!Networker.Inited)
                {
                    Networker.Init(907384096);
                }
                if (!Controls.InitedRadarControls)
                {
                    Controls.InitRadarControls();
                }

                NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
                GetMaxPower();
                Term = RadarBlock.CubeGrid.GetTerminalSystem();

                RadarPower           = new AutoSet <float>(RadarBlock, "Power", 1000, x => x >= 0 && x <= MaxPower);
                ShowMarkers          = new AutoSet <bool>(RadarBlock, "ShowMarkers", true, null);
                ShowRoids            = new AutoSet <bool>(RadarBlock, "ShowRoids", true, null);
                ActiveRadar          = new AutoSet <bool>(RadarBlock, "Active", false, null);
                ShowOnlyHostiles     = new AutoSet <bool>(RadarBlock, "OnlyHostiles", true, null);
                ShowFloating         = new AutoSet <bool>(RadarBlock, "Floating", false, null);
                ShowWorkingGridsOnly = new AutoSet <bool>(RadarBlock, "ShowWorkingGridsOnly", false, null);

                PowerModule.InitResourceSink();
                PersistenceModule.Load();
                RadarBlock.AppendingCustomInfo += RadarBlock_AppendingCustomInfo;
                RadarBlock.OnMarkForClose      += OnMarkForClose;
                Debug.Write($"Added radar {RadarBlock.EntityId}");
                if (RadarCore.Debug)
                {
                    TestNote = MyAPIGateway.Utilities.CreateNotification($"{RadarBlock.CustomName}: enabled;", int.MaxValue, "Green");
                }

                if (RadarCore.Debug)
                {
                    TestNote.Show();
                }

                RadarCore.DebugWrite("Testing", "TESTING", true);

                //MyRadarGrid = RadarBlock.CubeGrid.Components.Get<RadarableGrid>();
                if (MyRadarGrid == null)
                {
                    throw new Exception($"{RadarBlock.CustomName}.MyRadarGrid is null!");
                }
            }
            catch { }
        }
Ejemplo n.º 15
0
 public bool DisplayMsg()
 {
     if (Message != null && m_notification == null)
     {
         m_notification = MyAPIGateway.Utilities.CreateNotification(Message, 0, (IsMsgWinning ? MyFontEnum.Green : MyFontEnum.Red));
         m_notification.Show();
         return(true);
     }
     return(false);
 }
Ejemplo n.º 16
0
 public bool DisplayMsg()
 {
     if (Message != null && m_notification==null)
     {
         m_notification=MyAPIGateway.Utilities.CreateNotification(Message, 0, (IsMsgWinning ? MyFontEnum.Green : MyFontEnum.Red));
         m_notification.Show();
         return true;
     }
     return false;
 }
Ejemplo n.º 17
0
        public static void ShowDebug(this IMyHudNotification notification)
        {
            if (!Debug)
#pragma warning disable 162
            {
                return;
            }
#pragma warning restore 162

            notification.Show();
        }
Ejemplo n.º 18
0
        protected override void Hit()
        {
            if (Target.Entity == null || !(Target.Entity is MyVoxelBase))
            {
                return;
            }

            MrzUtils.ShowNotificationDebug($"VoxelPainter::Hit {Target.Entity}");

            try
            {
                var voxelBase = Target.Entity as MyVoxelBase;
                voxelBase = voxelBase.RootVoxel; // getting the planet
                if (voxelBase.MarkedForClose)
                {
                    return;
                }

                MyVoxelMaterialDefinition voxelMaterial = GetVoxelMaterial(voxelBase, Target.Position);

                MyVoxelMiningDefinition.MiningEntry miningDef;
                if (voxelMaterial != null && _mining.MiningEntries.TryGetValue(voxelMaterial.Index, out miningDef))
                {
                    UpdateDurability(-1);

                    Vector3 pos;
                    CalculateCoords(voxelBase, Target.Position,
                                    out pos);

                    MrzUtils.ShowNotificationDebug($"VoxelPainter::Request Paint - Position:{Target.Position} Radius:{Definition.PaintRadius} Material:{_fillMaterial}", 1000);

                    if (MrzUtils.IsServer)
                    {
                        var plane = new Plane(pos, Target.Normal);
                        plane.D = Definition.PaintDepth;
                        DoOperationServer(voxelBase, pos, Definition.PaintRadius, plane);
                    }
                    //MyAPIGateway.Multiplayer.RaiseStaticEvent(x => DoOperationServer, OperationServer.CreateCut(
                    //    Holder.EntityId, voxelBase.EntityId, pos, Modified
                    //));
                }
                else
                {
                    if (Holder == MySession.Static.PlayerEntity)
                    {
                        _wrongToolMessage.Show();
                    }
                }
            }
            catch (Exception e)
            {
                MrzUtils.ShowNotificationDebug(e.Message);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Prints a message to the player, repeated calls to this method will overwrite the previous message on the HUD, therefore preventing spam.
        /// </summary>
        public void NotifyHUD(string message, int time = 3000, string font = MyFontEnum.White)
        {
            if (notify == null)
            {
                notify = MyAPIGateway.Utilities.CreateNotification(string.Empty);
            }

            notify.Text      = "Air leak scan: " + message;
            notify.AliveTime = time;
            notify.Font      = font;
            notify.Show();
        }
        private void NotifyInventoryInteractionSuccess(long entityId, SerializableDefinitionId id, int amount)
        {
            if (MySession.Static.PlayerEntity == null || MySession.Static.PlayerEntity.EntityId != entityId)
            {
                return;
            }

            var text           = MyTexts.GetString(_definition.SuccessNotification);
            var itemDefinition = MyDefinitionManager.Get <MyInventoryItemDefinition>(id);

            _successNotification.Text = string.Format(text, itemDefinition?.DisplayNameText ?? id.ToString(), amount);
            _successNotification?.Show();
        }
Ejemplo n.º 21
0
        private void ShowNotification(string text, MyFontEnum color)
        {
            if (mNotify == null)
            {
                mNotify = MyAPIGateway.Utilities.CreateNotification(text, 10000, MyFontEnum.Red);
            }
            else
            {
                mNotify.Text = text;
                mNotify.ResetAliveTime();
            }

            mNotify.Show();
        }
Ejemplo n.º 22
0
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();
            Initialize();

            if (_grid == null || _thrusters.Count == 0)
            {
                return;
            }

            var hasOverheat = false;

            foreach (var t in _thrusters)
            {
                ThrusterMode thrusterMode;
                ReadThrusterState(t, out thrusterMode);
                hasOverheat = hasOverheat || thrusterMode == ThrusterMode.Overheat;
            }

            var enableBoost = MyAPIGateway.Input.IsAnyShiftKeyPressed() && !hasOverheat;

            var heatLevel = 0f;

            hasOverheat = false;
            foreach (var t in _thrusters)
            {
                float        thrusterHeat;
                ThrusterMode thrusterMode;
                UpdateThruster(t, enableBoost, out thrusterHeat, out thrusterMode);
                if (heatLevel < thrusterHeat)
                {
                    heatLevel = thrusterHeat;
                }

                hasOverheat = hasOverheat || thrusterMode == ThrusterMode.Overheat;
            }

            if (enableBoost || heatLevel > 0f)
            {
                var progress = 100f * heatLevel / MAX_HEAT;
                _notification.Text = RenderMessage(progress, hasOverheat, enableBoost);

                _notification.ResetAliveTime();
                _notification.Show();
            }
            else
            {
                _notification.Hide();
            }
        }
Ejemplo n.º 23
0
        void PrintMissing(HashSet <IMySlimBlock> UnbuiltBlocks)
        {
            //if (UnbuiltBlocks == null || UnbuiltBlocks.Count == 0) return;
            var Player = MyAPIGateway.Session.Player;

            if (Player == null)
            {
                return;
            }
            if (Player.IdentityId != Tool.OwnerId)
            {
                return;
            }
            if (Player.GetPosition().DistanceTo(Tool.GetPosition()) > 1000)
            {
                return;
            }

            StringBuilder Text = new StringBuilder();

            Text.AppendLine($"Performance impact: {(RunTimesAvailable ? Math.Round(AvgRunTime, 4).ToString() : "--")}/{(RunTimesAvailable ? Math.Round(MaxRunTime, 4).ToString() : "--")} ms (avg/max)");
            if (UnbuiltBlocks.Count == 1)
            {
                IMySlimBlock Block = UnbuiltBlocks.First();
                Text.AppendLine($"{Tool.CustomName}: can't proceed to build {Block.BlockDefinition.DisplayNameText}, missing:\n");
                var Missing = Block.ReadMissingComponents();
                foreach (var ItemPair in Missing)
                {
                    Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}");
                }
            }
            else if (UnbuiltBlocks.Count > 1)
            {
                Text.AppendLine($"{Tool.CustomName}: can't proceed to build {UnbuiltBlocks.Count} blocks:\n");
                foreach (IMySlimBlock Block in UnbuiltBlocks)
                {
                    var Missing = Block.ReadMissingComponents();
                    Text.AppendLine($"{Block.BlockDefinition.DisplayNameText}: missing:");
                    foreach (var ItemPair in Missing)
                    {
                        Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}");
                    }
                    Text.AppendLine();
                }
            }
            Text.RemoveTrailingNewlines();
            IMyHudNotification hud = MyAPIGateway.Utilities.CreateNotification(Text.ToString(), (int)(SessionCore.TickLengthMs * (SessionCore.WorkSkipTicks + 1)), "Red"); // Adding 1 excess tick is needed, otherwise notification can flicker

            hud.Show();
        }
Ejemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="displayms"></param>
        public void ShowOnHud(string text, int displayms = 10000)
        {
            if (_Notify == null)
            {
                _Notify = MyAPIGateway.Utilities.CreateNotification(text, displayms, MyFontEnum.Red);
            }
            else
            {
                _Notify.Text = text;
                _Notify.ResetAliveTime();
            }

            _Notify.Show();
        }
Ejemplo n.º 25
0
        public void Print(Channel channel, string text, string font = MyFontEnum.Debug, int aliveTime = 200)
        {
            IMyHudNotification notification = Channels[(int)channel];

            if (notification == null)
            {
                notification           = MyAPIGateway.Utilities.CreateNotification(string.Empty);
                Channels[(int)channel] = notification;
            }

            notification.Hide(); // required since SE v1.194
            notification.Font      = font;
            notification.Text      = text;
            notification.AliveTime = aliveTime;
            notification.Show();
        }
Ejemplo n.º 26
0
            private void ShowHudMessage(ref IMyHudNotification notify, string message, string printText, int printTime, string font)
            {
                try
                {
                    if (!sessionReady || printText == null || MyAPIGateway.Utilities == null || MyAPIGateway.Utilities.IsDedicated)
                    {
                        return;
                    }

                    if (printText == PRINT_GENERIC_ERROR)
                    {
                        printText = errorPrintText;
                    }
                    else if (printText == PRINT_MESSAGE)
                    {
                        if (font == MyFontEnum.Red)
                        {
                            printText = $"[{modName} ERROR: {message}]";
                        }
                        else
                        {
                            printText = $"[{modName} WARNING: {message}]";
                        }
                    }

                    if (notify == null)
                    {
                        notify = MyAPIGateway.Utilities.CreateNotification(printText, printTime, font);
                    }
                    else
                    {
                        notify.Hide(); // required since SE v1.194
                        notify.Text      = printText;
                        notify.AliveTime = printTime;
                        notify.ResetAliveTime();
                    }

                    notify.Show();
                }
                catch (Exception e)
                {
                    Info("ERROR: Could not send notification to local client: " + e);
                    MyLog.Default.WriteLineAndConsole($"{modName} :: LOGGER error/exception: Could not send notification to local client: {e}");
                }
            }
Ejemplo n.º 27
0
        /// <summary>
        /// Tries to get terminal block being targeted by the local player if there is one.
        /// </summary>
        private bool TryGetTarget()
        {
            IMyTerminalBlock block;
            bool             canDisplaceBlock = LocalPlayer.CurrentBuilderBlock != null && !BvConfig.Current.targeting.canOpenIfPlacing,
                             canTarget = !canDisplaceBlock || BvConfig.Current.genUI.legacyModeEnabled;

            if (canTarget && TryGetTargetedBlockInternal(BvConfig.Current.targeting.maxOpenRange, out block))
            {
                if (block != null)
                {
                    TerminalPermissionStates permissions = block.GetAccessPermissions();

                    if ((permissions & TerminalPermissionStates.Granted) > 0 ||
                        LocalPlayer.HasAdminSetting(MyAdminSettingsEnum.UseTerminals))
                    {
                        if (Target.TBlock == null || block != Target.TBlock)
                        {
                            targetGrid.SetGrid(block.CubeGrid);
                            Target.SetBlock(targetGrid, block);

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if ((permissions & TerminalPermissionStates.GridUnfriendly) > 0)
                        {
                            hudNotification.Text = $"Access denied. Grid unfriendly.";
                        }
                        else
                        {
                            hudNotification.Text = "Access denied";
                        }

                        hudNotification.Show();
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 28
0
        public void DisplayMessage(int amount)
        {
            var time = MyAPIGateway.Session.GameDateTime - LastAliveTime;

            if (time.TotalSeconds > Notification.AliveTime)
            {
                CurrentValue = 0;
            }

            CurrentValue += amount;
            Notification.Hide();
            Notification.Font = CurrentValue < 0 ? "Red" : "Green";
            Notification.Text = string.Format("Reputation With {0} Changed By: {1}", ReputationFactionTarget, CurrentValue);
            Notification.ResetAliveTime();
            Notification.Show();
            LastAliveTime = MyAPIGateway.Session.GameDateTime;
            //Logger.MsgDebug(string.Format("Rep Message Displayed. Current Value {0} - ReceivedAmount: {1}", CurrentValue, amount), DebugTypeEnum.Owner);
        }
 protected override void Hit()
 {
     try
     {
         MrzUtils.ShowNotificationDebug("AddItems::AddItemsFuzzyOrLoot");
         if (_holdersInventory != null && _holdersInventory.AddItemsFuzzyOrLoot(Definition.IdToAdd, Definition.AmountToAdd))
         {
             UpdateDurability(-1);
         }
         else if (Holder == MySession.Static.PlayerEntity)
         {
             InventoryFullNotification.Show();
         }
     }
     catch (Exception e)
     {
         MrzUtils.ShowNotificationDebug(e.Message);
     }
 }
Ejemplo n.º 30
0
            private void ShowHudMessage(ref IMyHudNotification notify, string message, string printText, int printTime, string font)
            {
                if (printText == null)
                {
                    return;
                }

                try
                {
                    if (MyAPIGateway.Utilities != null && !MyAPIGateway.Utilities.IsDedicated)
                    {
                        if (printText == PRINT_GENERIC_ERROR)
                        {
                            printText = errorPrintText;
                        }
                        else if (printText == PRINT_MESSAGE)
                        {
                            printText = $"[ {modName} ERROR: {message} ]";
                        }

                        if (notify == null)
                        {
                            notify = MyAPIGateway.Utilities.CreateNotification(printText, printTime, font);
                        }
                        else
                        {
                            notify.Text      = printText;
                            notify.AliveTime = printTime;
                            notify.ResetAliveTime();
                        }

                        notify.Show();
                    }
                }
                catch (Exception e)
                {
                    Info("ERROR: Could not send notification to local client: " + e);
                    MyLog.Default.WriteLineAndConsole(modName + " logger error/exception: Could not send notification to local client: " + e);
                }
            }
Ejemplo n.º 31
0
        public override void UpdateOnceBeforeFrame()
        {
            try
            {
                if (Tool.CubeGrid.Physics?.Enabled != true || !Networker.Inited)
                {
                    NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
                    if (!Networker.Inited)
                    {
                        Networker.Init(SessionCore.ModID);
                    }
                    return;
                }
                ToolCargo = Tool.GetInventory();

                SyncBeamLength      = new AutoSet <float>(Tool, "BeamLength", 1, Checker: val => val >= MinBeamLengthBlocks && val <= MaxBeamLengthBlocks);
                SyncDistanceMode    = new AutoSet <bool>(Tool, "DistanceBasedMode");
                SyncSpeedMultiplier = new AutoSet <float>(Tool, "SpeedMultiplier", 1, Checker: val => val >= 1 && val <= 4);
                SyncBeamLength.GotValueFromServer      += Tool.UpdateVisual;
                SyncDistanceMode.GotValueFromServer    += Tool.UpdateVisual;
                SyncSpeedMultiplier.GotValueFromServer += Tool.UpdateVisual;

                CheckInitControls();
                Load();

                Tool.AppendingCustomInfo += Tool_AppendingCustomInfo;
                SessionCore.SaveRegister(Save);
                NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
                DebugNote    = MyAPIGateway.Utilities.CreateNotification($"{Tool.CustomName}", int.MaxValue, (IsWelder ? "Blue" : "Red"));
                Owner        = MyAPIGateway.Players.GetPlayer(Tool.OwnerId);
                if (SessionCore.Debug)
                {
                    DebugNote.Show();
                }
            }
            catch { }
        }