Esempio n. 1
0
 static void GunItem_ZoomStart_Postfix(GunItem __instance)
 {
     if (__instance.m_GunType == GunType.Revolver && Main.config.allowWalkWhileAimingRevolver)
     {
         GameUtils.PlayerManager.SetControlMode(__instance.m_RestoreControlMode);
     }
 }
Esempio n. 2
0
 internal static void Postfix(GunItem __instance)
 {
     if (Weapon_Settings.Get().no_jam_delay)
     {
         GameManager.GetVpFPSCamera().CurrentShooter.NextAllowedReloadTime = Time.time;
     }
 }
Esempio n. 3
0
 public void InitBullet(GunItem gunItem, Character shooter)
 {
     this.damage  = gunItem.damage;
     this.speed   = gunItem.bulletSpeed;
     this.range   = gunItem.range;
     this.shooter = shooter;
 }
Esempio n. 4
0
        void FillAmmo(PlayerSession player)
        {
            if (!player.IsLoaded || !player.Player.isConnected)
            {
                return;
            }

            NetworkEntityComponentBase netEntity = player.WorldPlayerEntity.GetComponent <NetworkEntityComponentBase>();

            if (netEntity == null)
            {
                return;
            }

            EquippedHandlerBase equippedHandler = netEntity.GetComponent <EquippedHandlerBase>();

            if (equippedHandler == null)
            {
                return;
            }

            EquippedHandlerServer equippedHandlerServer = equippedHandler as EquippedHandlerServer;

            if (equippedHandlerServer == null)
            {
                return;
            }

            ItemInstance equippedItem = equippedHandler.GetEquippedItem();

            if (equippedItem == null)
            {
                return;
            }

            GunItem gunItem = equippedItem.Item as GunItem;
            BowItem bowItem = equippedItem.Item as BowItem;

            if ((bowItem != null || gunItem != null) && equippedHandlerServer != null)
            {
                if (gunItem != null)
                {
                    AutomaticGunItem     aGunItem      = gunItem as AutomaticGunItem;
                    GunItemEquippedState gunEquipState = gunItem.EquippedState(equippedHandler);

                    equippedItem.AuxData = Convert.ToByte(gunItem.GetClipSize());
                    equippedHandlerServer.AuxSync();
                }
                else
                {
                    PlayerInventory inventory = player.WorldPlayerEntity.GetComponent <PlayerInventory>();

                    if (!inventory.HasItem(bowItem.GetAmmoType().ItemId, 1))
                    {
                        GiveItem(player, bowItem.GetAmmoType(), 1);
                    }
                }
            }
        }
Esempio n. 5
0
 public void InitializeGun(GunItem item)
 {
     GetComponent <SpriteRenderer>().sprite = item.icon;
     bullet       = item.bullet;
     timeToShoot  = item.timeToShoot;
     timeToReload = item.timeToReload;
     maxBullets   = item.maxBullets;
 }
Esempio n. 6
0
        static void GunItem_Start_Postfix(GunItem __instance)
        {
            __instance.m_FireDelayAfterReload = __instance.m_FireDelayOnAim = 0f;

            if (__instance.m_GunType == GunType.Revolver)
            {
                __instance.m_FiringRateSeconds = Main.config.revolverFiringRate;
            }
        }
Esempio n. 7
0
    /// <summary>
    /// Trying to equip the gun
    /// </summary>
    /// <param name="gunModel"></param>
    private void EquipGun(GunItem gunModel)
    {
        PlayerGunHolster gunHolster = GetComponent <PlayerGunHolster>();

        if (gunHolster != null)
        {
            gunHolster.Equip(gunModel, this.SwapItem);
        }
    }
Esempio n. 8
0
    public void Equip(GunItem gunModel, Action <GunItem> callback)
    {
        if (callback != null && this.playerGunDataModel.HasGunEquipped())
        {
            callback(this.playerGunDataModel.GunItem);
        }

        this.EquipGun(gunModel);
    }
