示例#1
0
        static void DetachBlock(IMySlimBlock block, IMyAngleGrinder grinder)
        {
            if (!MyAPIGateway.Session.IsServer)
            {
                return;
            }

            MyCubeBlockDefinition blockDef = (MyCubeBlockDefinition)block.BlockDefinition;
            string blockName = blockDef.DisplayNameText;
            string gridName  = $"(Detached {blockName})";

            IMyCubeGrid detachFrom = block.CubeGrid;

            MyObjectBuilder_CubeBlock blockOb = block.GetObjectBuilder();
            MyObjectBuilder_CubeGrid  gridOb  = CreateNewGridOB(block.CubeGrid, blockOb, gridName);

            block.CubeGrid.RemoveBlock(block, true);

            MyCubeGrid createdGrid = MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(gridOb) as MyCubeGrid;

            if (createdGrid == null)
            {
                Log.Error($"Failed to create a new grid! obj={gridOb}; new entId={gridOb.EntityId.ToString()}");
                MyVisualScriptLogicProvider.SendChatMessageColored($"Failed to create detached block grid!", Color.Red, Log.ModName, grinder.OwnerIdentityId, MyFontEnum.Debug);
                return;
            }

            Log.Info($"Detached '{blockName}' from '{detachFrom.CustomName}' ({detachFrom.EntityId.ToString()}); new grid id={createdGrid.EntityId.ToString()}");

            // sending "to server" so that it happens serverside too if server is a player (or singleplayer).
            DetachEffectsPacket packet = new DetachEffectsPacket(createdGrid.GetBlocks().First());

            AdvancedWeldingMod.Instance.Networking.SendToServer(packet);
        }
示例#2
0
 void EquippedGrinderChanged(IMyAngleGrinder grinder)
 {
     if (grinder != null && !InformedAboutFeature && MyAPIGateway.Session?.Player != null)
     {
         InformedAboutFeature = true;
         MyVisualScriptLogicProvider.SendChatMessageColored("Type /detach in chat to see grinder features.", Color.Green, Log.ModName, MyAPIGateway.Session.Player.IdentityId);
     }
 }
示例#3
0
 public void Write(LogType t, string message)
 {
     if (MyAPIGateway.Session?.Player != null)
     {
         var msg_c = Util.ColorFor(t);
         MyVisualScriptLogicProvider.SendChatMessageColored(message, msg_c, ModName, MyAPIGateway.Session.Player.IdentityId);
     }
 }
        public static void ShowChatMessage(string message, long playerid = 0)
        {
            //this takes the death message and sends it out to all players
            Logging.Instance.WriteLine("ShowMessage " + message);

            //only the server should do this
            if (!MyAPIGateway.Multiplayer.IsServer)
            {
                return;
            }
            MyVisualScriptLogicProvider.SendChatMessageColored(message, VRageMath.Color.OrangeRed, (playerid != 0 ? "~" : "") + "Trading", playerid);
        }
示例#5
0
        public static void ShowChatMessage(string message, long playerid = 0)
        {
            //this takes the death message and sends it out to all players
            MyLog.Default.WriteLine("ShowMessage " + message);

            //only the server should do this
            if (!MyAPIGateway.Multiplayer.IsServer)
            {
                return;
            }
            MyVisualScriptLogicProvider.SendChatMessageColored(message, VRageMath.Color.GreenYellow, (playerid != 0 ? "~" : "") + "Biogas", playerid);
        }
示例#6
0
        public static void Draw(int number = -1)
        {
            Module.Config.NumberTotalDraw++;

            var random       = new Random();
            var randomNumber = number == -1 ? random.Next(0, Module.Config.MaxNumber) : number;

            MyVisualScriptLogicProvider.SendChatMessageColored(String.Format(TranslatesUtils.GetGeneralId("draw"), randomNumber), Color.Red, TranslatesUtils.GetGeneralId("lotto"));

            var listPlayersWin = ListPlayersWin(randomNumber);

            if (listPlayersWin.Count == 0)
            {
                MyVisualScriptLogicProvider.SendChatMessageColored(TranslatesUtils.GetGeneralId("dontWin"), Color.Red, TranslatesUtils.GetGeneralId("lotto"));
            }
            else
            {
                Module.Config.NumberTotalPlayersWin++;
                var gain = Module.Config.GainPartage ? Module.Config.GainTotal / listPlayersWin.Count : Module.Config.GainTotal;
                foreach (var item in listPlayersWin)
                {
                    MyVisualScriptLogicProvider.SendChatMessageColored(String.Format(TranslatesUtils.GetGeneralId("win"), PlayersUtils.GetPlayerNameById(item.playerId)), Color.Red, TranslatesUtils.GetGeneralId("lotto"));
                    Module.PlayersWin.ListPlayersWin.Add(new Models.PlayersWinStruct(item.playerName, item.playerId, randomNumber, gain, DateTime.Now));
                }
                Module.Config.GainTotal = 0;
            }

            if (Module.Config.GainTotal + Module.Config.Gain > Module.Config.GainMax)
            {
                Module.Config.GainTotal = Module.Config.GainMax;
            }
            else
            {
                Module.Config.GainTotal += Module.Config.Gain;
            }

            var next = ConfigUtils.NextDraw();

            Module.Config.NextDraw = next;

            MyVisualScriptLogicProvider.SendChatMessageColored(String.Format(TranslatesUtils.GetGeneralId("next"), next, Module.Config.GainTotal), Color.Red, TranslatesUtils.GetGeneralId("lotto"));

            Module.PlayersPlay.ListPlayersPlay.Clear();

            Module.SaveConfig();
            Module.SavePlayersPlay();
            Module.SavePlayersWin();
        }
示例#7
0
        private Task Discord_MessageCreated(DiscordClient discord, DSharpPlus.EventArgs.MessageCreateEventArgs e)
        {
            if (Plugin.DEBUG)
            {
                Log.WriteLineToConsole("Discord message received!");
            }

            if (!e.Author.IsBot && Plugin.m_configuration.DiscordToGame)
            {
                if (Plugin.m_configuration.ChannelID.Contains(e.Channel.Id.ToString()))
                {
                    string sender  = e.Guild.GetMemberAsync(e.Author.Id).Result.Username;
                    var    dSender = Plugin.m_configuration.DiscordChatAuthorFormat.Replace("{p}", sender);

                    //Fix potential message event duplication?
                    if (lastMessage.Equals(dSender + e.Message.Content))
                    {
                        return(Task.CompletedTask);
                    }

                    lastMessage = dSender + e.Message.Content;
                    MyVisualScriptLogicProvider.SendChatMessageColored(e.Message.Content, VRageMath.Color.MediumPurple, dSender, default, Plugin.m_configuration.GlobalColor);
示例#8
0
 private void ShowDisabledMsg()
 {
     MyVisualScriptLogicProvider.SendChatMessageColored("Apologies, config commands are currently disabled in multiplayer due to sync issues. reload is the only avaliable command", Color.Yellow);
 }