Ejemplo n.º 1
0
        public MotionController2(EditorOptions options, ItemOptionsArco itemOptions, ShipPartDNA dna, AIMousePlate mousePlate)
            : base(options, dna, itemOptions.MotionController_Damage.HitpointMin, itemOptions.MotionController_Damage.HitpointSlope, itemOptions.MotionController_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _mousePlate  = mousePlate;

            this.Design = new MotionController2Design(options, true);
            this.Design.SetDNA(dna);

            GetMass(out _mass, out double volume, out double radius, out _scaleActual, dna, itemOptions);

            this.Radius = radius;

            var neurons = CreateNeurons(dna, itemOptions);

            _neuron_rotate_direction_speed = neurons.rot_dirspeed;
            _neuron_rotate_radius          = neurons.rot_radius;
            _neurons_linear = neurons.linear;
            _neurons_all    = UtilityCore.Iterate <Neuron_SensorPosition>(_neuron_rotate_direction_speed, _neuron_rotate_radius, _neurons_linear).ToArray();
        }
Ejemplo n.º 2
0
        public static PartBase InstantiateUnknownPart_Standard(ShipPartDNA dna, ShipCoreArgs core, ShipExtraArgs extra, BotConstruction_Containers containers, object[] botObjects)
        {
            ItemOptionsArco itemOptions = (ItemOptionsArco)extra.ItemOptions;

            var constructProps = botObjects?.FirstOrDefault(o => o is ArcBot2_ConstructionProps) as ArcBot2_ConstructionProps;

            if (constructProps == null)
            {
                throw new ApplicationException("ArcBot2_ConstructionProps needs to be given to the bot constructor in the botObjects param");
            }

            double botRadius = itemOptions.RadiusAtLevel[constructProps.Level];

            switch (dna.PartType)
            {
            case MotionController2.PARTTYPE:
                //if (MotionController.Count > 0)
                //{
                //    throw new ApplicationException("There can be only one plate writer in a bot");
                //}

                AIMousePlate mousePlate = new AIMousePlate(constructProps.DragPlane);
                mousePlate.MaxXY = botRadius * 20;
                mousePlate.Scale = 1;

                return(new MotionController2(extra.Options, itemOptions, dna, mousePlate));

            case SensorVision.PARTTYPE:
                if (dna is SensorVisionDNA sensorVisionDNA)
                {
                    return(new SensorVision(extra.Options, itemOptions, (SensorVisionDNA)dna, core.Map));
                }
                else
                {
                    throw new ApplicationException($"SensorVision requires SensorVisionDNA: {dna.GetType()}");
                }

            default:
                throw new ApplicationException($"Unknown PartType: {dna.PartType}");
            }
        }
Ejemplo n.º 3
0
        public MotionController_Linear_obsolete(EditorOptions options, ItemOptionsArco itemOptions, ShipPartDNA dna, AIMousePlate mousePlate)
            : base(options, dna, itemOptions.MotionController_Damage.HitpointMin, itemOptions.MotionController_Damage.HitpointSlope, itemOptions.MotionController_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _mousePlate  = mousePlate;

            this.Design = new MotionController_LinearDesign_obsolete(options, true);
            this.Design.SetDNA(dna);

            double radius, volume;

            MotionController2.GetMass(out _mass, out volume, out radius, out _scaleActual, dna, itemOptions);

            this.Radius = radius;

            _neurons = SensorVision.CreateNeurons(dna, itemOptions, itemOptions.MotionController_Linear_NeuronDensity, false, false);

            BuildTerrain();

            _distanceMult = _mousePlate.MaxXY / _neurons.Max(o => o.PositionLength);
        }