/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Bomb temp = this + (Bomb)op2; Installations = temp.Installations; MinimumKill = temp.MinimumKill; PopKill = temp.PopKill; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { if (!IsSameWeaponType((Weapon)op2)) { Report.Error("Attempted to add different weapon types."); return; } Power += ((Weapon)op2).Power; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { if (HitChance != ((MineLayer)op2).HitChance) { Report.Error("MineLayer.operator+ Attempted to add together different types of mine layers."); return; } LayerRate += ((MineLayer)op2).LayerRate; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value = Math.Max(Value, ((Radiation)op2).Value); }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value = (this + (MassDriver)op2).Value; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value += ((IntegerProperty)op2).Value; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { MaxModifiedGravity = Math.Max(MaxModifiedGravity, ((Terraform)op2).MaxModifiedGravity); MaxModifiedRadiation = Math.Max(MaxModifiedRadiation, ((Terraform)op2).MaxModifiedRadiation); MaxModifiedTemperature = Math.Max(MaxModifiedTemperature, ((Terraform)op2).MaxModifiedTemperature); }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { return; }
/// <summary> /// Add a property to the ShipDesign.Summary. /// </summary> /// <param name="property"> /// The property to be added to the ShipDesign.Summary. /// </param><param name="type"> /// The type of the property: one of Component.propertyKeys, normally /// the key used to obtain it from a Properties dictionary. /// </param> private void SumProperty(ComponentProperty property, string type, int componentCount) { switch (type) { // properties that can be summed up to a single property case "Armor": case "Capacitor": case "Cargo": case "Cloak": case "Computer": case "Defense": case "Driver": case "Fuel": case "Jammer": case "Movement": case "Orbital Adjuster": case "Radiation": case "Robot": case "Scanner": case "Shield": case "Terraforming": if (Summary.Properties.ContainsKey(type)) { ComponentProperty toAdd = property.Clone() as ComponentProperty; // create a copy so scaling doesn't mess it up. toAdd.Scale(componentCount); Summary.Properties[type].Add(toAdd); } else { ComponentProperty toAdd = property.Clone() as ComponentProperty; // create a copy so scaling doesn't mess it up. toAdd.Scale(componentCount); Summary.Properties.Add(type, toAdd); } break; // sum up the components in the slot, but keep a separate entry for 'different components'<-- has different meaning for each of these case "Bomb": Bomb bomb = property as Bomb; if (bomb.IsSmart) { SmartBombs += bomb * componentCount; } else { ConventionalBombs += bomb * componentCount; } break; case "Mine Layer": MineLayer layer = property as MineLayer; if (layer.HitChance == MineLayer.HeavyHitChance) { HeavyMines += layer * componentCount; } else if (layer.HitChance == MineLayer.SpeedTrapHitChance) { SpeedBumbMines += layer * componentCount; } else { StandardMines += layer * componentCount; } break; case "Weapon": Weapon weapon = property as Weapon; Weapons.Add(weapon * componentCount); break; // keep one of each type only - TODO (priority 2) keep the right one case "Colonizer": case "Engine": case "Gate": case "Hull": case "Mine Layer Efficiency": if (Summary.Properties.ContainsKey(type)) { break; } else { Summary.Properties.Add(type, property); } break; // Ignore in this context case "Hull Affinity": case "Transport Ships Only": break; } }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value += ((DoubleProperty)op2).Value; }
// Note: this used to contain operators + and * which were then overriden in the daughter classes. // This turned out to be a very bad idea as operator overloading and polymorphism don't mix well: // The base class operators were always called which didn't do what we want. To get the desired // result I have implemented these as abstract methods. /// <summary> /// Add the <see cref="ComponentProperty"/> op2 to the current property. /// </summary> /// <param name="op2">A <see cref="ComponentProperty"/> of the same daughter type as the calling object.</param> public abstract void Add(ComponentProperty op2);
/// <summary> /// Initializes a new instance of the ComponentProperty class. /// Copy constructor. /// </summary> /// <param name="existing">An existing <see cref="ComponentProperty"/> to copy.</param> public ComponentProperty(ComponentProperty existing) { }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value = (this + (ProbabilityProperty)op2).Value; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value = (this + (CapacitorProperty)op2).Value; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Value = (this + (Defense)op2).Value; }
/// <summary> /// Polymorphic addition of properties. /// </summary> /// <param name="op2"></param> public override void Add(ComponentProperty op2) { Capacity += ((Fuel)op2).Capacity; Generation += ((Fuel)op2).Generation; }