コード例 #1
0
        public void MoveLCD()
        {
            try
            {
                var subpart = npcCrewBlock.GetSubpart("NPC_Weapons_LCDRotation");
                subpart.SetEmissiveParts("Emissive", Color.Red, 0.4f);

                var     initialMatrix = subpart.PositionComp.LocalMatrix;
                double  rotationX     = 0.0f;
                double  rotationY     = 0.0f;
                double  rotationZ     = 0.01;
                Vector3 scaleDown     = new Vector3D(0.998, 0.998, 1);
                Vector3 scaleUp       = new Vector3D(1.002, 1.002, 1);

                if (AnimationLoopLCD == 1500)
                {
                    AnimationLoopLCD = 0;
                    scaleDirection   = scaleDown;
                }
                if (AnimationLoopLCD == 0)
                {
                    RotationTimeLCD = -1;
                    scaleDirection  = scaleDown;
                }
                if (AnimationLoopLCD == 750)
                {
                    RotationTimeLCD = 1;
                    scaleDirection  = scaleUp;
                }
                var rotationAndScaleMatrix = MatrixD.CreateRotationX(rotationX) * MatrixD.CreateRotationY(rotationY) *
                                             MatrixD.CreateRotationZ(rotationZ) * MatrixD.CreateScale(scaleDirection);

                var translationMatrix = MatrixD.CreateTranslation(0.0010 * RotationTimeLCD, 0.0001 * RotationTimeLCD, -0.00003 * RotationTimeLCD);

                var matrix = rotationAndScaleMatrix * initialMatrix * translationMatrix;
                subpart.PositionComp.LocalMatrix = matrix;
                AnimationLoopLCD++;
            }
            catch (Exception e)
            {
                MyVisualScriptLogicProvider.ShowNotificationToAll("Update Error" + e, 2500, "Red");
            }
        }
コード例 #2
0
        internal static MyEntity Spawn(MyPhysicalInventoryItem item, BoundingBoxD box, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            MyEntity thrownEntity = MyEntities.CreateFromObjectBuilder(PrepareBuilder(ref item), false);

            if (thrownEntity != null)
            {
                float    radius  = thrownEntity.PositionComp.LocalVolume.Radius;
                Vector3D vectord = Vector3.Max(((Vector3)(box.Size / 2.0)) - new Vector3(radius), Vector3.Zero);
                box = new BoundingBoxD(box.Center - vectord, box.Center + vectord);
                Vector3D randomPosition = MyUtils.GetRandomPosition(ref box);
                AddToPos(thrownEntity, randomPosition, motionInheritedFrom);
                thrownEntity.Physics.ForceActivate();
                if (MyVisualScriptLogicProvider.ItemSpawned != null)
                {
                    MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, thrownEntity.EntityId, item.Amount.ToIntSafe(), randomPosition);
                }
            }
            return(thrownEntity);
        }
コード例 #3
0
ファイル: ModEntry.cs プロジェクト: Sk1tch/ExplorerCleanup
        static void TrackedGridScan()
        {
            int count = 0;

            MyVisualScriptLogicProvider.SendChatMessage("Checking for grids to broadcast..", "SERVER", 0, "Red");
            List <long> gridsToTrash = new List <long>();

            foreach (long entityId in trackedGrids)
            {
                // Validating twice, it maybe better to instead listen for events on the grid
                GridValidator gridValidator = new GridValidator(entityId);
                GridStatus    gridStatus    = gridValidator.Validate(Config);

                if (gridStatus > GridStatus.Marked)
                {
                    BroadcastInfo  broadcastInfo = gridValidator.GridToBroadcastInfo();
                    BroadcastError err           = BroadcastManager.AddBroadcastInfo(broadcastInfo, true);

                    switch (err)
                    {
                    case BroadcastError.NotEnoughBlocks:
                    case BroadcastError.NotEnoughFatBlocks:
                    case BroadcastError.TooFarFromPlayers:
                        MyVisualScriptLogicProvider.SendChatMessage($"Trashing {broadcastInfo} {Enum.GetName(typeof(BroadcastError), err)}", "SERVER", 0, "Red");
                        gridsToTrash.Add(entityId);
                        break;

                    case BroadcastError.TooCloseToPlayers:
                        MyVisualScriptLogicProvider.SendChatMessage($"Ignoring {broadcastInfo} {Enum.GetName(typeof(BroadcastError), err)}", "SERVER", 0, "Red");
                        break;

                    default:
                        MyVisualScriptLogicProvider.SendChatMessage($"Broadcasting {broadcastInfo}", "SERVER", 0, "Red");
                        count++;
                        break;
                    }
                }
            }

            Util.TrashGrids(gridsToTrash);
            trackedGrids.Clear();
        }
