public ShipPart Clone() { ShipPart result; if (this is WeaponPart) { WeaponPart source = (WeaponPart)this; List<EidosAction> newActions = new List<EidosAction>(); foreach (EidosAction oldAct in this.Actions) { object[] oldValues = new object[oldAct.ActionValues.Length]; for (int i = 0; i < oldValues.Length; i++) { oldValues[i] = oldAct.ActionValues[i]; } Type t = oldAct.GetType(); EidosAction newAct = (EidosAction)Activator.CreateInstance(t,oldValues); newActions.Add(newAct); } result = new WeaponPart(source.Parent, source.Name, source.HP.Max, source.Mass, source.WeaponDamage,source.Range,source.DamageType,source.FiringType, source.CritMultiplier, source.ReloadTime, newActions); } else if (this is DefensePart) { DefensePart source = (DefensePart)this; List<EidosAction> newActions = new List<EidosAction>(); foreach (EidosAction oldAct in this.Actions) { object[] oldValues = new object[oldAct.ActionValues.Length]; for (int i = 0; i < oldValues.Length; i++) { oldValues[i] = oldAct.ActionValues[i]; } Type t = oldAct.GetType(); EidosAction newAct = (EidosAction)Activator.CreateInstance(t,oldValues); newActions.Add(newAct); } result = new DefensePart(source.Parent, source.Name, source.HP.Max, source.Mass, source.DR, source.DownAdjective, source.PenetrateVerb, newActions); } else if (this is EnginePart) { EnginePart source = (EnginePart)this; List<EidosAction> newActions = new List<EidosAction>(); foreach (EidosAction oldAct in this.Actions) { object[] oldValues = new object[oldAct.ActionValues.Length]; for (int i = 0; i < oldValues.Length; i++) { oldValues[i] = oldAct.ActionValues[i]; } Type t = oldAct.GetType(); EidosAction newAct = (EidosAction)Activator.CreateInstance(t, oldValues); newActions.Add(newAct); } result = new EnginePart(source.Parent, source.Name, source.HP.Max, source.Mass, source.Thrust, newActions); } else { ActionPart source = (ActionPart)this; List<EidosAction> newActions = new List<EidosAction>(); foreach (EidosAction oldAct in this.Actions) { object[] oldValues = new object[oldAct.ActionValues.Length]; for (int i = 0; i < oldValues.Length; i++) { oldValues[i] = oldAct.ActionValues[i]; } Type t = oldAct.GetType(); EidosAction newAct = (EidosAction)Activator.CreateInstance(t, oldValues); newActions.Add(newAct); } result = new ActionPart(source.Parent, source.Name, source.HP.Max, source.Mass, source.Description, newActions); } return result; }
public FireWeaponAtTarget(WeaponPart weapon, Ship targetShip) { this.OrderValues = new object[2]; this.OrderValues[0] = weapon; this.OrderValues[1] = targetShip; }