private void OnDataChange(Data key, string value)
    {
        DataMap[key] = value;
        RpcOnDataChange(key, value);

        var strKey = key.FastToString();

        if (strKey.StartsWith("Eco", true, CultureInfo.InvariantCulture))
        {
            OnEcoDataChanged(key, value);
        }
        else if (strKey.StartsWith("BrushHead", true, CultureInfo.InvariantCulture))
        {
            BrushHead.ChangeBrushHeadData(key, value, GetHerbivores <BrushHead>(HerbivoreType.BrushHead));
        }
        else if (strKey.StartsWith("TriHorse", true, CultureInfo.InvariantCulture))
        {
            TriHorse.ChangeTriHorseData(key, value, GetHerbivores <TriHorse>(HerbivoreType.TriHorse));
        }
        else if (strKey.StartsWith("Jabarkie", true, CultureInfo.InvariantCulture))
        {
            Jabarkie.ChangeJabarkieData(key, value, GetCarnivores <Jabarkie>(CarnivoreType.Jabarkie));
        }
        else if (strKey.StartsWith("Gnomehatz", true, CultureInfo.InvariantCulture))
        {
            Gnomehatz.ChangeGnomehatzData(key, value, GetCarnivores <Gnomehatz>(CarnivoreType.Gnomehatz));
        }
        else if (strKey.StartsWith("Plant", true, CultureInfo.InvariantCulture))
        {
            PlantAI.ChangePlantData(key, value, GetPlants <PlantAI>(PlantType.Generic));
        }
        else if (strKey.StartsWith("Snatcher", true, CultureInfo.InvariantCulture))
        {
            IEnumerable <SnatcherPlant> snatchers;

            if (m_PlantMap.ContainsKey(PlantType.EmbeddedSnatcher))
            {
                snatchers = GetPlants <SnatcherPlant>(PlantType.EmbeddedSnatcher);
                if (m_PlantMap.ContainsKey(PlantType.FloatingSnatcher))
                {
                    snatchers = snatchers.Concat(GetPlants <SnatcherPlant>(PlantType.FloatingSnatcher));
                }
            }
            else if (m_PlantMap.ContainsKey(PlantType.FloatingSnatcher))
            {
                snatchers = GetPlants <SnatcherPlant>(PlantType.FloatingSnatcher);
            }
            else
            {
                return;
            }

            SnatcherPlant.ChangeSnatcherData(key, value, snatchers);
        }
        else if (strKey.StartsWith("NoduleFloating", true, CultureInfo.InvariantCulture))
        {
            FloatingNodule.ChangeNoduleData(key, value, m_Nodules.Where(n => n.Type == NoduleType.Floating).Select(n => n.gameObject));
        }
        else if (strKey.StartsWith("FloatGLColony", true, CultureInfo.InvariantCulture))
        {
            FloatGrassLargeColony.ChangeFloatGrassLargeColonyData(key, value, GetPlants <FloatGrassLargeColony>(PlantType.FloatGrassLargeColony));
        }
        else if (strKey.StartsWith("FloatGLCluster", true, CultureInfo.InvariantCulture))
        {
            FloatGrassLargeCluster.ChangeFloatGrassClusterData(key, value, GetPlants <FloatGrassLargeCluster>(PlantType.FloatGrassLargeCluster));
        }
        else if (strKey.StartsWith("FloatGLBlade", true, CultureInfo.InvariantCulture))
        {
            FloatGrassLargeBlade.ChangeFloatGrassLargeBladeData(key, value, GetPlants <FloatGrassLargeBlade>(PlantType.FloatGrassLargeBlade));
        }
        else if (strKey.StartsWith("FloatGSColony", true, CultureInfo.InvariantCulture))
        {
            FloatGrassSmallColony.ChangeFloatGrassSmallColonyData(key, value, GetPlants <FloatGrassSmallColony>(PlantType.FloatGrassSmallColony));
        }
        else if (strKey.StartsWith("FloatGSCluster", true, CultureInfo.InvariantCulture))
        {
            FloatGrassSmallCluster.ChangeFloatGrassClusterData(key, value, GetPlants <FloatGrassSmallCluster>(PlantType.FloatGrassSmallCluster));
        }
        else if (strKey.StartsWith("FloatGSBlade", true, CultureInfo.InvariantCulture))
        {
            FloatGrassSmallBlade.ChangeFloatGrassSmallBladeData(key, value, GetPlants <FloatGrassSmallBlade>(PlantType.FloatGrassSmallBlade));
        }
        else if (strKey.StartsWith("SporeGun", true, CultureInfo.InvariantCulture))
        {
            SporeGun.ChangeSporeGunData(key, value, GetPlants <SporeGun>(PlantType.SporeGun));
        }
        else if (strKey.StartsWith("FungiB", true, CultureInfo.InvariantCulture))
        {
            FungiB.ChangeFungiBData(key, value, GetPlants <FungiB>(PlantType.FungiB));
        }
        else if (strKey.StartsWith("Herbistar", true, CultureInfo.InvariantCulture))
        {
            Herbistar.ChangeHerbistarData(key, value, GetHerbivores <Herbistar>(HerbivoreType.Herbistar));
        }
        else if (strKey.StartsWith("DownDown", true, CultureInfo.InvariantCulture))
        {
            DownDown.ChangeDownDownData(key, value, GetHerbivores <DownDown>(HerbivoreType.DownDown));
        }
    }
Exemple #2
0
 void Awake()
 {
     _ai = GetComponent <PlantAI>();
     _ai.Init(this);
 }