コード例 #4
0
        /// <summary>
        /// Decides if a block about to be spawned is permitted by the player
        /// </summary>
        /// <param name="definition"></param>
        /// <returns></returns>
        private static bool Prefix(DefinitionIdBlit definition)
        {
            if (!BlockLimiterConfig.Instance.EnableLimits)
            {
                return(true);
            }

            var block = MyDefinitionManager.Static.GetCubeBlockDefinition(definition);

            if (block == null)
            {
                return(true);
            }

            var remoteUserId = MyEventContext.Current.Sender.Value;
            var player       = MySession.Static.Players.TryGetPlayerBySteamId(remoteUserId);
            var playerId     = player.Identity.IdentityId;

            if (Block.IsWithinLimits(block, playerId, null))
            {
                return(true);
            }


            var b = block.BlockPairName;
            var p = player.DisplayName;

            if (BlockLimiterConfig.Instance.EnableLog)
            {
                BlockLimiter.Instance.Log.Info($"Blocked {p} from placing a {b}");
            }

            //ModCommunication.SendMessageTo(new NotificationMessage($"You've reach your limit for {b}",5000,MyFontEnum.Red),remoteUserId );
            var msg = BlockLimiterConfig.Instance.DenyMessage.Replace("{BN}", $"{b}");

            MyVisualScriptLogicProvider.SendChatMessage($"{msg}", BlockLimiterConfig.Instance.ServerName, playerId, MyFontEnum.Red);

            Utilities.SendFailSound(remoteUserId);
            Utilities.ValidationFailed();

            return(false);
        }
コード例 #5
0
        public void MoveLeftArm()
        {
            try
            {
                MyEntitySubpart subpartAstronaut;
                MyEntitySubpart subpart;

                npcCrewBlock.TryGetSubpart("NPC_Astronaut_Standing_BlankLCD_Test", out subpartAstronaut);
                subpartAstronaut.TryGetSubpart("NPC_Astronaut_Standing_LeftArm_BlankLCD", out subpart);

                if (subpart == null)
                {
                    return;
                }
                //double rotation = 0.002f;
                var    initialMatrix = subpart.PositionComp.LocalMatrix;
                double rotationX     = -0.0005f;
                double rotationY     = -0.0005f;

                if (AnimationLoopLeftArm == 400)
                {
                    AnimationLoopLeftArm = 0;
                }
                if (AnimationLoopLeftArm == 0)
                {
                    TranslationTimeLeftArm = -1;
                }
                if (AnimationLoopLeftArm == 200)
                {
                    TranslationTimeLeftArm = 1;
                }

                var rotationMatrix = MatrixD.CreateRotationX(rotationX * TranslationTimeLeftArm) * MatrixD.CreateRotationY(rotationY * TranslationTimeLeftArm);
                var matrix         = rotationMatrix * initialMatrix;
                subpart.PositionComp.LocalMatrix = matrix;
                AnimationLoopLeftArm++;
            }
            catch (Exception e)
            {
                MyVisualScriptLogicProvider.ShowNotificationToAll("Update Error" + e, 2500, "Red");
            }
        }
コード例 #6
0
 public override void UpdateAfterSimulation()
 {
     try
     {
         if (npcCrewBlock.IsWorking && npcCrewBlock.IsFunctional)
         {
             if (playAnimation)
             {
                 MoveHead();
                 MoveLeftArm();
                 MoveRightArm();
                 MoveLCD();
             }
         }
     }
     catch (Exception e)
     {
         MyVisualScriptLogicProvider.ShowNotificationToAll("Update Error" + e, 2500, "Red");
     }
 }
