Exemple #1
0
        static BuffBHandler AttachBuffBHandler(NPC n, int slot, int type)
        {
            if (slot == -1)
            {
                return(null);
            }

            BuffBHandler h = null;

            if (Handler.BuffDef.DefsByType.ContainsKey(type))
            {
                var d = Handler.BuffDef.DefsByType[type];

                if (d.CreateBehaviour != null)
                {
                    var b = d.CreateBehaviour();

                    if (b != null)
                    {
                        b.Mod = d.Mod == PrismApi.VanillaInfo ? null : ModData.mods[d.Mod];

                        h = new BuffBHandler();

                        h.behaviours.Add(b);
                    }
                }
            }

            var bs = ModData.mods.Values.Select(d =>
            {
                var bb = d.ContentHandler.CreateGlobalBuffBInternally();

                if (bb != null)
                {
                    bb.Mod = d;
                }

                return(bb);
            }).Where(bb => bb != null);

            if (!bs.IsEmpty())
            {
                if (h == null)
                {
                    h = new BuffBHandler();
                }

                h.behaviours.AddRange(bs);
            }

            if (h != null)
            {
                h.Create();
            }

            n.P_BuffBHandler[slot] = h;

            return(h);
        }
Exemple #2
0
        static BuffBHandler AttachBuffBHandler(NPC n, int slot, int type)
        {
            if (slot == -1)
                return null;

            BuffBHandler h = null;

            if (Handler.BuffDef.DefsByType.ContainsKey(type))
            {
                var d = Handler.BuffDef.DefsByType[type];

                if (d.CreateBehaviour != null)
                {
                    var b = d.CreateBehaviour();

                    if (b != null)
                    {
                        h = new BuffBHandler();

                        b.Mod = d.Mod == PrismApi.VanillaInfo ? null : ModData.mods[d.Mod];

                        h.behaviours.Add(b);
                    }
                }
            }

            var bs = ModData.mods.Values.Select(d =>
            {
                var bb = d.ContentHandler.CreateGlobalBuffBInternally();

                if (bb != null)
                    bb.Mod = d;

                return bb;
            }).Where(bb => bb != null);

            if (!bs.IsEmpty())
            {
                if (h == null)
                    h = new BuffBHandler();

                h.behaviours.AddRange(bs);
            }

            if (h != null)
                h.Create();

            n.P_BuffBHandler[slot] = h;

            return h;
        }