示例#1
0
    private void DecideSlap(Hand WhichHand)
    {
        if (WhichHand != null && WhichHand._SlapAble.Count > 0)
        {
            Nuisance   BufferNuisance = WhichHand._SlapAble[0].GetComponent <Nuisance>();
            enums.Type BufferType     = BufferNuisance._DistractionType;
            switch (BufferType)
            {
            case enums.Type.normal:
                NormalSlap(WhichHand);
                break;

            case enums.Type.dog:
                ObjectThrowStart(WhichHand);
                break;

            case enums.Type.holy:
                SlapBarricateStart(WhichHand);
                break;

            default:
                break;
            }
        }
    }
示例#2
0
        private void Load()
        {
            _effects = new Dictionary <string, DrunkEffectData>();

            string[] resources = Assembly.GetExecutingAssembly().GetManifestResourceNames();

            foreach (string s in resources)
            {
                if (s.StartsWith(PATH))
                {
                    string name = s.Substring(PATH.Length, s.Length - PATH.Length - EXTENSION.Length);
                    Logger.log.Info($"Loading > {name}");
                    var def = Utils.LoadSFX(s);
                    if (disableByDefault.Contains(def.ReferenceName))
                    {
                        def.EnabledByDefault = false;
                    }
                    _effects.Add(name, def);
                }
            }

            try
            {
                var go = new GameObject($"{nameof(DSAssetLoader)}TempGameObject");
                foreach (Type t in Utils.GetTypesInNamespace(NUISANCE_NAMESPACE))
                {
                    Nuisance instance = go.AddComponent(t) as Nuisance;

                    if (_effects.TryGetValue(instance.Name, out DrunkEffectData data))
                    {
                        data.RuntimeType = t;
                    }
                    else
                    {
                        Logger.log.Warn($"No effect matching Type \"{t.Name}\"!");
                    }

                    UnityEngine.Object.Destroy(instance);
                }
                UnityEngine.Object.Destroy(go);
            }
            catch (Exception ex)
            {
                Logger.log.Error($"Loader Type matcher encountered an error: {ex.Message}");
                Logger.log.Debug(ex.StackTrace);
            }

            foreach (DrunkEffectData data in _effects.Values)
            {
                if (!_pluginConfig.Nuisances.Any(x => x.Name.Equals(data.ReferenceName)))
                {
                    _pluginConfig.Nuisances.Add(new PluginConfig.SavedNuisance()
                    {
                        Enabled = data.EnabledByDefault,
                        Name    = data.ReferenceName
                    });
                }
            }
        }
        public void AddNuisance(Type T)
        {
            if (this.gameObject.GetComponent(T) != null)
            {
                return;
            }
            Nuisance n = this.gameObject.AddComponent(T) as Nuisance;

            _container.Inject(n);
            _attachedNuisanceList.Add(n);
        }