コード例 #7
0
        void UpdateCommandNotification()
        {
            MyVisualScriptLogicProvider.RemoveNotification(_commandNotificationId);

            if (Quest >= Quest.Ended)
            {
                return;
            }

            if (_selfProfiled)
            {
                const string Msg = "Type in chat: !lag inspect";
                _commandNotificationId = MyVisualScriptLogicProvider.AddNotification(Msg, "Green", PlayerId);
            }
            else
            {
                const string Msg = "Type in chat: !lag profile";
                _commandNotificationId = MyVisualScriptLogicProvider.AddNotification(Msg, "Green", PlayerId);
            }
        }
コード例 #8
0
ファイル: ChatManager.cs プロジェクト: jturp/RivalAI
        public static void SendChatDataOverNetwork(ChatMessage chatData, bool sendToServer)
        {
            if (string.IsNullOrWhiteSpace(chatData.ReturnMessage) == false && sendToServer == false)
            {
                MyVisualScriptLogicProvider.ShowNotification(chatData.ReturnMessage, 5000, "White", chatData.PlayerId);
            }

            var byteChatData = MyAPIGateway.Utilities.SerializeToBinary <ChatMessage>(chatData);
            var syncData     = new SyncContainer(SyncMode.ChatCommand, byteChatData);
            var byteSyncData = MyAPIGateway.Utilities.SerializeToBinary <SyncContainer>(syncData);

            if (sendToServer == true)
            {
                MyAPIGateway.Multiplayer.SendMessageToServer(SyncManager.NetworkId, byteSyncData);
            }
            else
            {
                MyAPIGateway.Multiplayer.SendMessageTo(SyncManager.NetworkId, byteSyncData, chatData.SteamId);
            }
        }
コード例 #9
0
ファイル: WorldModule.cs プロジェクト: TorchAPI/Essentials
        private static bool RemoveFromFaction_Internal(MyIdentity identity)
        {
            var fac = MySession.Static.Factions.GetPlayerFaction(identity.IdentityId);

            if (fac == null)
            {
                return(false);
            }

            /*
             * VisualScriptLogicProvider takes care of removal of faction if last
             * identity is kicked, and promotes the next player in line to Founder
             * if the founder is being kicked.
             *
             * Factions must have a founder otherwise calls like MyFaction.Members.Keys will NRE.
             */
            MyVisualScriptLogicProvider.KickPlayerFromFaction(identity.IdentityId);

            return(true);
        }
コード例 #10
0
        private void PlayClip(IAudioClip clip)
        {
            var player = MyAPIGateway.Session.Player;
            var ent    = player?.Controller?.ControlledEntity?.Entity;

            if (ent != null)
            {
                if (playerEntityId != ent.EntityId)
                {
                    if (localPlayerSoundEmitter != null)                     // Player has died and lost their old sound emitter
                    {
                        localPlayerSoundEmitter.StopSound(true);
                    }

                    localPlayerSoundEmitter = new MyEntity3DSoundEmitter(ent as VRage.Game.Entity.MyEntity);
                    playerEntityId          = ent.EntityId;
                }
                if (clip.Filename != null)
                {
                    var soundPair = new MySoundPair(clip.Filename);
                    localPlayerSoundEmitter.StopSound(true);
                    localPlayerSoundEmitter.PlaySingleSound(soundPair);
                }
            }

            // Added V22
            //MyAPIGateway.Multiplayer.MultiplayerActive
            if (MyAPIGateway.Multiplayer.IsServer)
            {
                //            MyVisualScriptLogicProvider.SendChatMessage(clip.Subtitle, clip.Speaker, 0, clip.Font);
                string[] aLines = clip.Subtitle.Split('\n');
                foreach (var line in aLines)
                {
                    MyVisualScriptLogicProvider.SendChatMessage(line, clip.Speaker, 0, clip.Font);
                }
            }
            // chat, notifications, billboards... Bad on DS.
            // The following should NOT be done on  DS because nowhere to show it..
            MyAPIGateway.Utilities.ShowNotification(clip.Speaker + ": " + clip.Subtitle, clip.DisappearTimeMs, clip.Font);
            timeUntilNextAudioSeconds = clip.DisappearTimeMs / 1000 + 2; // Add a little 2 second pause between them
        }
