public override HashSet <IMyReplicable> GetDependencies()
        {
            m_dependencies.Clear();

            MyPlayerCollection playerCollection = MySession.Static.Players;
            var connectedPlayers = playerCollection.GetOnlinePlayers();

            foreach (var player in connectedPlayers)
            {
                if (player.Character == Instance)
                {
                    var broadcasters = Instance.RadioReceiver.GetRelayedBroadcastersForPlayer(player.Identity.IdentityId);
                    foreach (var broadcaster in broadcasters)
                    {
                        IMyReplicable dep = MyExternalReplicable.FindByObject(broadcaster.Entity);
                        if (dep != null)
                        {
                            m_dependencies.Add(dep.GetParent() ?? dep);
                        }
                    }
                }
            }

            return(m_dependencies);
        }
Exemple #2
0
        /// <summary>
        /// Gets priority of different replicable.
        /// E.g. can be used to get priority of grid when calling GetPriority on cube block.
        /// </summary>
        public float GetPriority(IMyReplicable replicable)
        {
            while (replicable.HasToBeChild)
            {
                var parent = replicable.GetParent();
                if (parent == null)
                {
                    break;
                }
                else
                {
                    replicable = parent;
                }
            }

            MyReplicableClientData data;

            return(m_clientData.Replicables.TryGetValue(replicable, out data) ? data.Priority : 0);
        }
 bool TryGetParent(IMyReplicable replicable, out IMyReplicable parent)
 {
     parent = replicable.GetParent();
     return(parent != null);
 }