Esempio n. 9
0
 public void SwapStats(GunItem newGun)
 {
     this.gunItem = newGun;
     this.fireRateInSeconds.Variable.SetValue(newGun.fireRateInSeconds);
     this.gunBarrelYCenterPositionInPixels.Variable.SetValue(newGun.gunBarrelYCenterPositionInPixels);
     this.recoilDegrees.Variable.SetValue(newGun.recoilDegrees);
     this.recoilDuration.Variable.SetValue(newGun.recoilDuration);
     this.projectilePrefab  = newGun.projectilePrefab;
     this.muzzleFlashPrefab = newGun.muzzleFlashPrefab;
 }
Esempio n. 10
0
 public void ResetStats()
 {
     this.gunItem = null;
     this.fireRateInSeconds.Variable.SetValue(0f);
     this.gunBarrelYCenterPositionInPixels.Variable.SetValue(0f);
     this.recoilDegrees.Variable.SetValue(0f);
     this.recoilDuration.Variable.SetValue(0f);
     this.projectilePrefab  = null;
     this.muzzleFlashPrefab = null;
 }
Esempio n. 11
0
 public void SetAnimationType(GunItem gunItem)
 {
     if (gunItem.gunType == GunType.Pistol)
     {
         animator.SetInteger("Gun", 1);
     }
     else
     {
         animator.SetInteger("Gun", 2);
     }
 }
Esempio n. 12
0
    private static void SpawnGun()
    {
        GameObject ar15     = UnityEngine.Object.Instantiate <GameObject>(Resources.Load("GEAR_Rifle") as GameObject);
        GunItem    ar15Gun  = ar15.GetComponent <GunItem>();
        GearItem   ar15Gear = ar15.GetComponent <GearItem>();

        ar15Gun.m_ClipSize             = 5;
        ar15Gun.m_FiringRateSeconds    = 0;
        ar15Gun.m_FireDelayOnAim       = 0;
        ar15Gun.m_FireDelayAfterReload = 0;
        ar15Gear.name = "ar15";
        Transform player = GameManager.GetVpFPSCamera().transform;

        ar15.transform.position = player.position;
    }
Esempio n. 13
0
    public bool AddGunToInventory(Gun g)
    {
        foreach (GunItem item in inventory)
        {
            if (item.gun.name.Equals(g.name))
            {
                return(false);
            }
        }

        GunItem gunItem = new GunItem(g);

        inventory.Add(gunItem);
        inventory [inventory.Count - 1].gun.Init();
        return(true);
    }
Esempio n. 14
0
        private static void ConfigureRifle(ModComponent modComponent)
        {
            ModRifleComponent modRifleComponent = modComponent as ModRifleComponent;

            if (modRifleComponent == null)
            {
                return;
            }

            GunItem gunItem = ModUtils.GetOrCreateComponent <GunItem>(modRifleComponent);

            gunItem.m_GunType        = GunType.Rifle;
            gunItem.m_AmmoPrefab     = (GameObject)Resources.Load("GEAR_RifleAmmoSingle");
            gunItem.m_AmmoSpriteName = "ico_units_ammo";

            gunItem.m_AccuracyRange          = modRifleComponent.Range;
            gunItem.m_ClipSize               = modRifleComponent.ClipSize;
            gunItem.m_DamageHP               = modRifleComponent.DamagePerShot;
            gunItem.m_FiringRateSeconds      = modRifleComponent.FiringDelay;
            gunItem.m_MuzzleFlash_FlashDelay = modRifleComponent.MuzzleFlashDelay;
            gunItem.m_MuzzleFlash_SmokeDelay = modRifleComponent.MuzzleSmokeDelay;
            gunItem.m_ReloadCoolDownSeconds  = modRifleComponent.ReloadDelay;

            gunItem.m_DryFireAudio = "Play_RifleDryFire";
            gunItem.m_ImpactAudio  = "Play_BulletImpacts";

            gunItem.m_SwayIncreasePerSecond = modRifleComponent.SwayIncrement;
            gunItem.m_SwayValueZeroFatigue  = modRifleComponent.MinSway;
            gunItem.m_SwayValueMaxFatigue   = modRifleComponent.MaxSway;

            Cleanable cleanable = ModUtils.GetOrCreateComponent <Cleanable>(modRifleComponent);

            cleanable.m_ConditionIncreaseMin = 2;
            cleanable.m_ConditionIncreaseMin = 5;
            cleanable.m_DurationMinutesMin   = 15;
            cleanable.m_DurationMinutesMax   = 5;
            cleanable.m_CleanAudio           = "Play_RifleCleaning";
            cleanable.m_RequiresToolToClean  = true;
            cleanable.m_CleanToolChoices     = new ToolsItem[] { Resources.Load <GameObject>("GEAR_RifleCleaningKit").GetComponent <ToolsItem>() };

            FirstPersonItem firstPersonItem = ConfiguredRifleFirstPersonItem(modRifleComponent);

            ModAnimationStateMachine animation = ModUtils.GetOrCreateComponent <ModAnimationStateMachine>(modRifleComponent);

            animation.SetTransitions(firstPersonItem.m_PlayerStateTransitions);
        }
