Example #1
0
        private static void DoLogging(EntityIdCooldownKey cooldownKey, MyCubeGrid grid)
        {
            RotorgunDetectorPlugin plugin = RotorgunDetectorPlugin.Instance;

            var cooldowns = plugin.LoggingCooldowns;

            if (!cooldowns.CheckCooldown(cooldownKey, "logging", out _))
            {
                return;
            }

            cooldowns.StartCooldown(cooldownKey, "logging", plugin.LoggingCooldown);

            grid = grid.GetBiggestGridInGroup();

            var gridOwnerList = grid.BigOwners;
            var ownerCnt      = gridOwnerList.Count;
            var gridOwner     = 0L;

            if (ownerCnt > 0 && gridOwnerList[0] != 0)
            {
                gridOwner = gridOwnerList[0];
            }
            else if (ownerCnt > 1)
            {
                gridOwner = gridOwnerList[1];
            }

            FILE_LOGGER.Warn("Possible Rotorgun found on grid " + grid.DisplayName + " owned by " + PlayerUtils.GetPlayerNameById(gridOwner));
        }
Example #2
0
        public static bool DetachDetection(MyMechanicalConnectionBlockBase __instance)
        {
            if (IsIrrelevantType(__instance))
            {
                return(true);
            }

            var motor = __instance as MyMotorBase;

            var session = RotorgunDetectorPlugin.Instance.Torch.CurrentSession;

            if (session == null || session.State != TorchSessionState.Loaded)
            {
                return(true);
            }

            RotorgunDetectorPlugin plugin = RotorgunDetectorPlugin.Instance;

            var grid = motor.CubeGrid;

            if (!IsPossibleRotorgun(grid, plugin.MinRotorGridCount))
            {
                return(true);
            }

            var cooldowns = plugin.DetachCooldowns;
            var key       = new EntityIdCooldownKey(grid.EntityId);

            if (!cooldowns.CheckCooldown(key, "detach", out long remainingSeconds))
            {
                long ownerId = motor.OwnerId;

                if (ownerId != 0)
                {
                    MyVisualScriptLogicProvider.SendChatMessage("Rotor Head cannot be placed for an other " + remainingSeconds + " seconds.", "Server", ownerId, "Red");
                }

                DoLogging(key, grid);

                return(false);
            }

            cooldowns.StartCooldown(key, "detach", plugin.DetachCooldown);

            return(true);
        }