public void RegisterWeapon(Weapon weapon) { if (weapon != null && !Weapons.Contains(weapon)) { Weapons.Add(weapon); } }
private void AddWeapon(string weapon) { if (!Weapons.Contains(weapon)) { Weapons.Add(weapon); } }
/// <summary> /// Checks if the given spaceship is partial match to this one. /// Any differences (other than properties not defined) will be considered mismatch. /// </summary> /// <param name="other">The spaceship to compare to this one.</param> /// <returns>True, if the spaceships are a partial match. False otherwise.</returns> public bool IsPartialMatch(Spaceship other) { if (other == null) { return(false); } if (other.Size != Sizes.NotDefined && other.Size != Size) { return(false); } foreach (EngineTypes engineType in other.Engines) { if (!Engines.Contains(engineType)) { return(false); } } foreach (WeaponTypes weaponType in other.Weapons) { if (!Weapons.Contains(weaponType)) { return(false); } } if (other.Crew != CrewTypes.NotDefined && other.Crew != Crew) { return(false); } return(true); }
public void AddWeapon(WeaponTypes weaponType) { if (!Weapons.Contains(weaponType)) { Weapons.Add(weaponType); } }
private static bool GetIsWeapon(int itemType) { if (Weapons.Contains(itemType)) { return(true); } return(false); }
public Inventory Remove(Weapon w) { if (Weapons.Contains(w)) { Weapons.Remove(w); } return(this); }
public void ChangeWeapon(Weapon newWeapon) { if (Weapons.Contains(newWeapon)) { ActiveWeapon = newWeapon; if (PlayerChangedWeaponEvent != null) { PlayerChangedWeaponEvent(); } } }
public bool ObtainWeapon(Weapon weapon) { if (Full()) { return(false); } weapon.transform.parent = m_weapons.transform; if (!Weapons.Contains(weapon)) { Weapons.Add(weapon); } return(true); }
/// <summary> /// Equips a new weapon. /// </summary> public void EquipWeapon(Weapon newWeapon) { //Already have a weapon of this type so replace the old one. if (Weapons.Contains(newWeapon.WeaponData.WeaponType)) { ReplaceWeapon(Weapons[newWeapon.WeaponData.WeaponType], newWeapon); } //Full of weapons, so drop your currently equipped one. else if (Weapons.Count() >= Capacity) { ReplaceWeapon(Weapons[CurrentWeapon.WeaponData.WeaponType], newWeapon); } //Regular, just add it. else { Weapons.Add(newWeapon); } _CurrentWeaponIndex = Weapons.Count() - 1; }
internal void CompChange(bool add, WeaponComponent comp) { if (add) { if (WeaponsIdx.ContainsKey(comp)) { Log.Line($"CompAddFailed:<{comp.MyCube.EntityId}> - comp({comp.MyCube.DebugName}[{comp.MyCube.BlockDefinition.Id.SubtypeName}]) already existed in {MyGrid.DebugName}"); return; } if (comp.HasArmor) { for (int i = 0; i < comp.Platform.Weapons.Length; i++) { var w = comp.Platform.Weapons[i]; if (w.System.Armor != WeaponDefinition.HardPointDef.HardwareDef.ArmorState.IsWeapon) { Armor.Add(w.Comp.MyCube, w); } } Session.ArmorCubes.Add(comp.MyCube, comp); } WeaponsIdx.Add(comp, Weapons.Count); Weapons.Add(comp); } else { int idx; if (!WeaponsIdx.TryGetValue(comp, out idx)) { Log.Line($"CompRemoveFailed: <{comp.MyCube.EntityId}> - {Weapons.Count}[{WeaponsIdx.Count}]({WeaponBase.Count}) - {Weapons.Contains(comp)}[{Weapons.Count}] - {Session.GridTargetingAIs[comp.MyCube.CubeGrid].WeaponBase.ContainsKey(comp.MyCube)} - {Session.GridTargetingAIs[comp.MyCube.CubeGrid].WeaponBase.Count} "); return; } if (comp.HasArmor) { for (int i = 0; i < comp.Platform.Weapons.Length; i++) { var w = comp.Platform.Weapons[i]; if (w.System.Armor != WeaponDefinition.HardPointDef.HardwareDef.ArmorState.IsWeapon) { Armor.Remove(w.Comp.MyCube); } } Session.ArmorCubes.Remove(comp.MyCube); } Weapons.RemoveAtFast(idx); if (idx < Weapons.Count) { WeaponsIdx[Weapons[idx]] = idx; } //Session.IdToCompMap.Remove(comp.MyCube.EntityId); WeaponsIdx.Remove(comp); } }
public bool Contains(Weapon weapon) => Weapons.Contains(weapon);