예제 #1
0
        bool FillPropertiesFromPublished()
        {
            var results = WorkshopHelper.GetItemsBlocking(m_modId);

            if (results?.Count > 0)
            {
                System.Threading.Thread.Sleep(1000); // Fix for DLC not being filled in
                if (results.Count > 0)
                {
                    m_workshopItems[m_modId[0]] = results[0];

                    if (m_modId.Length > 1 && results.Count > 1)
                    {
                        m_workshopItems[m_modId[1]] = results[1];
                    }

                    m_title = results[0].Title;

                    // Check if the mod owner in the sbmi matches steam owner
                    var owner = results[0].OwnerId;

                    if (m_visibility == null)
                    {
                        m_visibility = (PublishedFileVisibility)(int)results[0].Visibility;
                    }

#if SE
                    m_dlcs = results[0].DLCs.ToArray();
#endif
                    m_deps = results[0].Dependencies.ToArray();

                    MyDebug.AssertDebug(owner == MyGameService.UserId);
                    if (owner != MyGameService.UserId)
                    {
                        MySandboxGame.Log.WriteLineError(string.Format("Owner mismatch! Mod owner: {0}; Current user: {1}", owner, MyGameService.UserId));
                        MySandboxGame.Log.WriteLineError("Upload/Publish FAILED!");
                        return(false);
                    }
                    return(true);
                }
                return(false);
            }
            return(false);
        }
예제 #2
0
        public static bool ReplaceMethod(MethodInfo methodtoreplace, MethodInfo methodtoinject, Type[] types = null)
        {
            ParameterInfo[] sourceParameters;
            ParameterInfo[] destinationParameters;

            MyDebug.AssertRelease(methodtoreplace != null);
            if (methodtoreplace != null && methodtoinject != null)
            {
                sourceParameters      = methodtoreplace.GetParameters();
                destinationParameters = methodtoinject.GetParameters();
                MyDebug.AssertDebug(sourceParameters.Length == destinationParameters.Length);
                bool valid = true;

                // Verify signatures
                for (var x = 0; x < Math.Min(destinationParameters.Length, sourceParameters.Length); x++)
                {
                    MyDebug.AssertDebug(destinationParameters[x].ParameterType == sourceParameters[x].ParameterType);
                    if (destinationParameters[x].ParameterType != sourceParameters[x].ParameterType)
                    {
                        valid = false;
                    }
                }

                if (sourceParameters.Length != destinationParameters.Length || !valid)
                {
                    methodtoreplace = null;
                }
            }

            if (methodtoreplace != null && methodtoinject != null)
            {
                MethodUtil.ReplaceMethod(methodtoreplace, methodtoinject);
                return(true);
            }
            else
            {
                return(false);
            }
        }