コード例 #11
0
        public static bool Write(string s, int level, int debugLevel = GlobalDebugLevel, bool chat = true)
        {
            try
            {
                if (debugLevel < level)
                {
                    return(true);
                }

                MyLog.Default.WriteLineAndConsole($"STC Utilities Debug: {s}");

                if (Core.Instance == null)
                {
                    return(true);
                }

                if (Core.Instance.AdminIdentityId <= 0L)
                {
                    Core.Instance.AdminIdentityId = MyAPIGateway.Players.TryGetIdentityId(Core.Instance.AdminSteamId);
                }

                if (chat && !Core.Instance.DisableChatDebugLogging && Core.Instance.AdminIdentityId > 0L)
                {
                    MyAPIGateway.Utilities.InvokeOnGameThread(() =>
                    {
                        try
                        { MyVisualScriptLogicProvider.SendChatMessage(s, "Debug", Core.Instance.AdminIdentityId); }
                        catch (Exception e)
                        {
                            MyLog.Default.WriteLineAndConsole(e.ToString());
                            Core.Instance.DisableChatDebugLogging = true;
                        }
                    });
                }
            }
            catch
            {
            }

            return(true);
        }
コード例 #12
0
        private void CheckPlayerNotifications()
        {
            try
            {
                foreach (var item in new Dictionary <long, int>(TimeThrusterNoteWasSentToPlayer))
                {
                    if (item.Value != 0 && Timer > item.Value + 180)
                    {
                        MyAPIGateway.Utilities.InvokeOnGameThread(() =>
                        {
                            try
                            {
                                MyVisualScriptLogicProvider.RemoveNotification(LastThrusterHeatNoteSentToPlayer[item.Key], item.Key);
                                TimeThrusterNoteWasSentToPlayer[item.Key] = 0;
                            }
                            catch (Exception e)
                            { Debug.HandleException(e); }
                        });
                    }
                }

                foreach (var item in new Dictionary <long, int>(TimeWeaponNoteWasSentToPlayer))
                {
                    if (item.Value != 0 && Timer > item.Value + 180)
                    {
                        MyAPIGateway.Utilities.InvokeOnGameThread(() =>
                        {
                            try
                            {
                                MyVisualScriptLogicProvider.RemoveNotification(LastWeaponHeatNoteSentToPlayer[item.Key], item.Key);
                                TimeWeaponNoteWasSentToPlayer[item.Key] = 0;
                            }
                            catch (Exception e)
                            { Debug.HandleException(e); }
                        });
                    }
                }
            }
            catch (Exception e)
            { Debug.HandleException(e); }
        }
コード例 #13
0
        public static void AssignPlayer(long playerId)
        {
            if (!PluginCore.Instance.Config.Enable || !PluginCore.Instance.Config.AssignFaction || playerId == 0)
            {
                return;
            }

            var factionDictionary = MySession.Static.Factions.Factions;

            if (factionDictionary == null || factionDictionary.Count == 0)
            {
                return;
            }
            IMyFaction potentialFaction = null;

            if (MySession.Static.Factions.GetPlayerFaction(playerId) != null)
            {
                return;
            }
            foreach (var(factionId, faction) in factionDictionary)
            {
                if (faction.IsEveryoneNpc() || MySession.Static.Players.IdentityIsNpc(faction.FounderId))
                {
                    continue;
                }

                if (faction.Members.Count >= PluginCore.Instance.Config.FactionSize)
                {
                    continue;
                }

                potentialFaction = faction;
            }

            if (potentialFaction == null)
            {
                CreatePlayerFaction(playerId);
                return;
            }
            MyVisualScriptLogicProvider.SetPlayersFaction(playerId, potentialFaction.Tag);
        }
    private void PlayerSpawned(long playerId)
    {
        //logger.WriteLine("Request of Player "+ playerId);

        IMyIdentity playerIdentity = Player(playerId);

        //logger.WriteLine("Found Identity " + playerId);

        if (playerIdentity != null)
        {
            //logger.WriteLine("Player is " + playerIdentity.DisplayName);

            var playerList = new List <IMyPlayer>();
            MyAPIGateway.Players.GetPlayers(playerList, p => p != null && p.IdentityId == playerIdentity.IdentityId);

            var player = playerList.FirstOrDefault();
            if (player != null)
            {
                if (!MustBeExecuted(player))
                {
                    logger.WriteLine("Player " + playerIdentity.DisplayName + " did not spawn near special Medbay!");
                    return;
                }

                MyVisualScriptLogicProvider.SetPlayersHydrogenLevel(playerIdentity.IdentityId, 0);

                IMyCharacter character = player.Character;

                if (character == null)
                {
                    logger.WriteLine("Player " + playerIdentity.DisplayName + " has no Character yet!");
                }

                spawnToolsRemover.Remove(character);
            }
            else
            {
                logger.WriteLine("Player " + playerIdentity.DisplayName + " not Found!");
            }
        }
    }
