/// <summary> /// Constructs a Missile instance of the given missile type. /// </summary> /// <param name="missileData">Reference to the missile data.</param> /// <param name="sourceEntity">Reference to the entity that is the source of this missile.</param> /// <param name="targetEntity">Reference to the entity that is the target of this missile.</param> public Missile(IMissileData missileData, Entity sourceEntity, Entity targetEntity) : base(missileData.MissileType.Name) { if (missileData == null) { throw new ArgumentNullException("missileData"); } this.missileData = missileData; if (sourceEntity == null) { throw new ArgumentNullException("sourceEntity"); } if (!sourceEntity.HasMapObject(MapObjectLayerEnum.GroundObjects, MapObjectLayerEnum.AirObjects)) { throw new ArgumentException("Source entity is not attached to the map!", "sourceEntity"); } if (targetEntity == null) { throw new ArgumentNullException("sourceEntity"); } if (!targetEntity.HasMapObject(MapObjectLayerEnum.GroundObjects, MapObjectLayerEnum.AirObjects)) { throw new ArgumentException("Target entity is not attached to the map!", "targetEntity"); } this.sourceEntity = this.ConstructField <Entity>("sourceEntity"); this.targetEntity = this.ConstructField <Entity>("targetEntity"); this.lastKnownTargetEntityPos = this.ConstructField <RCNumVector>("lastKnownTargetEntityPos"); this.lastKnownTargetEntityIsFlying = this.ConstructField <byte>("lastKnownTargetEntityIsFlying"); this.missilePosition = this.ConstructField <RCNumVector>("missilePosition"); this.launchPosition = this.ConstructField <RCNumVector>("launchPosition"); this.launchedFromAir = this.ConstructField <byte>("launchedFromAir"); this.missileVelocity = this.ConstructField <RCNumVector>("missileVelocity"); this.timer = this.ConstructField <int>("timer"); this.currentStatus = this.ConstructField <byte>("currentStatus"); this.sourceEntity.Write(sourceEntity); this.targetEntity.Write(targetEntity); this.lastKnownTargetEntityPos.Write(RCNumVector.Undefined); this.lastKnownTargetEntityIsFlying.Write(0x00); this.missilePosition.Write(RCNumVector.Undefined); this.launchPosition.Write(RCNumVector.Undefined); this.launchedFromAir.Write(0x00); this.missileVelocity.Write(RCNumVector.Undefined); this.timer.Write(0); this.currentStatus.Write((byte)Status.Launching); this.launchIndicator = null; this.missileIndicator = null; //this.trailIndicators = new List<MapObject>(); this.impactIndicator = null; this.sourceEntityHeading = new MapDirValueSrcWrapper(new HeadingToMapDirConverter(sourceEntity.Armour.TargetVector)); this.velocityGraph = this.missileData.MissileType.Speed != null ? new HexadecagonalVelocityGraph(this.missileData.MissileType.Speed.Read()) : null; }
/// <summary> /// Constructs a MissileDataWrapper instance for the given missile data. /// </summary> /// <param name="weaponDataUpgrade">The weapon data upgrade instance that this missile data wrapper belongs to.</param> /// <param name="originalMissileData">The wrapped missile data.</param> public MissileDataWrapper(WeaponDataUpgrade weaponDataUpgrade, IMissileData originalMissileData) { if (weaponDataUpgrade == null) { throw new ArgumentNullException("weaponDataUpgrade"); } if (originalMissileData == null) { throw new ArgumentNullException("originalMissileData"); } this.missileType = new IMissileType(weaponDataUpgrade.metadataUpgrade.GetElementTypeUpgradeImpl(originalMissileData.MissileType.Name)); this.originalMissileData = originalMissileData; }