static void ShareBlueprintRequest(ref ShareBlueprintMsg msg, MyNetworkClient sender)
 {
     if (Sync.IsServer && msg.SendToId != Sync.MyId)
     {
         Sync.Layer.SendMessage(ref msg, msg.SendToId);
     }
     else
     {
         var itemId = msg.WorkshopId;
         var name   = msg.Name;
         var info   = new MyBlueprintItemInfo(MyBlueprintTypeEnum.SHARED, id: itemId);
         var item   = new MyGuiControlListbox.Item(new StringBuilder(name.ToString()), userData: info, icon: MyGuiConstants.TEXTURE_BLUEPRINTS_ARROW.Normal);
         item.ColorMask = new Vector4(0.7f);
         if (!m_recievedBlueprints.Any(item2 => (item2.UserData as MyBlueprintItemInfo).PublishedItemId == (item.UserData as MyBlueprintItemInfo).PublishedItemId))
         {
             m_recievedBlueprints.Add(item);
             m_blueprintList.Add(item);
             if (sender != null)
             {
                 var notification = new MyHudNotificationDebug(sender.DisplayName + " just shared a blueprint with you.", 2500);
                 MyHud.Notifications.Add(notification);
             }
         }
     }
 }
Esempio n. 2
0
        void OnFactionsStateChanged(MyFactionCollection.MyFactionStateChange change, long fromFactionId, long toFactionId, long playerId, long sender)
        {
            if (change == MyFactionCollection.MyFactionStateChange.FactionMemberKick && sender != playerId && LocalPlayerId == playerId)
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionKicked),
                    messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextYouHaveBeenKickedFromFaction)));
            }

            if (change == MyFactionCollection.MyFactionStateChange.FactionMemberAcceptJoin && sender != playerId && LocalPlayerId == playerId && !Battle)
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionInfo),
                    messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextYouHaveBeenAcceptedToFaction)));
            }

            if (change == MyFactionCollection.MyFactionStateChange.FactionMemberAcceptJoin && (Static.Factions[toFactionId].IsFounder(LocalPlayerId) || Static.Factions[toFactionId].IsLeader(LocalPlayerId)) && playerId != 0)
            {
                var identity = Sync.Players.TryGetIdentity(playerId);
                if (identity != null)
                {
                    var joiningName = identity.DisplayName;
                    var notification = new MyHudNotificationDebug("Player \"" + joiningName + "\" has joined your faction.", 2500);
                    MyHud.Notifications.Add(notification);
                }
            }

            if (change == MyFactionCollection.MyFactionStateChange.FactionMemberLeave && (Static.Factions[toFactionId].IsFounder(LocalPlayerId) || Static.Factions[toFactionId].IsLeader(LocalPlayerId)) && playerId != 0)
            {
                var identity = Sync.Players.TryGetIdentity(playerId);
                if (identity != null)
                {
                    var joiningName = identity.DisplayName;
                    var notification = new MyHudNotificationDebug("Player \"" + joiningName + "\" has left your faction.", 2500);
                    MyHud.Notifications.Add(notification);
                }
            }

            if (change == MyFactionCollection.MyFactionStateChange.FactionMemberSendJoin && (Static.Factions[toFactionId].IsFounder(LocalPlayerId) || Static.Factions[toFactionId].IsLeader(LocalPlayerId)) && playerId != 0)
            {
                var identity = Sync.Players.TryGetIdentity(playerId);
                if (identity != null)
                {
                    var joiningName = identity.DisplayName;
                    var notification = new MyHudNotificationDebug("Player \"" + joiningName + "\" has applied to join your faction.", 2500);
                    MyHud.Notifications.Add(notification);
                }
            }
        }
 static void ShareBlueprintRequest(ref ShareBlueprintMsg msg, MyNetworkClient sender)
 {
     if (Sync.IsServer && msg.SendToId != Sync.MyId)
     {
         Sync.Layer.SendMessage(ref msg, msg.SendToId);
     }
     else
     {
         var itemId = msg.WorkshopId;
         var name = msg.Name;
         var info = new MyBlueprintItemInfo(MyBlueprintTypeEnum.SHARED, id: itemId);
         var item = new MyGuiControlListbox.Item(new StringBuilder(name.ToString()), userData: info, icon: MyGuiConstants.TEXTURE_BLUEPRINTS_ARROW.Normal);
         item.ColorMask = new Vector4(0.7f);
         if (!m_recievedBlueprints.Any(item2 => (item2.UserData as MyBlueprintItemInfo).PublishedItemId == (item.UserData as MyBlueprintItemInfo).PublishedItemId))
         {
             m_recievedBlueprints.Add(item);
             m_blueprintList.Add(item);
             if (sender != null)
             {
                 var notification = new MyHudNotificationDebug(sender.DisplayName + " just shared a blueprint with you.", 2500);
                 MyHud.Notifications.Add(notification);
             }
         }
     }
 }
        static void ShareBlueprintRequestClient(ulong workshopId, string name, ulong sendToId, string senderName)
        {
            var itemId = workshopId;
            var info = new MyBlueprintItemInfo(MyBlueprintTypeEnum.SHARED, id: itemId);
            var item = new MyGuiControlListbox.Item(new StringBuilder(name.ToString()), userData: info, icon: MyGuiConstants.TEXTURE_BLUEPRINTS_ARROW.Normal);
            item.ColorMask = new Vector4(0.7f);
            if (!m_recievedBlueprints.Any(item2 => (item2.UserData as MyBlueprintItemInfo).PublishedItemId == (item.UserData as MyBlueprintItemInfo).PublishedItemId))
            {
                m_recievedBlueprints.Add(item);
                m_blueprintList.Add(item);

                var notification = new MyHudNotificationDebug(senderName + " just shared a blueprint with you.", 2500);
                MyHud.Notifications.Add(notification);
            }
        }