public void RemoveBuff(ModuleBuffMk2 buff)
        {
            List <string> affectedModules = new List <string>();

            for (int i = 0; i < buff.m_BuffPath.Length; i++)
            {
                string        path      = buff.m_BuffPath[i];
                List <string> splitPath = path.Split('.').ToList();
                Type          component = typeof(TankBlock).Assembly.GetType(splitPath[0]);
                if (component != null)
                {
                    affectedModules.Add(splitPath[0]);
                    pathToSegment[path].RemoveBuff(buff);
                    Console.WriteLine("FFW! Removed buff from Segment => " + path);
                    pathToSegment[path].ManipulateObj(this.typeToBlock[component], "UPDATE");
                }
                else
                {
                    Console.WriteLine("FFW! RemoveBuff! Type " + splitPath[0] + " doesn't exist.");
                }
            }
            if (affectedModules.Contains("ModuleWeaponGun") && pathToSegment.ContainsKey("ModuleWeaponGun.m_ShotCooldown"))
            {
                float avg = pathToSegment["ModuleWeaponGun.m_ShotCooldown"].GetAverages("~");
                BuffSpecificFix.ManipulateBarrels(this.typeToBlock[typeof(ModuleWeaponGun)], "UPDATE", this.weaponSpeedMemory, avg);
            }
            if (affectedModules.Contains("ModuleWheels"))
            {
                BuffSpecificFix.RefreshWheels(this.typeToBlock[typeof(ModuleWheels)]);
            }
        }
Exemplo n.º 2
0
 public void RemoveBuff(ModuleBuffMk2 buff)
 {
     this.effectBuffBlocks.Remove(buff);
 }
Exemplo n.º 3
0
 public void AddBuff(ModuleBuffMk2 buff, int i)
 {
     this.effectBuffBlocks.Add(buff, i);
 }
        public void AddBuff(ModuleBuffMk2 buff)
        {
            List <string> affectedModules = new List <string>();

            for (int i = 0; i < buff.m_BuffPath.Length; i++)
            {
                string        path       = buff.m_BuffPath[i];
                List <string> splitPath  = path.Split('.').ToList();
                List <string> restOfPath = splitPath.Skip(1).ToList();
                Type          component  = typeof(TankBlock).Assembly.GetType(splitPath[0]);
                if (component != null)
                {
                    affectedModules.Add(splitPath[0]);
                    if (!typeToBlock.ContainsKey(component))
                    {
                        typeToBlock.Add(component, new List <TankBlock>());
                        Console.WriteLine("FFW! Added typeToBlock => " + component.Name);
                        foreach (TankBlock block in this.allBlocks)
                        {
                            object blockComponent = block.GetComponent(component);
                            if (blockComponent != null)
                            {
                                if (!this.typeToBlock[component].Contains(block))
                                {
                                    this.typeToBlock[component].Add(block);
                                    Console.WriteLine("FFW! +Reg => " + block.name + " => " + component.Name);
                                }
                            }
                        }
                    }
                    if (!pathToSegment.ContainsKey(path))
                    {
                        BuffSegmentMk2 segment = new BuffSegmentMk2()
                        {
                            tank            = this.tank,
                            controller      = this,
                            effectComponent = component,
                            effectPath      = restOfPath
                        };
                        this.pathToSegment.Add(path, segment);
                        Console.WriteLine("FFW! Added pathToSegment => " + path);
                        pathToSegment[path].ManipulateObj(this.typeToBlock[component], "SAVE");
                        if (path == "ModuleWeaponGun.m_ShotCooldown")
                        {
                            BuffSpecificFix.ManipulateBarrels(this.typeToBlock[component], "SAVE", this.weaponSpeedMemory, 1.0f);
                        }
                    }
                    pathToSegment[path].AddBuff(buff, i);
                    Console.WriteLine("FFW! Added buff to Segment => " + path);
                    pathToSegment[path].ManipulateObj(this.typeToBlock[component], "UPDATE");
                }
                else
                {
                    Console.WriteLine("FFW! AddBuff! Type " + splitPath[0] + " doesn't exist.");
                }
            }
            if (affectedModules.Contains("ModuleWeaponGun") && pathToSegment.ContainsKey("ModuleWeaponGun.m_ShotCooldown"))
            {
                float avg = pathToSegment["ModuleWeaponGun.m_ShotCooldown"].GetAverages("~");
                BuffSpecificFix.ManipulateBarrels(this.typeToBlock[typeof(ModuleWeaponGun)], "UPDATE", this.weaponSpeedMemory, avg);
            }
            if (affectedModules.Contains("ModuleWheels"))
            {
                BuffSpecificFix.RefreshWheels(this.typeToBlock[typeof(ModuleWheels)]);
            }
        }