コード例 #15
0
        /// <summary>
        /// Checks blocks being built in creative with multiblock placement.
        /// </summary>
        /// <param name="__instance"></param>
        /// <param name="area"></param>
        /// <returns></returns>
        private static bool BuildBlocksArea(MyCubeGrid __instance, MyCubeGrid.MyBlockBuildArea area)
        {
            if (!BlockLimiterConfig.Instance.EnableLimits)
            {
                return(true);
            }

            var def  = MyDefinitionManager.Static.GetCubeBlockDefinition(area.DefinitionId);
            var grid = __instance;

            int blocksToBuild = (int)area.BuildAreaSize.X * (int)area.BuildAreaSize.Y * (int)area.BuildAreaSize.Z;


            if (grid == null)
            {
                BlockLimiter.Instance.Log.Debug("Null grid in BuildBlockHandler");
                return(true);
            }

            var remoteUserId = MyEventContext.Current.Sender.Value;
            var playerId     = Utilities.GetPlayerIdFromSteamId(remoteUserId);


            if (!Block.IsWithinLimits(def, playerId, grid.EntityId, blocksToBuild))
            {
                if (BlockLimiterConfig.Instance.EnableLog)
                {
                    BlockLimiter.Instance.Log.Info($"Blocked {Utilities.GetPlayerNameFromSteamId(remoteUserId)} from placing {def.ToString().Substring(16)} due to limits");
                }
                //ModCommunication.SendMessageTo(new NotificationMessage($"You've reach your limit for {b}",5000,MyFontEnum.Red),remoteUserId );
                var msg = BlockLimiterConfig.Instance.DenyMessage.Replace("{BN}", $"{def.ToString().Substring(16)}");
                MyVisualScriptLogicProvider.SendChatMessage($"{msg}", BlockLimiterConfig.Instance.ServerName, playerId, MyFontEnum.Red);
                Utilities.SendFailSound(remoteUserId);
                Utilities.ValidationFailed();

                return(false);
            }


            return(true);
        }
コード例 #16
0
        public void SendMotd(MyPlayer player)
        {
            long playerId = player.Identity.IdentityId;

            if (!string.IsNullOrEmpty(Config.MotdUrl))
            {
                if (MyGuiSandbox.IsUrlWhitelisted(Config.MotdUrl))
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay(Config.MotdUrl, playerId);
                }
                else
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={Config.MotdUrl}", playerId);
                }
            }

            var id = player.Client.SteamUserId;

            if (id <= 0) //can't remember if this returns 0 or -1 on error.
            {
                return;
            }

            string name = player.Identity?.DisplayName ?? "player";

            bool newUser = !Config.KnownSteamIds.Contains(id);

            if (newUser)
            {
                Config.KnownSteamIds.Add(id);
            }

            if (newUser && !string.IsNullOrEmpty(Config.NewUserMotd))
            {
                ModCommunication.SendMessageTo(new DialogMessage(MySession.Static.Name, "New User Message Of The Day", Config.NewUserMotd.Replace("%player%", name)), id);
            }
            else if (!string.IsNullOrEmpty(Config.Motd))
            {
                ModCommunication.SendMessageTo(new DialogMessage(MySession.Static.Name, "Message Of The Day", Config.Motd.Replace("%player%", name)), id);
            }
        }
