void Awake() { switch (shape) { case GravityShape.Flat: Field = new FlatGravityField(); break; case GravityShape.Spherical: Field = new SphericalGravityField(Vector3.zero); break; case GravityShape.InverseSpherical: Field = new InverseSphericalGravityField(Vector3.zero); break; case GravityShape.TripleSpherical: Field = new TripleSphericalGravityField(Vector3.zero); break; case GravityShape.ZXTorus: Field = new ZXTorusGravityField(Vector3.zero, 70.0f); break; default: break; } }
public NPCNest(NPCNestDNA dna, double radius, World world, Map map, KeepItems2D keepItems2D, MaterialIDs materialIDs, Viewport3D viewport, EditorOptions editorOptions, ItemOptionsArco itemOptions, IGravityField gravity, DragHitShape dragPlane) { // Store stuff _world = world; _map = map; _keepItems2D = keepItems2D; _materialIDs = materialIDs; _viewport = viewport; _editorOptions = editorOptions; _itemOptions = itemOptions; _gravity = gravity; _dragPlane = dragPlane; // DNA NPCNestDNA fixedDNA = GetFinalDNA(dna); _shellColors = fixedDNA.ShellColors; _botDNA = fixedDNA.BotDNA; _weaponDNA = fixedDNA.WeaponDNA; //TODO: Hand this a winner list, and filter criteria _dreamer = new EvolutionDreamer(_itemOptions, _shellColors, 4); //TODO: Num bots should come from item options _dreamer.WeaponDNA = EvolutionDreamer.GetRandomDNA().Item2; #region WPF Model var models = GetModel(_shellColors, radius); this.Model = models.Item1; _eggModels = models.Item2; _rotateTransform = new QuaternionRotation3D(); _translateTransform = new TranslateTransform3D(); Transform3DGroup transform = new Transform3DGroup(); transform.Children.Add(new RotateTransform3D(_rotateTransform)); transform.Children.Add(_translateTransform); ModelVisual3D visual = new ModelVisual3D(); visual.Transform = transform; visual.Content = this.Model; this.Visuals3D = new Visual3D[] { visual }; #endregion // Energy tank _energy = new Container(); _energy.QuantityMax = _itemOptions.Nest_Energy_Max * radius; _energy.QuantityCurrent = _energy.QuantityMax * .5d; // Finish this.Token = TokenGenerator.NextToken(); this.Radius = radius; this.CreationTime = DateTime.UtcNow; }
public SensorGravity(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks, IGravityField field) : base(options, dna, itemOptions.Sensor_Damage.HitpointMin, itemOptions.Sensor_Damage.HitpointSlope, itemOptions.Sensor_Damage.Damage) { _itemOptions = itemOptions; _energyTanks = energyTanks; _field = field; Design = new SensorGravityDesign(options, true); Design.SetDNA(dna); GetMass(out _mass, out _volume, out double radius, out _scaleActual, dna, itemOptions); Radius = radius; _neurons = CreateNeurons(dna, itemOptions, itemOptions.GravitySensor_NeuronDensity); _neuronMaxRadius = _neurons.Max(o => o.PositionLength); }
public Bot(BotConstruction_Result construction) { _options = construction.ArgsExtra.Options; _itemOptions = construction.ArgsExtra.ItemOptions; _radiation = construction.ArgsExtra.Radiation; _gravity = construction.ArgsExtra.Gravity; _cameraPool = construction.ArgsExtra.CameraPool; _parts = construction.PartConstruction; _thrusters = construction.PartConstruction.GetStandardParts <Thruster>(Thruster.PARTTYPE).ToArray(); _impulseEngines = construction.PartConstruction.GetStandardParts <ImpulseEngine>(ImpulseEngine.PARTTYPE).ToArray(); _projectileGuns = construction.PartConstruction.GetStandardParts <ProjectileGun>(ProjectileGun.PARTTYPE).ToArray(); _updatableParts_MainThread = construction.UpdatableParts_MainThread; _updatableParts_AnyThread = construction.UpdatableParts_AnyThread; _dna = construction.DNA; _dnaParts = construction.DNAParts; this.Model = construction.Model; _visualEffects = construction.VisualEffects; _isPhysicsStatic = construction.ArgsExtra.IsPhysicsStatic; this.PhysicsBody = construction.PhysicsBody; this.Radius = construction.Radius; _partTransformToModel = _parts.AllPartsArray. Select(o => { Transform3DGroup transform = new Transform3DGroup(); transform.Children.Add(new TranslateTransform3D(-o.Position.ToVector())); transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(o.Orientation.ToReverse()))); return(transform); }). ToArray(); // Hook up events if (!_isPhysicsStatic) { this.PhysicsBody.ApplyForceAndTorque += new EventHandler <BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque); } foreach (var part in _parts.AllPartsArray) { part.RequestWorldLocation += new EventHandler <PartRequestWorldLocationArgs>(Part_RequestWorldLocation); part.RequestWorldSpeed += new EventHandler <PartRequestWorldSpeedArgs>(Part_RequestWorldSpeed); part.RequestParent += new EventHandler <PartRequestParentArgs>(Part_RequestParent); part.Resurrected += Part_Resurrected; part.Destroyed += Part_Destroyed; } // See if there are parts that can gradually change the ship's mass if ((_parts.Containers.Fuels.Count > 0 && _parts.StandardParts.ContainsKey(Thruster.PARTTYPE)) || (_parts.Containers.CargoBays.Count > 0 && (_parts.StandardParts.ContainsKey(ConverterMatterToEnergy.PARTTYPE) || _parts.StandardParts.ContainsKey(ConverterMatterToFuel.PARTTYPE))) || (_parts.Containers.Energies.Count > 0 && _parts.Containers.Fuels.Count > 0 && (_parts.StandardParts.ContainsKey(ConverterEnergyToFuel.PARTTYPE) || _parts.StandardParts.ContainsKey(ConverterFuelToEnergy.PARTTYPE))) ) { _hasMassChangingUpdatables_Small = true; } else { _hasMassChangingUpdatables_Small = false; } if (_parts.Containers.Ammos.Count > 0 && _parts.StandardParts.ContainsKey(ProjectileGun.PARTTYPE)) { _hasMassChangingUpdatables_Medium = true; } else { _hasMassChangingUpdatables_Medium = false; } // Set up a neural processor on its own thread/task _neuronLinks = construction.Links; if (_neuronLinks != null) { var result = AddToNeuralPool(_neuronLinks, construction.ArgsExtra.NeuralPoolManual); _linkBucket = result.bucket; _neuralPoolAddTask = result.addTask; _neuralPoolManualTick = result.manualPool; } _lifeEvents = construction.PartConstruction.LifeEventWatcher; this.ShouldRecalcMass_Large = false; this.ShouldRecalcMass_Small = false; this.CreationTime = DateTime.UtcNow; }
public ArcBotNPC(BotDNA dna, int level, Point3D position, World world, Map map, KeepItems2D keepItems2D, MaterialIDs materialIDs, Viewport3D viewport, EditorOptions editorOptions, ItemOptionsArco itemOptions, IGravityField gravity, DragHitShape dragPlane, Point3D homingPoint, double homingRadius, bool runNeural, bool repairPartPositions) : base(dna, level, position, world, map, keepItems2D, materialIDs, viewport, editorOptions, itemOptions, gravity, dragPlane, homingPoint, homingRadius, runNeural, repairPartPositions) { }
public Bot(BotConstruction_Result construction) { _options = construction.ArgsExtra.Options; _itemOptions = construction.ArgsExtra.ItemOptions; _radiation = construction.ArgsExtra.Radiation; _gravity = construction.ArgsExtra.Gravity; _cameraPool = construction.ArgsExtra.CameraPool; _parts = construction.PartConstruction; _thrusters = construction.PartConstruction.GetStandardParts<Thruster>(Thruster.PARTTYPE).ToArray(); _projectileGuns = construction.PartConstruction.GetStandardParts<ProjectileGun>(ProjectileGun.PARTTYPE).ToArray(); _updatableParts_MainThread = construction.UpdatableParts_MainThread; _updatableParts_AnyThread = construction.UpdatableParts_AnyThread; _dna = construction.DNA; _dnaParts = construction.DNAParts; this.Model = construction.Model; _visualEffects = construction.VisualEffects; _isPhysicsStatic = construction.ArgsExtra.IsPhysicsStatic; this.PhysicsBody = construction.PhysicsBody; this.Radius = construction.Radius; _partTransformToModel = _parts.AllPartsArray. Select(o => { Transform3DGroup transform = new Transform3DGroup(); transform.Children.Add(new TranslateTransform3D(-o.Position.ToVector())); transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(o.Orientation.ToReverse()))); return transform; }). ToArray(); // Hook up events if (!_isPhysicsStatic) { this.PhysicsBody.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque); } foreach (var part in _parts.AllPartsArray) { part.RequestWorldLocation += new EventHandler<PartRequestWorldLocationArgs>(Part_RequestWorldLocation); part.RequestWorldSpeed += new EventHandler<PartRequestWorldSpeedArgs>(Part_RequestWorldSpeed); part.RequestParent += new EventHandler<PartRequestParentArgs>(Part_RequestParent); part.Resurrected += Part_Resurrected; part.Destroyed += Part_Destroyed; } // See if there are parts that can gradually change the ship's mass if ((_parts.Containers.Fuels.Count > 0 && _parts.StandardParts.ContainsKey(Thruster.PARTTYPE)) || (_parts.Containers.CargoBays.Count > 0 && (_parts.StandardParts.ContainsKey(ConverterMatterToEnergy.PARTTYPE) || _parts.StandardParts.ContainsKey(ConverterMatterToFuel.PARTTYPE))) || (_parts.Containers.Energies.Count > 0 && _parts.Containers.Fuels.Count > 0 && (_parts.StandardParts.ContainsKey(ConverterEnergyToFuel.PARTTYPE) || _parts.StandardParts.ContainsKey(ConverterFuelToEnergy.PARTTYPE))) ) { _hasMassChangingUpdatables_Small = true; } else { _hasMassChangingUpdatables_Small = false; } if (_parts.Containers.Ammos.Count > 0 && _parts.StandardParts.ContainsKey(ProjectileGun.PARTTYPE)) { _hasMassChangingUpdatables_Medium = true; } else { _hasMassChangingUpdatables_Medium = false; } // Set up a neural processor on its own thread/task _neuronLinks = construction.Links; if (_neuronLinks != null) { var bucketTask = AddToNeuralPool(_neuronLinks); _neuralPoolAddTask = bucketTask.Item1; _linkBucket = bucketTask.Item2; } _lifeEvents = construction.PartConstruction.LifeEventWatcher; this.ShouldRecalcMass_Large = false; this.ShouldRecalcMass_Small = false; this.CreationTime = DateTime.UtcNow; }
public SensorGravity(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks, IGravityField field) : base(options, dna, itemOptions.Sensor_Damage.HitpointMin, itemOptions.Sensor_Damage.HitpointSlope, itemOptions.Sensor_Damage.Damage) { _itemOptions = itemOptions; _energyTanks = energyTanks; _field = field; this.Design = new SensorGravityDesign(options, true); this.Design.SetDNA(dna); double radius; GetMass(out _mass, out _volume, out radius, out _scaleActual, dna, itemOptions); this.Radius = radius; _neurons = CreateNeurons(dna, itemOptions, itemOptions.GravitySensor_NeuronDensity); _neuronMaxRadius = _neurons.Max(o => o.PositionLength); }