Esempio n. 15
0
    private void EquipGun(GunItem gunModel)
    {
        if (!this.gunPrefab.activeSelf)
        {
            this.gunPrefab.SetActive(true);
        }

        if (this.gunSpriteRenderer != null)
        {
            this.gunSpriteRenderer.sprite = gunModel.sprite;
        }

        if (this.gunShooter != null)
        {
            this.gunShooter.Setup(gunModel.projectilePrefab, gunModel.muzzleFlashPrefab);
        }

        this.playerGunDataModel.SwapStats(gunModel);
    }
Esempio n. 16
0
        public override void PreUpdate()
        {
            GunItem gunItem = null;

            if (player.HeldItem != null && player.HeldItem.modItem is GunItem csGun)
            {
                gunItem = csGun;
            }

            if (gunItem == null || gunItem.Definition.GetAccuracyChangePerShot(this) < 0)
            {
                AccuracyFactor += ACCURACY_PER_TICK;

                if (AccuracyFactor >= 1)
                {
                    AccuracyFactor = 1;
                }
            }
            else if (gunItem.Definition.GetAccuracyChangePerShot(this) > 0 && !LeftClick)
            {
                AccuracyFactor = 0;
            }
        }
Esempio n. 17
0
    public void OnDrop(PointerEventData eventData)
    {
        if (EventSystem.current.currentSelectedGameObject != null)
        {
            Vector3 mousePosition = Input.mousePosition;

            RectTransform invEntry = transform as RectTransform;

            Debug.Log("Dropped at " + mousePosition);
            if (RectTransformUtility.RectangleContainsScreenPoint(invEntry, mousePosition))
            {
                gun         = EventSystem.current.currentSelectedGameObject.GetComponent <Draggable>().gun;
                icon.sprite = gun.icon;
                if (gun.name != "Pistol" && gun.name != "Laser" && gun.name != "Shuriken")
                {
                    icon.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 80);
                    icon.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40);
                    icon.transform.rotation = Quaternion.Euler(0f, 0f, 45f);
                }
                switch (id)
                {
                case 1:
                    SelectedGuns.gun1 = gun;
                    break;

                case 2:
                    SelectedGuns.gun2 = gun;
                    break;

                case 3:
                    SelectedGuns.gun3 = gun;
                    break;
                }
            }
        }
    }
