Пример #1
0
 public static bool IsOwnerOrFactionOwned(MyCubeGrid grid, long playerId, bool doFactionCheck)
 {
     if (grid.BigOwners.Contains(playerId))
     {
         return(true);
     }
     else
     {
         if (!doFactionCheck)
         {
             return(false);
         }
         long ownerId = GetOwner(grid);
         //check if the owner is a faction member, i honestly dont know the difference between grid.BigOwners and grid.SmallOwners
         return(FacUtils.InSameFaction(playerId, ownerId));
     }
 }
Пример #2
0
        public void transmit()
        {
            foreach (MyPlayer p in MySession.Static.Players.GetOnlinePlayers())
            {
                List <IMyGps> playergpsList = MyAPIGateway.Session?.GPS.GetGpsList(p.Identity.IdentityId);

                if (playergpsList == null)
                {
                    break;
                }

                foreach (IMyGps gps in playergpsList)
                {
                    if (gps.Description.Contains("Cronch"))
                    {
                        MyAPIGateway.Session?.GPS.RemoveGps(p.Identity.IdentityId, gps);
                    }
                }
            }
            foreach (var group in MyCubeGridGroups.Static.Logical.Groups)
            {
                bool NPC = false;
                foreach (var item in group.Nodes)
                {
                    MyCubeGrid grid = item.NodeData;
                    // TransmitPlugin.Log.Info(grid.DisplayName);
                    if (((int)grid.Flags & 4) != 0)
                    {
                        //concealed
                        break;
                    }
                    if (grid.IsStatic && !TransmitPlugin.config.broadcastStations)
                    {
                        break;
                    }
                    if (MyGravityProviderSystem.IsPositionInNaturalGravity(grid.PositionComp.GetPosition()) && !TransmitPlugin.config.broadcastInGravity)
                    {
                        break;
                    }

                    //this bit requires a fac utils to get the faction tag, you can remove it if you dont need it
                    foreach (long l in grid.BigOwners)
                    {
                        if (FacUtils.GetFactionTag(l) != null && FacUtils.GetFactionTag(l).Length > 3)
                        {
                            NPC = true;
                        }
                    }

                    if (NPC)
                    {
                        break;
                    }
                    int PCU = 0;
                    PCU = grid.BlocksPCU;
                    Vector3 location = grid.PositionComp.GetPosition();
                    //get the gps
                    float           broadcastRange = 0;
                    MyGpsCollection gpsCollection  = (MyGpsCollection)MyAPIGateway.Session?.GPS;


                    broadcastRange = grid.BlocksPCU * TransmitPlugin.config.meterPerPCU;


                    if (PCU < TransmitPlugin.config.minimumPCU)
                    {
                        break;
                    }
                    IMyFaction gridOwner = FacUtils.GetPlayersFaction(FacUtils.GetOwner(grid));

                    foreach (MyPlayer p in MySession.Static.Players.GetOnlinePlayers())
                    {
                        List <MyGps> gpsList  = new List <MyGps>();
                        float        distance = Vector3.Distance(location, p.GetPosition());
                        if (distance <= broadcastRange)
                        {
                            MyGps gps;
                            //add a new gps point if player is in range
                            if (gridOwner != null)
                            {
                                if (gridOwner.IsNeutral(p.Identity.IdentityId) || gridOwner.IsFriendly(p.Identity.IdentityId))
                                {
                                    gps = CreateGps(grid, Color.RoyalBlue, 60, broadcastRange);
                                }
                                else
                                {
                                    gps = CreateGps(grid, Color.Red, 60, broadcastRange);
                                }
                            }
                            else
                            {
                                gps = CreateGps(grid, Color.Red, 60, broadcastRange);
                            }

                            gpsList.Add(gps);
                        }
                        foreach (MyGps gps in gpsList)
                        {
                            MyGps gpsRef   = gps;
                            long  entityId = 0L;
                            entityId = gps.EntityId;
                            gpsCollection.SendAddGps(p.Identity.IdentityId, ref gpsRef, entityId, TransmitPlugin.config.soundForGPS);
                        }
                    }
                }
            }
        }