示例#1
0
        /// <summary>
        /// Plays the RayAudio audio track assigned to the ID, or returns the WWise event name.
        /// This method is used in the AkSoundEngine.PostEvent patch to allow for posting audio events
        /// using Semi IDs, including RayAudio tracks and streams.
        /// </summary>
        /// <returns>Null if the ID matched a RayAudio audio track (which also plays it), or the WWise event name if the ID points to a WWise event.</returns>
        /// <param name="id">ID of the audio track.</param>
        /// <param name="source">Source GameObject.</param>
        internal static string PostEventOrReturnWWiseEventName(ID id, GameObject source)
        {
            if (!Audio.Ready)
            {
                return(null);
            }

            if (AudioEvent.AudioEventOverrides.ContainsKey(id))
            {
                return(PostEventOrReturnWWiseEventName(AudioEvent.AudioEventOverrides[id], source));
            }

            if (!Registry.AudioEvents.Contains(id))
            {
                var event_name = GetWWiseEventNameFromID(id);
                if (event_name != null)
                {
                    return(event_name);
                }
                else
                {
                    Logger.Error($"Audio event with ID '{id}' doesn't exist.");
                    return(null);
                }
            }
            else
            {
                return(Registry.AudioEvents[id].FirePostEvent(source));
            }
        }
示例#2
0
        /// <summary>
        /// Compares two hashes based on the SemiModVerification repository.
        /// </summary>
        /// <returns><c>true</c>, if hashes match, <c>false</c> otherwise.</returns>
        /// <param name="mod_id">ID of the mod.</param>
        /// <param name="hash">The computed hash.</param>
        public static bool ValidateHashOnline(string mod_id, byte[] hash)
        {
            var url = $"{BASE_VERIFICATION_URL}{mod_id}";

            Logger.Debug($"Validating from URL: {url}");
            byte[] online_hash = null;
            using (var client = new WebClient()) {
                ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
                client.Encoding = Encoding.UTF8;
                try {
                    online_hash = client.DownloadData(url);
                } catch (WebException e) {
                    Logger.Error($"[{e.GetType().Name}] {e.Message}");
                    Logger.ErrorPretty(e.StackTrace);
                    return(false);
                }
            }

            return(ValidateHash(online_hash, hash));
        }
示例#3
0
        internal static void LoadLocalizationTextGeneral(TextReader reader, Func <string, bool> dupe_check, Action <string, StringTableManager.StringCollection> assign_action, bool overwrite = false, string default_namespace = null)
        {
            // mostly based on copied StringTableManager code
            // all the files have duplicate loading code but it all seems to be doing
            // the same thing /shrug
            StringTableManager.StringCollection coll = null;

            string text;

            while ((text = reader.ReadLine()) != null)
            {
                if (!text.StartsWithInvariant("//"))
                {
                    if (text.StartsWithInvariant("#"))
                    {
                        coll = new StringTableManager.ComplexStringCollection();

                        if (default_namespace != null)
                        {
                            var id = text.Substring(1);
                            if (id.Count(':') > 1)
                            {
                                Logger.Error($"Failed to add invalid key to table: {id}");
                                continue;
                            }

                            if (!id.Contains(":"))
                            {
                                id = $"{default_namespace}:{id}";
                            }

                            if (id.StartsWithInvariant("gungeon:"))
                            {
                                text = $"#{id.Substring("gungeon:".Length)}";
                            }
                            else
                            {
                                text = $"#{id}";
                            }
                        }

                        if (dupe_check.Invoke(text) && !overwrite)
                        {
                            Logger.Error($"Failed to add duplicate key to table: {text}");
                        }
                        else
                        {
                            assign_action.Invoke(text, coll);
                        }
                    }
                    else
                    {
                        if (coll == null)
                        {
                            continue;
                        }
                        // ignore the KEY,EN stuff on ui.txt
                        // we don't need it anyway because we have our own ID system

                        string[] array = text.Split(new char[] {
                            '|'
                        });
                        if (array.Length == 1)
                        {
                            coll.AddString(array[0], 1f);
                        }
                        else
                        {
                            coll.AddString(array[1], float.Parse(array[0]));
                        }
                    }
                }
            }
        }
            internal tk2dSpriteAnimationFrame[] ConstructFrames(YAML.Clip clip, tk2dSpriteCollectionData collection)
            {
                var frames = new List <tk2dSpriteAnimationFrame>();

                for (int i = 0; i < clip.Frames.Count; i++)
                {
                    var mframe = clip.Frames[i];

                    var sprite_id = Collection.GetSpriteDefinitionIndex(mframe.Definition);
                    if (sprite_id == null)
                    {
                        Logger.Error($"Definition '{mframe.Definition}' doesn't exist!");
                        continue;
                    }

                    var frame = new tk2dSpriteAnimationFrame {
                        spriteCollection  = collection,
                        spriteId          = Collection.GetSpriteDefinitionIndex(mframe.Definition).Value,
                        groundedFrame     = true,
                        invulnerableFrame = false
                    };

                    if (clip.AllInvulnerable)
                    {
                        frame.invulnerableFrame = true;
                    }
                    if (clip.AllOffGround)
                    {
                        frame.groundedFrame = false;
                    }

                    var @event = YAML.Frame.DEFAULT_EVENT;
                    if (mframe.Event != null)
                    {
                        frame.triggerEvent = true;
                        @event             = mframe.Event;
                    }
                    frame.eventInfo    = @event.Name;
                    frame.eventVfx     = @event.PlayVFX;
                    frame.eventStopVfx = @event.StopVFX;
                    frame.eventInt     = @event.Int;
                    frame.eventFloat   = @event.Float;
                    frame.eventAudio   = @event.Audio;

                    var outline = tk2dSpriteAnimationFrame.OutlineModifier.Unspecified;

                    if (@event.Outline != null)
                    {
                        outline = (tk2dSpriteAnimationFrame.OutlineModifier)Enum.Parse(typeof(tk2dSpriteAnimationFrame.OutlineModifier), @event.Outline.Replace('_', ' ').ToTitleCaseInvariant().Replace(" ", ""));
                    }

                    frame.eventOutline = outline;

                    var lerp_emissive = YAML.Event.DEFAULT_LERP_EMISSIVE;
                    if (@event.LerpEmissive != null)
                    {
                        lerp_emissive           = @event.LerpEmissive;
                        frame.eventLerpEmissive = true;
                    }


                    frame.eventLerpEmissiveTime  = lerp_emissive.Time;
                    frame.eventLerpEmissivePower = lerp_emissive.Power;

                    // TODO reverse order, or not reverse order?
                    frames.Add(frame);
                }

                return(frames.ToArray());
            }
示例#5
0
 public void LogError(string tag, object message, Object context)
 {
     GungeonLogger.Error(_FormatMessage(message, tag: tag, context: context));
 }