Пример #1
0
 public void RegisterWeapon(Weapon weapon)
 {
     if (weapon != null && !Weapons.Contains(weapon))
     {
         Weapons.Add(weapon);
     }
 }
Пример #2
0
 private void AddWeapon(string weapon)
 {
     if (!Weapons.Contains(weapon))
     {
         Weapons.Add(weapon);
     }
 }
Пример #3
0
        /// <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);
        }
Пример #4
0
 public void AddWeapon(WeaponTypes weaponType)
 {
     if (!Weapons.Contains(weaponType))
     {
         Weapons.Add(weaponType);
     }
 }
Пример #5
0
 private static bool GetIsWeapon(int itemType)
 {
     if (Weapons.Contains(itemType))
     {
         return(true);
     }
     return(false);
 }
Пример #6
0
 public Inventory Remove(Weapon w)
 {
     if (Weapons.Contains(w))
     {
         Weapons.Remove(w);
     }
     return(this);
 }
Пример #7
0
 public void ChangeWeapon(Weapon newWeapon)
 {
     if (Weapons.Contains(newWeapon))
     {
         ActiveWeapon = newWeapon;
         if (PlayerChangedWeaponEvent != null)
         {
             PlayerChangedWeaponEvent();
         }
     }
 }
Пример #8
0
    public bool ObtainWeapon(Weapon weapon)
    {
        if (Full())
        {
            return(false);
        }

        weapon.transform.parent = m_weapons.transform;
        if (!Weapons.Contains(weapon))
        {
            Weapons.Add(weapon);
        }

        return(true);
    }
Пример #9
0
 /// <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;
 }
Пример #10
0
        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);
            }
        }
Пример #11
0
 public bool Contains(Weapon weapon) => Weapons.Contains(weapon);