Ejemplo n.º 1
0
        private void LogGrid(MyCubeGrid grid)
        {
            try {
                long ownerId = OwnershipUtils.GetOwner(grid);

                string name = PlayerUtils.GetPlayerNameById(ownerId);

                IMyFaction faction = GetFactionForPlayer(ownerId);

                string factionString = "";
                if (faction != null)
                {
                    factionString = "[" + faction.Tag + "]";
                }

                string ownedString = "Owned by: " + name + " " + factionString;

                long   gridId   = grid.EntityId;
                string gridName = grid.DisplayName;

                Log.Info("Broadcasted " + gridId + " " + gridName + " " + ownedString);
            } catch (Exception e) {
                Log.Error(e);
            }
        }
        private KeyValuePair <long, List <MyCubeGrid> > CheckGroupsDays(HashSetReader <MyGroups <MyCubeGrid, MyGridMechanicalGroupData> .Node> nodes, bool checkFaction, DateTime today)
        {
            List <MyCubeGrid> gridsList = new List <MyCubeGrid>();

            foreach (var groupNodes in nodes)
            {
                MyCubeGrid cubeGrid = groupNodes.NodeData;

                if (cubeGrid.Physics == null)
                {
                    continue;
                }

                gridsList.Add(cubeGrid);
            }

            if (gridsList.Count == 0)
            {
                return(new KeyValuePair <long, List <MyCubeGrid> >(0, gridsList));
            }

            MyCubeGrid biggestGrid = GridUtils.GetBiggestGridInGroup(gridsList);

            if (biggestGrid == null)
            {
                return(new KeyValuePair <long, List <MyCubeGrid> >(0, new List <MyCubeGrid>()));
            }

            long ownerId      = OwnershipUtils.GetOwner(biggestGrid);
            long daysInactive = 0;

            if (ownerId != 0L && !PlayerUtils.IsNpc(ownerId))
            {
                var identity     = PlayerUtils.GetIdentityById(ownerId);
                var lastSeenDate = PlayerUtils.GetLastSeenDate(identity);

                daysInactive = (today - lastSeenDate).Days;

                if (checkFaction)
                {
                    var faction = FactionUtils.GetPlayerFaction(ownerId);

                    if (faction != null)
                    {
                        foreach (long member in faction.Members.Keys)
                        {
                            identity     = PlayerUtils.GetIdentityById(member);
                            lastSeenDate = PlayerUtils.GetLastSeenDate(identity);

                            daysInactive = Math.Min(daysInactive, (today - lastSeenDate).Days);
                        }
                    }
                }
            }

            return(new KeyValuePair <long, List <MyCubeGrid> >(daysInactive, gridsList));
        }
Ejemplo n.º 3
0
        public bool HasRightToMove(IMyPlayer player, MyCubeGrid grid)
        {
            var result = player.GetRelationTo(OwnershipUtils.GetOwner(grid)) == MyRelationsBetweenPlayerAndBlock.Owner;

            if (Config.AllowInFaction && !result)
            {
                result = player.GetRelationTo(OwnershipUtils.GetOwner(grid)) == MyRelationsBetweenPlayerAndBlock.FactionShare;
            }
            return(result);
        }
        public static bool OwnershipCorrect(MyCubeGrid grid, long playerId, bool checkFactions) {

            /* If Player is owner we are totally fine and can allow it */
            if(grid.BigOwners.Contains(playerId))
                return true;

            /* If he is not owner and we dont want to allow checks for faction members... then prohibit */
            if (!checkFactions)
                return false;

            /* If checks for faction are allowed grab owner and see if factions are equal */
            long gridOwner = OwnershipUtils.GetOwner(grid);

            return FactionUtils.HavePlayersSameFaction(playerId, gridOwner);
        }
Ejemplo n.º 5
0
        public void Outboundwormhole(string ip, string outfile, double xgate, double ygate, double zgate)
        {
            BoundingSphereD gate = new BoundingSphereD(new Vector3D(xgate, ygate, zgate), Config.InRadiusGate);

            foreach (var entity in MyAPIGateway.Entities.GetTopMostEntitiesInSphere(ref gate))
            {
                var grid = (entity as VRage.Game.ModAPI.IMyCubeGrid);
                if (grid != null)
                {
                    var playerInCharge = MyAPIGateway.Players.GetPlayerControllingEntity(entity);
                    if (playerInCharge != null && OwnershipUtils.GetOwner(entity as MyCubeGrid) == playerInCharge.IdentityId)//hasrighttomove(playerInCharge, entity as MyCubeGrid))
                    {
                        var WormholeDrives = new List <IMyJumpDrive>();
                        var gts            = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(grid);
                        gts.GetBlocksOfType(WormholeDrives);
                        if (Config.DontNeedJD)
                        {
                            List <MyCubeGrid> grids = GridFinder.FindGridList(grid.EntityId.ToString(), playerInCharge as MyCharacter, Config.IncludeConnectedGrids);
                            if (grids == null)
                            {
                                return;
                            }
                            if (grids.Count == 0)
                            {
                                return;
                            }
                            var filename = playerInCharge.SteamUserId.ToString() + "_" + grid.GetFriendlyName() + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");

                            Sandbox.Game.MyVisualScriptLogicProvider.CreateLightning(new Vector3D(xgate, ygate, zgate));
                            if (GridManager.SaveGrid(CreatePath(outfile, filename), filename, ip, Config.KeepOriginalOwner, Config.ExportProjectorBlueprints, grids))
                            {
                                foreach (var delgrid in grids)
                                {
                                    delgrid.Delete();
                                }
                            }
                        }
                        else if (WormholeDrives.Count > 0)
                        {
                            foreach (var WormholeDrive in WormholeDrives)
                            {
                                if (WormholeDrive.OwnerId == playerInCharge.IdentityId && WormholeDrive.Enabled && WormholeDrive.CurrentStoredPower == WormholeDrive.MaxStoredPower && (WormholeDrive.BlockDefinition.SubtypeId.ToString() == Config.JumpDriveSubid || Config.WorkWithAllJD))
                                {
                                    WormholeDrive.CurrentStoredPower = 0;
                                    if (Config.DisableJD)
                                    {
                                        foreach (var jd in WormholeDrives)
                                        {
                                            jd.Enabled = false;
                                        }
                                    }
                                    List <MyCubeGrid> grids = GridFinder.FindGridList(grid.EntityId.ToString(), playerInCharge as MyCharacter, Config.IncludeConnectedGrids);
                                    if (grids == null)
                                    {
                                        return;
                                    }
                                    if (grids.Count == 0)
                                    {
                                        return;
                                    }
                                    var filename = playerInCharge.SteamUserId.ToString() + "_" + playerInCharge.DisplayName + "_" + grid.DisplayName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");

                                    Sandbox.Game.MyVisualScriptLogicProvider.CreateLightning(new Vector3D(xgate, ygate, zgate));
                                    if (GridManager.SaveGrid(CreatePath(outfile, filename), filename, ip, Config.KeepOriginalOwner, Config.ExportProjectorBlueprints, grids))
                                    {
                                        foreach (var delgrid in grids)
                                        {
                                            delgrid.Delete();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }