Beispiel #1
0
        public override void Load(TagCompound tag)
        {
            try
            {
                Tier = (DuctTier)tag.GetInt("Tier");
                switch (Tier)
                {
                case DuctTier.Basic:
                    Speed = 20;
                    break;

                case DuctTier.Advanced:
                    Speed = 12;
                    break;

                case DuctTier.Elite:
                    Speed = 5;
                    break;
                }

                if (tag.ContainsKey("Module"))
                {
                    TagCompound module = tag.GetCompound("Module");
                    Module        = (BaseModule)Activator.CreateInstance(Type.GetType(module.GetString("Type")));
                    Module.Parent = this;
                    Module.Load(module.GetCompound("Data"));
                }
            }
            catch
            {
            }
        }
Beispiel #2
0
        public override void OnPlace(BaseLayerItem item)
        {
            if (item is BaseDuct d)
            {
                Tier = d.Tier;
                switch (Tier)
                {
                case DuctTier.Basic:
                    Speed = 20;
                    break;

                case DuctTier.Advanced:
                    Speed = 12;
                    break;

                case DuctTier.Elite:
                    Speed = 5;
                    break;
                }
            }

            List <RoutedNetwork> networks = GetNeighbors().Select(duct => duct.Network).Distinct().ToList();
            RoutedNetwork        network  = new RoutedNetwork
            {
                Tiles        = networks.SelectMany(routedNetwork => routedNetwork.Tiles).Concat(this).ToList(),
                NetworkItems = networks.SelectMany(routedNetwork => routedNetwork.NetworkItems).ToList()
            };

            foreach (Duct duct in network.Tiles)
            {
                RoutedNetwork.Networks.Remove(duct.Network);
                duct.Network = network;
            }

            foreach (Duct duct in network.Tiles)
            {
                if ((duct.frame & 1) != 0 && (duct.frame & 16) != 0 && (duct.frame & 4) == 0 && (duct.frame & 64) == 0)
                {
                    duct.isNode = false;
                }
                else if ((duct.frame & 1) == 0 && (duct.frame & 16) == 0 && (duct.frame & 4) != 0 && (duct.frame & 64) != 0)
                {
                    duct.isNode = false;
                }
                else
                {
                    duct.isNode = true;
                }
            }
        }