Example #1
0
        public static IList<IComponent> BuildComponentsFromRNA(Reactor reactor, string rna )
        {
            if (rna.Length - reactor.GetWidth() != reactor.GetWidth()*reactor.GetHeight()) throw new ArgumentOutOfRangeException("rna", @"rna didnt match reactor parameters");

            var gridRNA = rna.Split(':');

            var toReturn = new List<IComponent>();

            for (uint x = 0; x < gridRNA.Length; x++)
            {
                string column = gridRNA[x];

                for (uint y = 0; y < column.Length; y++)
                {
                    Component.Component toBuild;

                    switch (column[(int)y])
                    {
                        case 'U':
                            toBuild = Component.Component.UranCell;
                            break;
                        case 'C':
                            toBuild = Component.Component.CoolCell;
                            break;
                        case 'E':
                            toBuild = Component.Component.Empty;
                            break;
                        case 'R':
                            toBuild = Component.Component.ReactorPlating;
                            break;
                        case 'H':
                            toBuild = Component.Component.HeatDispenser;
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                    var newComponent = BuildComponent(x, y, toBuild);
                    reactor.Pulse += newComponent.PulseHandler;
                    toReturn.Add(newComponent);
                }
            }

            return toReturn;
        }
Example #2
0
        public static void RandomReactor(Reactor reactor)
        {
            for (uint x = 0; x < reactor.GetWidth(); x++)
            {
                for (uint y = 0; y < reactor.GetHeight(); y++)
                {
                    Component.Component component = GetNextComponent();

                    var newComponent = BuildComponent(x, y, component);

                    reactor.Pulse += newComponent.PulseHandler;

                    reactor.ItsComponents.Add(newComponent);
                }
            }
        }