<commit_before>using System;
using System.Collections.Generic;
using Fasterflect;
using Playblack.EventSystem;
using Playblack.EventSystem.Events;
using Playblack.Pooling;
using Playblack.Savegame;
using UnityEngine;

#if UNITY_EDITOR

using UnityEditor;

#endif

namespace Playblack.Csp {

    public delegate void SimpleSignal();

    public delegate void ParameterSignal(string param);

    /// <summary>
    /// Tracks and manages signals coming in and out of the gameobject this handler is attached to.
    /// </summary>
    [DisallowMultipleComponent]
    [SaveableComponent]
    public class SignalProcessor : MonoBehaviour {

        /// <summary>
        /// Signals this Entity can receive and process.
        /// This list represents volatile information and needs to be rebuilt
        /// manually each time a signal processor is instantiated
        /// </summary>
        protected Dictionary<string, List<InputFunc>> inputFuncs;

        public Dictionary<string, List<InputFunc>> InputFuncs {
            get {
                if (this.inputFuncs == null || this.inputFuncs.Count == 0) {
                    this.RebuildInputs();
                }
                return this.inputFuncs;
            }
        }

        [SerializeField]
        [SaveableField(SaveField.FIELD_PROTOBUF_OBJECT)]
        protected List<OutputFunc> outputs;

        public List<OutputFunc> Outputs {
            get {
                if (this.outputs == null) {
                    this.ReadOutputs();
                }
                return this.outputs;
            }
#if UNITY_EDITOR
            set {
                this.outputs = value;
            }
#endif
        }

        /// <summary>
        /// This cache is used to speed up the lookups for input funcs on components by remembering
        /// their type and all attached attributes to it.
        /// </summary>
        private GenericObjectPoolMap<Type, InputFuncAttribute[]> inputFuncCache = new GenericObjectPoolMap<Type, InputFuncAttribute[]>(10, 50);

        public InputFunc GetInputFunc(string name, string component) {
            if (inputFuncs == null || inputFuncs.Count == 0) {
                this.RebuildInputs();
            }
            if (!inputFuncs.ContainsKey(component)) {
                return null;
            }

            for (int i = 0; i < inputFuncs[component].Count; ++i) {
                if (inputFuncs[component][i].Name == name) {
                    return inputFuncs[component][i];
                }
            }
            return null;
        }

        /// <summary>
        /// Call this to rebuild the input funcs.
        /// This needs to be called everytime the signalprocessor object is instantiated.
        /// The data is used in OutputEvent. It will look in a SignalProcessors input-list
        /// for things to call when an output is fired.
        /// </summary>
        private void RebuildInputs() {
            var components = GetComponents<Component>();
            if (inputFuncs == null) {
                inputFuncs = new Dictionary<string, List<InputFunc>>();
            }
            else {
                inputFuncs.Clear();
            }

            for (int i = 0; i < components.Length; ++i) {
                var type = components[i].GetType();
                var methods = type.MethodsWith(Flags.InstancePublic, typeof(InputFuncAttribute));
                InputFuncAttribute[] attribs = null;
                if (inputFuncCache.Has(type)) {
                    attribs = inputFuncCache.Get(type);
                }
                else {<commit_msg>Changes to account for namespace / method refactorings in csp data<commit_after>using System;
using System.Collections.Generic;
using Fasterflect;
using Playblack.EventSystem;
using Playblack.EventSystem.Events;
using Playblack.Pooling;
using Playblack.Savegame;
using UnityEngine;

#if UNITY_EDITOR

using UnityEditor;

#endif

namespace Playblack.Csp {

    public delegate void SimpleSignal();

    public delegate void ParameterSignal(string param);

    /// <summary>
    /// Tracks and manages signals coming in and out of the gameobject this handler is attached to.
    /// </summary>
    [DisallowMultipleComponent]
    [SaveableComponent]
    [InitializeOnLoad]
    public class SignalProcessor : MonoBehaviour {

        /// <summary>
        /// Signals this Entity can receive and process.
        /// This list represents volatile information and needs to be rebuilt
        /// manually each time a signal processor is instantiated
        /// </summary>
        protected Dictionary<string, List<InputFunc>> inputFuncs;

        public Dictionary<string, List<InputFunc>> InputFuncs {
            get {
                if (this.inputFuncs == null || this.inputFuncs.Count == 0) {
                    this.RebuildInputs();
                }
                return this.inputFuncs;
            }
        }

        [SerializeField]
        [SaveableField(SaveField.FIELD_PROTOBUF_OBJECT)]
        protected List<OutputFunc> outputs;

        public List<OutputFunc> Outputs {
            get {
                if (this.outputs == null) {
                    this.ReadOutputs();
                }
                return this.outputs;
            }
#if UNITY_EDITOR
            set {
                this.outputs = value;
            }
#endif
        }

        /// <summary>
        /// This cache is used to speed up the lookups for input funcs on components by remembering
        /// their type and all attached attributes to it.
        /// </summary>
        private GenericObjectPoolMap<Type, InputFuncAttribute[]> inputFuncCache = new GenericObjectPoolMap<Type, InputFuncAttribute[]>(10, 50);

        public InputFunc GetInputFunc(string name, string component) {
            if (inputFuncs == null || inputFuncs.Count == 0) {
                this.RebuildInputs();
            }
            if (!inputFuncs.ContainsKey(component)) {
                Debug.Log("Component " + component + " is not part of this GameObject. No InputFunc for it can be found.");
                return null;
            }

            for (int i = 0; i < inputFuncs[component].Count; ++i) {
                if (inputFuncs[component][i].Name == name) {
                    return inputFuncs[component][i];
                }
            }
            return null;
        }

        /// <summary>
        /// Call this to rebuild the input funcs.
        /// This needs to be called everytime the signalprocessor object is instantiated.
        /// The data is used in OutputEvent. It will look in a SignalProcessors input-list
        /// for things to call when an output is fired.
        /// </summary>
        private void RebuildInputs() {
            Debug.Log("Rebuilding InputFunc cache on " + this.gameObject.name);
            var components = GetComponents<Component>();
            if (inputFuncs == null) {
                inputFuncs = new Dictionary<string, List<InputFunc>>();
            }
            else {
                inputFuncs.Clear();
            }

            for (int i = 0; i < components.Length; ++i) {
                var type = components[i].GetType();
                var methods = type.MethodsWith(Flags.InstancePublic, typeof(InputFuncAttribute));
                InputFuncAttribute[] attribs = null;
                if (inputFuncCache.Has(type)) {
                    attribs = inputFuncCache.Get(type);
                }
                else {
{'fraction_non_alphanumeric': 0.09256286784376672, 'fraction_numerical': 0.002140181915462814, 'mean_word_length': 1.7723396366332962, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4091754', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1817, 'n_words': 558}