コード例 #17
0
ファイル: Fighter.cs プロジェクト: Blue64/Space_Engineers
 public void LoadKeenAI()
 {
     try
     {
         if (KeenAILoaded)
         {
             return;
         }
         (RC as MyRemoteControl).SetAutoPilotSpeedLimit(RC.GetSpeedCap());
         MyVisualScriptLogicProvider.SetDroneBehaviourFull(RC.Name, presetName: FighterSetup.Preset, maxPlayerDistance: FighterSetup.SeekDistance, playerPriority: FighterSetup.PlayerPriority, assignToPirates: FighterSetup.AssignToPirates);
         if (FighterSetup.AmbushMode == true)
         {
             MyVisualScriptLogicProvider.DroneSetAmbushMode(RC.Name, ambushModeOn: true);
         }
         KeenAILoaded = true;
     }
     catch (Exception Scrap)
     {
         Grid.LogError("LoadKeenAI", Scrap);
     }
 }
コード例 #18
0
        private bool HealTarget(IMyPlayer player)
        {
            float health = MyVisualScriptLogicProvider.GetPlayersHealth(player.IdentityId);

            if (health <= 0)
            {
                return(true);
            }

            if (health + m_healthRefillPerTick <= 100f)
            {
                MyVisualScriptLogicProvider.SetPlayersHealth(player.IdentityId, health + m_healthRefillPerTick);
            }
            else
            {
                MyVisualScriptLogicProvider.SetPlayersHealth(player.IdentityId, 100f);
                return(true);
            }

            return(false);
        }
コード例 #19
0
        public static MyEntity Spawn(MyPhysicalInventoryItem item, MatrixD worldMatrix, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            var floatingBuilder = PrepareBuilder(ref item);

            floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
            var thrownEntity = MyEntities.CreateFromObjectBuilderAndAdd(floatingBuilder);

            if (thrownEntity != null)
            {
                thrownEntity.Physics.ForceActivate();
                ApplyPhysics(thrownEntity, motionInheritedFrom);
                Debug.Assert(thrownEntity.Save == true, "Thrown item will not be saved. Feel free to ignore this.");

                //Visual scripting action
                if (MyVisualScriptLogicProvider.ItemSpawned != null)
                {
                    MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, thrownEntity.EntityId, item.Amount.ToIntSafe(), worldMatrix.Translation);
                }
            }
            return(thrownEntity);
        }
コード例 #20
0
        public void NotifyPlayer(long identityId)
        {
            string message;

            if (Config.NotifyDelaySeconds <= 0)
            {
                message = "Watch out! Someone bought your current location. They will be here soon!";
            }
            else
            {
                message = "Watch out! Someone bought your current location within the last " + Config.NotifyDelaySeconds.ToString("#,##0") + " seconds. They will be here soon!";
            }

            MyVisualScriptLogicProvider.ShowNotification(
                message, 10000, MyFontEnum.White, identityId);

            MyVisualScriptLogicProvider.SendChatMessage(
                message, Torch.Config.ChatName, identityId, MyFontEnum.Red);

            Log.Info("Identity " + identityId + " (" + PlayerUtils.GetPlayerNameById(identityId) + ") was Notified about their GPS being bought!");
        }