Esempio n. 18
0
        ////////////////////////////////////////
        ///     Ammo Related
        ////////////////////////////////////////

        /*void OnWeaponFired(IItem item, EquippedHandlerBase handler)
         * {
         * }*/

        void LoadAmmo(PlayerSession player)
        {
            if (!player.IsLoaded)
            {
                return;
            }

            NetworkEntityComponentBase netEntity = player.WorldPlayerEntity.GetComponent <NetworkEntityComponentBase>();

            if (netEntity == null)
            {
                return;
            }

            EquippedHandlerBase equippedHandler = netEntity.GetComponent <EquippedHandlerBase>();

            if (equippedHandler == null)
            {
                return;
            }

            EquippedHandlerServer equippedHandlerServer = equippedHandler as EquippedHandlerServer;

            if (equippedHandlerServer == null)
            {
                return;
            }

            ItemInstance equippedItem = equippedHandler.GetEquippedItem();

            if (equippedItem == null)
            {
                return;
            }

            GunItem gunItem = equippedItem.Item as GunItem;
            BowItem bowItem = equippedItem.Item as BowItem;

            //PrintWarning($"Item: {equippedItem.Item.GetNameKey().Split('/').Last()}");
            //PrintWarning($"Is Gun: {!(gunItem == null)}");

            if ((bowItem != null || gunItem != null) && equippedHandlerServer != null)
            {
                if (gunItem != null)
                {
                    AutomaticGunItem     aGunItem      = gunItem as AutomaticGunItem;
                    GunItemEquippedState gunEquipState = gunItem.EquippedState(equippedHandler);

                    //PrintWarning($"Is Automatic: {!(aGunItem == null)}");
                    //PrintWarning($"Clip Size: {gunItem.GetClipSize().ToString()}");
                    //PrintWarning($"Ammo Count: {equippedItem.AuxData.ToString()}");

                    //if (equippedItem.AuxData <= 1)
                    //{
                    equippedItem.AuxData = Convert.ToByte(gunItem.GetClipSize());
                    equippedHandlerServer.AuxSync();
                    //}
                }
                else
                {
                    PlayerInventory inventory = player.WorldPlayerEntity.GetComponent <PlayerInventory>();

                    //PrintWarning($"Has Ammo: {inventory.HasItem(bowItem.GetAmmoType().ItemId, 1)}");

                    if (!inventory.HasItem(bowItem.GetAmmoType().ItemId, 1))
                    {
                        GiveItem(player, bowItem.GetAmmoType(), 1);
                    }
                }
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Picks up drop, sends data to network.
 /// </summary>
 /// <param name="item">Item received.</param>
 /// <param name="player">Player who caught it.</param>
 public void PickUp(GunItem item, PlayerManager player)
 {
     networkLayer.CatchItem(item, player);
 }
 /// <summary>
 /// Picks up drop, sends data to network.
 /// </summary>
 /// <param name="item">Item received.</param>
 /// <param name="player">Player who caught it.</param>
 public void PickUp(GunItem item, PlayerManager player)
 {
     networkLayer.CatchItem(item, player);
 }
Esempio n. 21
0
 virtual protected void InitItem()
 {
     _gun = GunObject.AddComponent <NWayGunItem>();
     //_gun = GunObject.AddComponent<SparialGunItem>();
     _gun.SetBullet(BulletPrefab);
 }
Esempio n. 22
0
 public void Init(GunItem gunItem)
 {
     _parentGunItem = gunItem;
 }
Esempio n. 23
0
 public static void clearGuns()
 {
     gun1 = null;
     gun2 = null;
     gun3 = null;
 }
Esempio n. 24
0
 public void Init(GunItem parentGunItem)
 {
     _parentGunItem = parentGunItem;
 }
Esempio n. 25
0
 private void EquipGun(GunItem g)
 {
     currentGunItem = g;
 }
 /// <summary>
 /// Sends data to network, to catch a scpecific item.
 /// </summary>
 /// <param name="item">Item caught.</param>
 /// <param name="player">Player who caught it.</param>
 public void CatchItem(GunItem item, PlayerManager player)
 {
     photonView.RPC("OnNetworkCatchItem", PhotonTargets.All, item.name, player.name);
 }
Esempio n. 27
0
 /// <summary>
 /// Sends data to network, to catch a scpecific item.
 /// </summary>
 /// <param name="item">Item caught.</param>
 /// <param name="player">Player who caught it.</param>
 public void CatchItem(GunItem item, PlayerManager player)
 {
     photonView.RPC("OnNetworkCatchItem", PhotonTargets.All, item.name, player.name);
 }