コード例 #21
0
        private void BlackList1(bool activate)
        {
            try
            {
                var upKey    = MyAPIGateway.Input.GetControl(MyKeys.Up);
                var downKey  = MyAPIGateway.Input.GetControl(MyKeys.Down);
                var leftKey  = MyAPIGateway.Input.GetControl(MyKeys.Left);
                var rightkey = MyAPIGateway.Input.GetControl(MyKeys.Right);
                var addKey   = MyAPIGateway.Input.GetControl(MyKeys.Add);
                var subKey   = MyAPIGateway.Input.GetControl(MyKeys.Subtract);

                if (upKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(upKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (downKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(downKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (leftKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(leftKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (rightkey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(rightkey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (addKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(addKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (subKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(subKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }

                BlackListActive1 = activate;
            }
            catch (Exception ex) { Log.Line($"Exception in BlackList1: {ex}"); }
        }
コード例 #22
0
    private void PlayerSpawned(long playerId)
    {
        //logger.WriteLine("Request of Player "+ playerId);

        IMyIdentity playerIdentity = Player(playerId);

        //logger.WriteLine("Found Identity " + playerId);

        if (playerIdentity != null)
        {
            //logger.WriteLine("Player is " + playerIdentity.DisplayName);

            var playerList = new List <IMyPlayer>();
            MyAPIGateway.Players.GetPlayers(playerList, p => p != null && p.IdentityId == playerIdentity.IdentityId);

            var player = playerList.FirstOrDefault();
            if (player != null)
            {
                MyVisualScriptLogicProvider.SetPlayersHydrogenLevel(playerIdentity.IdentityId, 0);
            }
        }
    }
コード例 #23
0
        public override void UpdateOnceBeforeFrame()
        {
            base.UpdateOnceBeforeFrame();
            IsCountingDown = false;
            if (Sync.IsServer)
            {
                for (int i = 0; i < Toolbar.ItemCount; ++i)
                {
                    Toolbar.UpdateItem(i);
                    Toolbar.ActivateItemAtIndex(i);
                }

                //Visual scripting action
                if (CubeGrid.Physics != null && MyVisualScriptLogicProvider.TimerBlockTriggered != null)
                {
                    MyVisualScriptLogicProvider.TimerBlockTriggered(CustomName.ToString());
                }
            }
            UpdateEmissivity();
            DetailedInfo.Clear();
            RaisePropertiesChanged();
        }
コード例 #24
0
        private bool DoesTargetNeedLifeSupport(IMyPlayer player)
        {
            if (player == null)
            {
                return(false);
            }

            float health   = MyVisualScriptLogicProvider.GetPlayersHealth(player.IdentityId);
            float oxygen   = MyVisualScriptLogicProvider.GetPlayersOxygenLevel(player.IdentityId);
            float hydrogen = MyVisualScriptLogicProvider.GetPlayersHydrogenLevel(player.IdentityId);
            float energy   = MyVisualScriptLogicProvider.GetPlayersEnergyLevel(player.IdentityId);

            if (health < 100f ||
                (oxygen < m_o2RefillLevel && m_hasOxygen) ||
                (hydrogen < m_h2RefillLevel && m_hasHydrogen) ||
                energy < m_energyRefillLevel)
            {
                return(true);
            }

            return(false);
        }
コード例 #25
0
        public static void Spawn(MyPhysicalInventoryItem item, BoundingSphereD sphere, MyPhysicsComponentBase motionInheritedFrom, MyVoxelMaterialDefinition voxelMaterial, Action <MyEntity> OnDone)
        {
            Vector3D?relativeOffset = null;

            MyEntities.CreateFromObjectBuilderParallel(PrepareBuilder(ref item), false, delegate(MyEntity entity) {
                if (voxelMaterial.DamagedMaterial != MyStringHash.NullOrEmpty)
                {
                    voxelMaterial = MyDefinitionManager.Static.GetVoxelMaterialDefinition(voxelMaterial.DamagedMaterial.ToString());
                }
                ((MyFloatingObject)entity).VoxelMaterial = voxelMaterial;
                float radius = entity.PositionComp.LocalVolume.Radius;
                double num2  = Math.Max((double)(sphere.Radius - radius), (double)0.0);
                sphere       = new BoundingSphereD(sphere.Center, num2);
                Vector3D randomBorderPosition = MyUtils.GetRandomBorderPosition(ref sphere);
                AddToPos(entity, randomBorderPosition, motionInheritedFrom);
                if (MyVisualScriptLogicProvider.ItemSpawned != null)
                {
                    MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, entity.EntityId, item.Amount.ToIntSafe(), randomBorderPosition);
                }
                OnDone(entity);
            }, null, null, relativeOffset, false, false);
        }
コード例 #26
0
ファイル: Bridge.cs プロジェクト: Bishbash777/SEDB-LITE
        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);
コード例 #27
0
 public void LoadKeenAi()
 {
     try
     {
         if (KeenAiLoaded)
         {
             return;
         }
         (Rc as MyRemoteControl)?.SetAutoPilotSpeedLimit(Rc.GetSpeedCap());
         MyVisualScriptLogicProvider.SetDroneBehaviourFull(Rc.Name, presetName: _fighterSetup.Preset, maxPlayerDistance: _fighterSetup.SeekDistance, playerPriority: 0, assignToPirates: _fighterSetup.AssignToPirates);
         if (_fighterSetup.AmbushMode)
         {
             MyVisualScriptLogicProvider.DroneSetAmbushMode(Rc.Name);
         }
         MyVisualScriptLogicProvider.TargetingSetWhitelist(Rc.Name);
         KeenAiLoaded = true;
     }
     catch (Exception scrap)
     {
         Grid.LogError("LoadKeenAI", scrap);
     }
 }
コード例 #28
0
        public static BroadcastError AddBroadcastInfo(BroadcastInfo broadcastInfo, bool broadcast = false)
        {
            HashSet <long> playersToNotify;
            BroadcastError err = PlayersWithinSafeRange(broadcastInfo.Location, out playersToNotify);

            if (err == BroadcastError.TooCloseToPlayers || err == BroadcastError.TooFarFromPlayers)
            {
                return(err);
            }
            else
            {
                err = ValidateBlockRequirements(broadcastInfo);

                if (err != BroadcastError.Ok)
                {
                    return(err);
                }

                if (err == BroadcastError.Ok && broadcast == true)
                {
                    foreach (long identityId in playersToNotify)
                    {
                        // If player near owned Antenna consider adding more detils to grid description and increasing range
                        // e.g. Antenna Size (big/small), Est. Grid Power, Grid Name, Ship/Station
                        IMyGps myGPS = AddGPSToPlayer(identityId, broadcastInfo);

                        if (myGPS != null)
                        {
                            broadcastInfo.MyGps.Add(myGPS);
                        }
                    }
                    BroadcastingGrids.Add(broadcastInfo);
                    MyVisualScriptLogicProvider.SendChatMessage($"Broadcasting {BroadcastingGrids.Count} offending grids", "SERVER", 0, "Red");
                }

                return(BroadcastError.Ok);
            }
        }
コード例 #29
0
        public void Kill(string playerName)
        {
            /*
             * First we try killing the player when hes online. This is easy and fast
             * and can also kill the player while being seated.
             */
            var player = Utilities.GetPlayerByNameOrId(playerName);

            if (player != null)
            {
                MyVisualScriptLogicProvider.SetPlayersHealth(player.IdentityId, 0);

                Context.Torch.CurrentSession?.Managers?.GetManager <IChatManagerServer>()?.SendMessageAsSelf
                    ($"{player.DisplayName} was killed by an admin");

                return;
            }

            /*
             * If we could not find the player there is a chance he is offline, in that case we try inflicting
             * damage to the character as the VST will not help us with offline characters.
             */
            if (!Utilities.TryGetEntityByNameOrId(playerName, out IMyEntity entity))
            {
                Context.Respond($"Entity '{playerName}' not found.");
                return;
            }

            if (entity is IMyCharacter)
            {
                var destroyable = entity as IMyDestroyableObject;

                destroyable.DoDamage(1000f, MyDamageType.Radioactivity, true);

                Context.Torch.CurrentSession?.Managers?.GetManager <IChatManagerServer>()?.SendMessageAsSelf
                    ($"{entity.DisplayName} was killed by an admin");
            }
        }
コード例 #30
0
        public IEnumerator Reset()
        {
            var entities        = GetEntities();
            var floatingObjects = GetEntitiesOfType <MyFloatingObject>(entities);

            foreach (var floatingObject in floatingObjects)
            {
                MyEntities.Remove(floatingObject);
            }

            foreach (var entity in entities)
            {
                if (entity is MyCubeGrid)
                {
                    var grid = (MyCubeGrid)entity;

                    //if (grid.Hierarchy != null)
                    //{
                    //    grid.Hierarchy.GetTopMostParent().Delete();
                    //}

                    //if (grid.DisplayName == "ThrowerArm - WithHinges")
                    //{
                    //    entity.Close();
                    //}

                    grid.SendGridCloseRequest();

                    // entity.Close();
                }
            }

            entities.Clear();

            yield return(null);

            MyVisualScriptLogicProvider.SpawnLocalBlueprint("ThrowerArm - WithHinges", new Vector3D(new Vector3(-300, 300, 300)));
        }