public static void PostAwake(Handgun __instance) { if (__instance.FireSelectorModes.Length == 0) { return; } var hasFullAuto = __instance.FireSelectorModes.Any(t => t.ModeType == Handgun.FireSelectorModeType.FullAuto); if (hasFullAuto) { return; } var fullAuto = new Handgun.FireSelectorMode { SelectorPosition = __instance.FireSelectorModes[__instance.FireSelectorModes.Length - 1] .SelectorPosition, ModeType = Handgun.FireSelectorModeType.FullAuto }; __instance.FireSelectorModes = new List <Handgun.FireSelectorMode>(__instance.FireSelectorModes) { fullAuto }.ToArray(); }
public void AddFullAutoButton() { if ((detectedHandgun == null && detectedClosedBolt == null && detectedOpenBolt == null) || PanelCost > original.M.GetNumTokens()) { //Debug.Log("Can't add full auto!"); SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position); return; } else { //Debug.Log("Adding full auto!"); SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position); original.M.SubtractTokens(PanelCost); original.M.Increment(10, false); if (detectedHandgun != null) { AddFullAutoToHandgun(detectedHandgun); detectedHandgun = null; } else if (detectedClosedBolt != null) { AddFullAutoToClosedBolt(detectedClosedBolt); detectedClosedBolt = null; } else if (detectedOpenBolt != null) { AddFullAutoToOpenBolt(detectedOpenBolt); detectedOpenBolt = null; } } }
public static bool ToggleSafetyPrefix(Handgun __instance, ref int ___m_fireSelectorMode, ref bool ___m_isSafetyEngaged, ref bool ___m_isHammerCocked, ref bool __result) { if (!__instance.HasSafety) { __result = false; return(false); } if (__instance.DoesSafetyRequireSlideForward && __instance.Slide.CurPos != HandgunSlide.SlidePos.Forward) { __result = false; return(false); } if (__instance.Slide.CurPos == HandgunSlide.SlidePos.Forward || __instance.Slide.CurPos >= HandgunSlide.SlidePos.Locked) { if (___m_isSafetyEngaged) { __instance.PlayAudioEvent(FirearmAudioEventType.Safety); ___m_isSafetyEngaged = false; if (__instance.DoesSafetyDisengageCockHammer) { __instance.CockHammer(true); } ___m_fireSelectorMode = 0; } else if (__instance.FireSelectorModes[___m_fireSelectorMode].ModeType != Handgun.FireSelectorModeType.FullAuto) { __instance.PlayAudioEvent(FirearmAudioEventType.Safety, 0.7f); ___m_fireSelectorMode = (___m_fireSelectorMode + 1) % __instance.FireSelectorModes.Length; } else { ___m_fireSelectorMode = 0; var flag = !(__instance.DoesSafetyRequireCockedHammer && !___m_isHammerCocked); if (flag) { ___m_isSafetyEngaged = true; if (__instance.DoesSafetyEngagingDecock) { __instance.DeCockHammer(true, true); } __instance.PlayAudioEvent(FirearmAudioEventType.Safety); } } UpdateSafetyPos(__instance); __result = true; return(false); } __result = false; return(false); }
public void Start() { _chamber = firearm switch { ClosedBoltWeapon weapon => weapon.Chamber, OpenBoltReceiver receiver => receiver.Chamber, Handgun handgun => handgun.Chamber, _ => _chamber }; }
public void Init(Player player, PlayerStats playerStats, Handgun handgun, Shotgun shotgun, Machinegun machinegun, ControlsController controls, SignalBus bus) { _player = player; _playerStats = playerStats; _handgun = handgun; _shotgun = shotgun; _machinegun = machinegun; _controls = controls; _bus = bus; }
private void EnablePickup() { switch (_thisItem) { case _itemType.Handgun: Handgun playerHandgun = weaponManager.GetComponentInChildren <Handgun>(true); if (playerHandgun.CurrentAmmo < playerHandgun.MagazineCapacity + 1) // Check if we have less than 1 clip left, if so then respawn ammo, add +1 in case user is running around with one magazine left in ammo reserve { GetComponent <ParticleSystem>().Play(); GetComponent <Collider>().enabled = true; _pickupMesh.SetActive(true); CancelInvoke("EnablePickup"); // Make sure to cancel the invoke } break; case _itemType.Shotgun: Shotgun playerShotgun = weaponManager.GetComponentInChildren <Shotgun>(true); if (playerShotgun.CurrentAmmo < playerShotgun.MagazineCapacity * 2) // Check if we have less than 1 clip left, if so then respawn ammo { GetComponent <ParticleSystem>().Play(); GetComponent <Collider>().enabled = true; _pickupMesh.SetActive(true); CancelInvoke("EnablePickup"); } break; case _itemType.PlasmaRifle: PlasmaRifle playerPlasmaRifle = weaponManager.GetComponentInChildren <PlasmaRifle>(true); if (playerPlasmaRifle.CurrentAmmo < playerPlasmaRifle.MagazineCapacity) // Check if we have less than 1 clip left, if so then respawn ammo { GetComponent <ParticleSystem>().Play(); GetComponent <Collider>().enabled = true; _pickupMesh.SetActive(true); CancelInvoke("EnablePickup"); } break; case _itemType.HealthPickup: if (PlayerStats.PlayerHealth <= 30.0f) { GetComponent <ParticleSystem>().Play(); GetComponent <Collider>().enabled = true; _pickupMesh.SetActive(true); } break; case _itemType.AmmoPickup: break; default: break; } }
private void LoadFirearmProperties() { GameObject gunObject = GetGunObject().GetGameObject(); Handgun handgunComp = gunObject.GetComponent <Handgun>(); if (handgunComp != null) { foreach (Handgun.FireSelectorMode mode in handgunComp.FireSelectorModes) { FireSelectorModes.Add(new FireSelectorMode(mode)); } SpeedForward = handgunComp.Slide.Speed_Forward; SpeedRearward = handgunComp.Slide.Speed_Rearward; SpringStiffness = handgunComp.Slide.SpringStiffness; return; } ClosedBoltWeapon closedBoltComp = gunObject.GetComponent <ClosedBoltWeapon>(); if (closedBoltComp != null) { foreach (ClosedBoltWeapon.FireSelectorMode mode in closedBoltComp.FireSelector_Modes) { FireSelectorModes.Add(new FireSelectorMode(mode)); } SpeedForward = closedBoltComp.Bolt.Speed_Forward; SpeedRearward = closedBoltComp.Bolt.Speed_Rearward; SpringStiffness = closedBoltComp.Bolt.SpringStiffness; return; } OpenBoltReceiver openBoltComp = gunObject.GetComponent <OpenBoltReceiver>(); if (openBoltComp != null) { foreach (OpenBoltReceiver.FireSelectorMode mode in openBoltComp.FireSelector_Modes) { FireSelectorModes.Add(new FireSelectorMode(mode)); } SpeedForward = openBoltComp.Bolt.BoltSpeed_Forward; SpeedRearward = openBoltComp.Bolt.BoltSpeed_Rearward; SpringStiffness = openBoltComp.Bolt.BoltSpringStiffness; return; } }
private static bool HFHandgun(bool isManual, Handgun __instance) { if (!Meatyceiver.enableBrokenFirearmFailures.Value) { return(true); } float chance = Meatyceiver.HFRate.Value * Meatyceiver.generalMult.Value; if (Meatyceiver.CalcFail(chance, __instance)) { return(false); } return(true); }
public WeaponController(WeaponInventory inventory, Handgun handgun, Shotgun shotgun, Machinegun machinegun, SignalBus bus, PlayerStatsController playerStatsController) { _bus = bus; Handgun = handgun; Shotgun = shotgun; Machinegun = machinegun; Inventory = inventory; CurrentGun = Handgun; _playerStatsController = playerStatsController; InitialAmmoSurvivalMode(); }
public void Start() { if (weapon is Handgun) { hg = weapon as Handgun; } if (weapon is ClosedBoltWeapon) { cbw = weapon as ClosedBoltWeapon; } if (weapon is Handgun) { obr = weapon as OpenBoltReceiver; } }
static bool HandgunPatch_FailureToLockSlide(Handgun __instance) { if (!Meatyceiver.enableBrokenFirearmFailures.Value) { return(true); } string failureName = "Failure to lock slide"; float chance = Meatyceiver.FTLSlide.Value * Meatyceiver.generalMult.Value; if (Meatyceiver.CalcFail(chance, __instance)) { return(false); } return(true); }
private void Scan() { detectedHandgun = null; detectedClosedBolt = null; detectedOpenBolt = null; int colliderCount = Physics.OverlapBoxNonAlloc(original.ScanningVolume.position, original.ScanningVolume.localScale * 0.5f, colBuffer, original.ScanningVolume.rotation, original.ScanningLM, QueryTriggerInteraction.Collide); for (int i = 0; i < colliderCount; i++) { if (colBuffer[i].attachedRigidbody != null) { Handgun handgun = colBuffer[i].GetComponent <Handgun>(); if (handgun != null) { if (handgun.FireSelectorModes == null || !handgun.FireSelectorModes.Any(o => o.ModeType == Handgun.FireSelectorModeType.FullAuto)) { //Debug.Log("Hand gun detected!"); detectedHandgun = handgun; return; } } ClosedBoltWeapon closedBolt = colBuffer[i].GetComponent <ClosedBoltWeapon>(); if (closedBolt != null) { if (closedBolt.FireSelector_Modes == null || !closedBolt.FireSelector_Modes.Any(o => o.ModeType == ClosedBoltWeapon.FireSelectorModeType.FullAuto)) { //Debug.Log("Closed bolt detected!"); detectedClosedBolt = closedBolt; return; } } OpenBoltReceiver openBolt = colBuffer[i].GetComponent <OpenBoltReceiver>(); if (openBolt != null) { if (openBolt.FireSelector_Modes == null || !openBolt.FireSelector_Modes.Any(o => o.ModeType == OpenBoltReceiver.FireSelectorModeType.FullAuto)) { //Debug.Log("Open bolt detected!"); detectedOpenBolt = openBolt; return; } } } } }
void Start() { _handgunAnimator = transform.GetChild(0).GetComponent <Animator>(); _assaultRifleAnimator = transform.GetChild(1).GetComponent <Animator>(); _grenadeAnimator = transform.GetChild(2).GetComponent <Animator>(); _handgunAudioSource = transform.GetChild(0).GetComponent <AudioSource>(); _assaultRifleAudioSource = transform.GetChild(1).GetComponent <AudioSource>(); _grenadeAudioSource = transform.GetChild(2).GetComponent <AudioSource>(); _handgun = new Handgun(_handgunDamage, _handgunBulletAmount, _handgunAnimator, _handgunAudioSource); _assaultRifle = new AssaultRifle(_assaultRifleDamage, _assaultRifleBulletAmount, _assaultRifleAnimator, _assaultRifleAudioSource); _grenadeThrower = new GrenadeThrower(_grenadeDamage, _grenadeThrowForce, _grenadeAmount, _grenadeAnimator, _grenadeAudioSource); _weapons[0].SetActive(true); _weapons[1].SetActive(false); _weapons[2].SetActive(false); }
private PlayerMeleeAttack _meleeAttackScript; // Script for melee Attacking // ------------------------------------------------------------------------------------------ // METHOD: Awake() // DESCRIPTION: Cache global variables and convert layer names to their integer values // ------------------------------------------------------------------------------------------ void Awake() { TagsHashIDs = FindObjectOfType <TagsHashIDs>(); _weaponManagerScript = GetComponent <WeaponManager>(); _fpsAnimator = GetComponent <Animator>(); _noWeaponLayer = _fpsAnimator.GetLayerIndex("NoWeaponLayer"); _handgunLayer = _fpsAnimator.GetLayerIndex("HandgunLayer"); _macheteLayer = _fpsAnimator.GetLayerIndex("MacheteLayer"); _shotgunLayer = _fpsAnimator.GetLayerIndex("ShotgunLayer"); _plasmaRifleLayer = _fpsAnimator.GetLayerIndex("PlasmaRifleLayer"); //_pickupReloadLayer = _fpsAnimator.GetLayerIndex("PickupAndReload"); _handgun = GetComponentInChildren <Handgun>(true); _shotgun = GetComponentInChildren <Shotgun>(true); _plasmaRifle = GetComponentInChildren <PlasmaRifle>(true); }
public Player(TGCGame game, Camera camera, float yPosition = 0, Matrix?scaling = null) { this.Camera = camera; NewPosition = Camera.Position + new Vector3(0, yPosition, 0); UpVertex = NewPosition + HitboxSize; BottomVertex = NewPosition - HitboxSize; // Remover Weapons = new List <Weapon>(); Weapon machineGun = new MachineGun(); Weapon handgun = new Handgun(); Weapon rpg7 = new Rpg7(); Weapon shotgun = new Shotgun(); Weapons.Add(handgun); Weapons.Add(machineGun); Weapons.Add(shotgun); Weapons.Add(rpg7); CurrentWeapon = Weapons[0]; }
public void DecreaseFireRateButton() { if ((detectedHandgun == null && detectedClosedBolt == null && detectedOpenBolt == null) || PanelCost > original.M.GetNumTokens()) { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position); return; } else { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position); original.M.SubtractTokens(PanelCost); original.M.Increment(10, false); DecreaseFireRate(); detectedHandgun = null; detectedOpenBolt = null; detectedClosedBolt = null; } }
//create an array to hold four values //in handgun.cs AND stick.cs, set those four values protected virtual void Start() { handgun = this.GetComponentInChildren <Handgun>(true); stick = this.GetComponentInChildren <Stick>(true); animationName = null; }
// ------------------------------------------------------------------------ // Method: OnTriggerEnter // Description: Change a value in the player's script depending on which // item this script is attached to // ------------------------------------------------------------------------ private void OnTriggerEnter(Collider other) { // TODO Add pickup noise if (other.CompareTag(TagsHashIDs.Player)) { weaponManager = other.GetComponentInChildren <WeaponManager>(); switch (_thisItem) { case _itemType.Handgun: if (weaponManager.HasHandgun) { Handgun playerHandgun = weaponManager.GetComponentInChildren <Handgun>(true); // Check if we have maximum ammo before updating the ammo count and disabling the pickup: if (playerHandgun.CurrentAmmo < playerHandgun.MaximumAmmo) { for (int i = 0; i < playerHandgun.MagazineCapacity * 4; i++) // We gain 4 handgun clips from a pickup: { if (playerHandgun.CurrentAmmo < playerHandgun.MaximumAmmo) { playerHandgun.CurrentAmmo++; } } weaponManager.GetComponent <FPSRigAnimator>().UpdateAmmoDisplay(); if (playerHandgun.shotCount >= playerHandgun.MagazineCapacity && weaponManager.CurrentWeapon == WeaponSet.Handgun) { weaponManager.GetComponent <FPSRigAnimator>().TriggerReload(WeaponSet.Handgun); } DisablePickup(); } } else { weaponManager.HasHandgun = true; Handgun playerHandgun = weaponManager.GetComponentInChildren <Handgun>(true); if (weaponManager.GetComponent <FPSRigAnimator>().CanFire) // Only switch to the weapon automatically if we are not in reload animation { weaponManager.SwitchWeapon(WeaponSet.Handgun); } playerHandgun.CurrentAmmo = playerHandgun.MagazineCapacity * 4; if (weaponManager.CurrentWeapon == WeaponSet.Handgun) { // Only update the ammo display if that weapon is selected weaponManager.GetComponent <FPSRigAnimator>().UpdateAmmoDisplay(); } DisablePickup(); } break; case _itemType.Shotgun: if (weaponManager.HasShotgun) { Shotgun playerShotgun = weaponManager.GetComponentInChildren <Shotgun>(true); if (playerShotgun.CurrentAmmo < playerShotgun.MaximumAmmo) { for (int i = 0; i < playerShotgun.MagazineCapacity * 4; i++) { if (playerShotgun.CurrentAmmo < playerShotgun.MaximumAmmo) { playerShotgun.CurrentAmmo++; } } weaponManager.GetComponent <FPSRigAnimator>().UpdateAmmoDisplay(); if (playerShotgun.shotCount >= playerShotgun.MagazineCapacity && weaponManager.CurrentWeapon == WeaponSet.Shotgun) { weaponManager.GetComponent <FPSRigAnimator>().TriggerReload(WeaponSet.Shotgun); } DisablePickup(); } } else { weaponManager.HasShotgun = true; Shotgun playerShotgun = weaponManager.GetComponentInChildren <Shotgun>(true); if (weaponManager.GetComponent <FPSRigAnimator>().CanFire) // Only switch to the weapon automatically if we are not in reload animation { weaponManager.SwitchWeapon(WeaponSet.Shotgun); } playerShotgun.CurrentAmmo = playerShotgun.MagazineCapacity * 4; if (weaponManager.CurrentWeapon == WeaponSet.Shotgun) { weaponManager.GetComponent <FPSRigAnimator>().UpdateAmmoDisplay(); } DisablePickup(); } break; case _itemType.PlasmaRifle: if (weaponManager.HasPlasmaRifle) { PlasmaRifle playerPlasmaRifle = weaponManager.GetComponentInChildren <PlasmaRifle>(true); if (playerPlasmaRifle.CurrentAmmo < playerPlasmaRifle.MaximumAmmo) { for (int i = 0; i < playerPlasmaRifle.MagazineCapacity * 2; i++) { if (playerPlasmaRifle.CurrentAmmo < playerPlasmaRifle.MaximumAmmo) { playerPlasmaRifle.CurrentAmmo++; } } weaponManager.GetComponent <FPSRigAnimator>().UpdateAmmoDisplay(); if (playerPlasmaRifle.shotCount >= playerPlasmaRifle.MagazineCapacity && weaponManager.CurrentWeapon == WeaponSet.PlasmaRifle) { weaponManager.GetComponent <FPSRigAnimator>().TriggerReload(WeaponSet.PlasmaRifle); } DisablePickup(); } } else { weaponManager.HasPlasmaRifle = true; PlasmaRifle playerPlasmaRifle = weaponManager.GetComponentInChildren <PlasmaRifle>(true); if (weaponManager.GetComponent <FPSRigAnimator>().CanFire) // Only switch to the weapon automatically if we are not in reload animation { weaponManager.SwitchWeapon(WeaponSet.PlasmaRifle); } playerPlasmaRifle.CurrentAmmo = playerPlasmaRifle.MagazineCapacity * 2; if (weaponManager.CurrentWeapon == WeaponSet.PlasmaRifle) { weaponManager.GetComponent <FPSRigAnimator>().UpdateAmmoDisplay(); } DisablePickup(); } break; case _itemType.HealthPickup: // Check if the player can gain health if (PlayerStats.PlayerHealth < 100.0f) { other.GetComponent <PlayerLifecycle>().GainHealth(15f); DisablePickup(); } break; case _itemType.AmmoPickup: // Ammo pickup is handled if player picks up a weapon type but already has it gameObject.SetActive(false); break; default: break; } } }
public void ApplyFirearmProperties(FVRFireArm firearm) { if (!OverrideFireRate && !OverrideFireSelectors) { return; } Handgun handgunComp = firearm.gameObject.GetComponent <Handgun>(); if (handgunComp != null) { if (OverrideFireSelectors) { List <Handgun.FireSelectorMode> modeList = new List <Handgun.FireSelectorMode>(); foreach (FireSelectorMode mode in FireSelectorModes) { modeList.Add(mode.GetHandgunMode()); } handgunComp.FireSelectorModes = modeList.ToArray(); } if (OverrideFireRate) { handgunComp.Slide.Speed_Forward = SpeedForward; handgunComp.Slide.Speed_Rearward = SpeedRearward; handgunComp.Slide.SpringStiffness = SpringStiffness; } return; } ClosedBoltWeapon closedBoltComp = firearm.gameObject.GetComponent <ClosedBoltWeapon>(); if (closedBoltComp != null) { if (OverrideFireSelectors) { List <ClosedBoltWeapon.FireSelectorMode> modeList = new List <ClosedBoltWeapon.FireSelectorMode>(); foreach (FireSelectorMode mode in FireSelectorModes) { modeList.Add(mode.GetClosedBoltMode()); } closedBoltComp.FireSelector_Modes = modeList.ToArray(); } if (OverrideFireRate) { closedBoltComp.Bolt.Speed_Forward = SpeedForward; closedBoltComp.Bolt.Speed_Rearward = SpeedRearward; closedBoltComp.Bolt.SpringStiffness = SpringStiffness; } return; } OpenBoltReceiver openBoltComp = firearm.gameObject.GetComponent <OpenBoltReceiver>(); if (openBoltComp != null) { if (OverrideFireSelectors) { List <OpenBoltReceiver.FireSelectorMode> modeList = new List <OpenBoltReceiver.FireSelectorMode>(); foreach (FireSelectorMode mode in FireSelectorModes) { modeList.Add(mode.GetOpenBoltMode()); } openBoltComp.FireSelector_Modes = modeList.ToArray(); } if (OverrideFireRate) { openBoltComp.Bolt.BoltSpeed_Forward = SpeedForward; openBoltComp.Bolt.BoltSpeed_Rearward = SpeedRearward; openBoltComp.Bolt.BoltSpringStiffness = SpringStiffness; } return; } }
private void AddFullAutoToHandgun(Handgun gun) { Handgun.FireSelectorMode fullAuto = new Handgun.FireSelectorMode(); fullAuto.SelectorPosition = 0; fullAuto.ModeType = Handgun.FireSelectorModeType.FullAuto; if (gun.FireSelectorModes != null) { //Debug.Log("Fire Selector options before addition:"); foreach (Handgun.FireSelectorMode mode in gun.FireSelectorModes) { Debug.Log(mode.ModeType); } } if (gun.FireSelectorModes == null || gun.FireSelectorModes.Length == 0) { //Debug.Log("Handgun did not have any fire selector modes, so we're adding defaults"); Handgun.FireSelectorMode single = new Handgun.FireSelectorMode(); single.SelectorPosition = 0; single.ModeType = Handgun.FireSelectorModeType.Single; gun.FireSelectorModes = new Handgun.FireSelectorMode[] { single, fullAuto }; } else { //Debug.Log("Handgun had atleast one fire selector mode, Adding full auto"); List <Handgun.FireSelectorMode> modes = new List <Handgun.FireSelectorMode>(gun.FireSelectorModes); modes.Add(fullAuto); gun.FireSelectorModes = modes.ToArray(); //Debug.Log("Array count: " + gun.FireSelectorModes.Length + ", List count: " + modes.Count); } if (!gun.HasFireSelector) { //Debug.Log("Handgun was not originally configured to have fire selector. Configuring"); gun.HasFireSelector = true; if (gun.HasSafety) { //Debug.Log("Using safety object as fire selector"); gun.FireSelectorAxis = gun.SafetyAxis; gun.FireSelectorInterpStyle = gun.Safety_Interp; gun.FireSelector = gun.Safety; } else if (gun.FireSelector == null) { //Debug.Log("Creating dummy game object for fire selector"); gun.FireSelector = Instantiate(new GameObject(), gun.GameObject.transform).transform; } } if (gun.HasSafety) { //Debug.Log("Handgun originally had a safety, so we're removing that"); //gun.SetSafetyState(false); //gun.FireSelectorModes = gun.FireSelectorModes.Where(o => o.ModeType != Handgun.FireSelectorModeType.Safe).ToArray(); gun.AudioClipSet.FireSelector = gun.AudioClipSet.Safety; gun.HasSafety = false; } }
public void RefreshObjectControls(FVRPhysicalObject obj) { if (Object != null) { CleanupHeldObject(); } Object = obj; m_columnStarts = new int[] { 0, 0, 0 }; if (Object != null) { if (Panel != null && Panel.PageNameText != null && Object.ObjectWrapper != null) { Panel.PageNameText.text = PageTitle + " - " + Object.ObjectWrapper.DisplayName; } m_columnStarts[0] = AddObjectControls(Columns[0], m_columnStarts[0], Object, new string[] { "SpawnLockable", "Harnessable", "Size", "QBSlotType", "ThrowVelMultiplier", "ThrowAngMultiplier", "UsesGravity", "DoesQuickbeltSlotFollowHead", "DistantGrabbable", "IsPickUpLocked", "UseGripRotInterp" }); m_columnStarts[0] = AddObjectControls(Columns[0], m_columnStarts[0], Object, new string[] { "ToggleKinematicLocked" }, null, null, new bool[] { true }); if (Object.GetComponentInChildren <FVRFireArmMagazine>() != null) { m_columnStarts[2] = AddObjectControls(Columns[2], m_columnStarts[2], Object.GetComponentInChildren <FVRFireArmMagazine>(), new string[] { "m_capacity", "IsInfinite", "MagazineType", "RoundType", "FuelAmountLeft", "CanManuallyEjectRounds" }); } if (Object.GetComponentInChildren <FVRFireArmClip>() != null) { m_columnStarts[2] = AddObjectControls(Columns[2], m_columnStarts[2], Object.GetComponentInChildren <FVRFireArmClip>(), new string[] { "m_capacity", "IsInfinite", "ClipType", "RoundType", "CanManuallyEjectRounds" }); } #if !UNITY_EDITOR && !UNITY_STANDALONE if (Object.GetComponent <FVRFireArm>() != null) { m_columnStarts[0] = AddObjectControls(Columns[0], m_columnStarts[0] + 1, Object.GetComponent <FVRFireArm>(), new string[] { "MagazineType", "ClipType", "RoundType" }); if (m_curChamber == null) { TryToGetCurrentChamber(); } if (AccessTools.Field(Object.GetType(), "Chamber") != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetType().GetField("Chamber").GetValue(Object), new string[] { "RoundType", "ChamberVelocityMultiplier", "IsManuallyExtractable" }); } else if (AccessTools.Field(Object.GetType(), "m_curChamber") != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], m_curChamber, new string[] { "RoundType", "ChamberVelocityMultiplier", "IsManuallyExtractable" }, null, new bool[] { true, true, true }); } if (Object.GetComponent <Handgun>() != null) { Handgun handgun = Object.GetComponent <Handgun>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, handgun, new string[] { "HasManualDecocker", "HasMagReleaseInput", "CanPhysicsSlideRack" }); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, handgun.Slide, new string[] { "Speed_Forward", "Speed_Rearward", "Speed_Held", "SpringStiffness", "HasLastRoundSlideHoldOpen" }); AddObjectControls(Columns[2], 14, handgun.FireSelectorModes[handgun.FireSelectorModeIndex], new string[] { "ModeType", "BurstAmount" }); } else if (Object.GetComponent <OpenBoltReceiver>() != null) { OpenBoltReceiver obr = Object.GetComponent <OpenBoltReceiver>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, obr, new string[] { "HasMagReleaseButton" }); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, obr.Bolt, new string[] { "BoltSpeed_Forward", "BoltSpeed_Rearward", "BoltSpeed_Held", "BoltSpringStiffness", "HasLastRoundBoltHoldOpen", "BoltRot_Standard", "BoltRot_Safe", "BoltRot_SlipDistance" }); AddObjectControls(Columns[2], 14, obr.FireSelector_Modes[obr.FireSelectorModeIndex], new string[] { "ModeType" }); AddObjectControls(Columns[2], 15, obr, new string[] { "SuperBurstAmount" }); } else if (Object.GetComponent <ClosedBoltWeapon>() != null) { ClosedBoltWeapon cbw = Object.GetComponent <ClosedBoltWeapon>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, cbw, new string[] { "EjectsMagazineOnEmpty", "BoltLocksWhenNoMagazineFound", "DoesClipEntryRequireBoltBack", "HasMagReleaseButton" }); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, cbw.Bolt, new string[] { "Speed_Forward", "Speed_Rearward", "Speed_Held", "SpringStiffness", "HasLastRoundBoltHoldOpen", "UsesAKSafetyLock", "DoesClipHoldBoltOpen" }); AddObjectControls(Columns[2], 14, cbw.FireSelector_Modes[cbw.FireSelectorModeIndex], new string[] { "ModeType", "BurstAmount" }); } else if (Object.GetComponent <BreakActionWeapon>() != null) { BreakActionWeapon baw = Object.GetComponent <BreakActionWeapon>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], baw, new string[] { "m_isLatched", "UsesManuallyCockedHammers", "FireAllBarrels", "PopOutEmpties" }); for (int i = 0; i < baw.Barrels.Length; i++) { m_columnStarts[2] = AddObjectControls(Columns[2], m_columnStarts[2], baw.Barrels[i].Chamber, new string[] { "RoundType", "ChamberVelocityMultiplier", "SpreadRangeModifier" }); } } else if (Object.GetComponent <TubeFedShotgun>() != null) { TubeFedShotgun tfs = Object.GetComponent <TubeFedShotgun>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, tfs, new string[] { "m_isHammerCocked", "UsesSlamFireTrigger", "CanModeSwitch" }); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, tfs.Bolt, new string[] { "Speed_Forward", "Speed_Rearward", "Speed_Held", "SpringStiffness", "HasLastRoundBoltHoldOpen" }); if (tfs.Handle != null) { m_columnStarts[2] = AddObjectControls(Columns[2], m_columnStarts[2] + 1, tfs.Handle, new string[] { "Speed_Held", "m_isHandleLocked" }); } } else if (Object.GetComponent <Flaregun>() != null) { Flaregun flaregun = Object.GetComponent <Flaregun>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, flaregun, new string[] { "HingeAxis", "RotOut", "CanUnlatch", "IsHighPressureTolerant", "m_isHammerCocked", "m_isDestroyed", "CocksOnOpen" }); } else if (Object.GetComponent <SimpleLauncher>() != null) { SimpleLauncher sl = Object.GetComponent <SimpleLauncher>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, sl, new string[] { "HasTrigger", "AlsoPlaysSuppressedSound", "DeletesCartridgeOnFire", "FireOnCol", "ColThresh" }); } else if (Object.GetComponent <BoltActionRifle>() != null) { BoltActionRifle bar = Object.GetComponent <BoltActionRifle>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, bar, new string[] { "HasMagEjectionButton", "m_isHammerCocked", "EjectsMagazineOnEmpty", "HasMagEjectionButton" }); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, bar.BoltHandle, new string[] { "UsesQuickRelease", "BaseRotOffset", "MinRot", "MaxRot", "UnlockThreshold" }); } else if (Object.GetComponent <Revolver>() != null) { Revolver revolver = Object.GetComponent <Revolver>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, revolver, new string[] { "CanManuallyCockHammer", "m_isHammerLocked", "m_isCylinderArmLocked", "CylinderRotRange", "IsCylinderArmZ", "GravityRotsCylinderPositive" }); } else if (Object.GetComponent <LAPD2019>() != null) { LAPD2019 lapd = Object.GetComponent <LAPD2019>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1] + 1, lapd, new string[] { "m_isCylinderArmLocked", "CylinderRotRange", "GravityRotsCylinderPositive", "m_isAutoChargeEnabled", "m_hasBattery", "m_batteryCharge", "m_hasThermalClip", "m_heatThermalClip", "m_heatSystem", "m_barrelHeatDamage" }); m_columnStarts[2] = AddObjectControls(Columns[2], m_columnStarts[2], lapd.BoltHandle, new string[] { "UsesQuickRelease", "BaseRotOffset", "MinRot", "MaxRot", "UnlockThreshold" }); } m_curChamberIndex = 0; } else if (Object.GetComponent <FVRFireArmRound>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <FVRFireArmRound>(), new string[] { "RoundType", "RoundClass", "IsHighPressure", "NumProjectiles", "ProjectileSpread", "IsDestroyedAfterCounter", "m_isKillCounting", "isCookingOff", "isManuallyChamberable", "IsCaseless", "isMagazineLoadable", "isPalmable", "MaxPalmedAmount" }); } else if (Object.GetComponent <FVRGrenade>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <FVRGrenade>(), new string[] { "DefaultFuse" }); } else if (Object.GetComponent <MF2_Medigun>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <MF2_Medigun>(), new string[] { "EngageRange", "MaxRange", "TryEngageBeam", "EngageUber", "DisEngageBeam", "m_uberChargeUp", "m_uberChargeOut" }); } else if (Object.GetComponent <SosigLink>() != null) { SosigLink L = Object.GetComponent <SosigLink>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], L.S, new string[] { "ClearSosig", "", "BodyState", "CurrentOrder", "Mustard", "BleedDamageMult", "BleedRateMult", "Speed_Crawl", "Speed_Sneak", "Speed_Walk", "Speed_Run" }); m_columnStarts[2] = AddObjectControls(Columns[2], m_columnStarts[2], L, new string[] { "m_integrity", "StaggerMagnitude", "DamMult" }); } else if (Object.GetComponent <SosigWeaponPlayerInterface>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <SosigWeaponPlayerInterface>().W, new string[] { "CycleSpeedForward", "CycleSpeedBackward", "ShotsPerLoad", "m_shotsLeft", "ProjectilesPerShot", "ProjectileSpread", "isFullAuto", "ReloadTime", "BurstLimit" }); } else if (Object.GetComponent <RW_Powerup>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <RW_Powerup>(), new string[] { "PowerupType", "PowerupIntensity", "PowerupDuration", "PowerUpSpecial", "Cooked", "UpdateSymbols" }); } else if (Object.GetComponent <ShatterablePhysicalObject>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <ShatterablePhysicalObject>(), new string[] { "currentToughness", "TransfersVelocityExplosively", "DamageReceivedMultiplier", "CollisionShatterThreshold" }); } else if (Object.GetComponent <RotrwBangerJunk>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <RotrwBangerJunk>(), new string[] { "Type", "ContainerSize" }); } else if (Object.GetComponent <Banger>() != null) { Banger banger = Object.GetComponent <Banger>(); m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], banger, new string[] { "BType", "BSize", "m_isArmed", "m_timeToPayload", "ProxRange", "m_timeSinceArmed", "m_shrapnelVel", "m_isSticky", "m_isSilent", "m_isHoming", "m_canbeshot", "SetToBouncy" }); if (banger.BDial != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], banger.BDial, new string[] { "DialTick", "m_isPrimed", "m_hasDinged" }); } } else if (Object.GetComponent <BangerDetonator>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <BangerDetonator>(), new string[] { "TriggerRange", "Detonate" }); } else if (Object.GetComponent <GronchHatCase>() != null) { m_columnStarts[1] = AddObjectControls(Columns[1], m_columnStarts[1], Object.GetComponent <GronchHatCase>(), new string[] { "m_isOpen", "Open", "HID" }, null, null, new bool[] { false, true, false }, new object[][] { null, new object[] { new GameObject("dummy").AddComponent <GronchHatCaseKey>() }, null }); } #endif } }
public void BoltSpeedModifier(actionType ActType) { int wepType = 0; OpenBoltReceiver _OpenBoltWep = null; ClosedBoltWeapon _ClosedBoltWep = null; Handgun _HandgunWep = null; TubeFedShotgun _TFWep = null; if (weapon is OpenBoltReceiver) { _OpenBoltWep = weapon as OpenBoltReceiver; wepType = 1; } else if (weapon is ClosedBoltWeapon) { _ClosedBoltWep = weapon as ClosedBoltWeapon; wepType = 2; } else if (weapon is Handgun) { _HandgunWep = weapon as Handgun; wepType = 3; } else if (weapon is TubeFedShotgun) { _TFWep = weapon as TubeFedShotgun; wepType = 4; } float _boltSpeedBack = 0; float _boltSpeedForward = 0; float _boltSpringStiffness = 0; switch (wepType) { case 1: _boltSpeedBack = _OpenBoltWep.Bolt.BoltSpeed_Rearward; _boltSpeedForward = _OpenBoltWep.Bolt.BoltSpeed_Forward; _boltSpringStiffness = _OpenBoltWep.Bolt.BoltSpringStiffness; break; case 2: _boltSpeedBack = _ClosedBoltWep.Bolt.Speed_Rearward; _boltSpeedForward = _ClosedBoltWep.Bolt.Speed_Forward; _boltSpringStiffness = _ClosedBoltWep.Bolt.SpringStiffness; break; case 3: _boltSpeedBack = _HandgunWep.Slide.Speed_Forward; _boltSpeedForward = _HandgunWep.Slide.Speed_Rearward; _boltSpringStiffness = _HandgunWep.Slide.SpringStiffness; break; } if (ActType == actionType.attach) { prevBoltSpeedBackwards = _boltSpeedBack; prevBoltSpeedForward = _boltSpeedForward; prevBoltSpringStiffness = _boltSpringStiffness; if (BoltSpeedModifierType == CapType.SetTo) { _boltSpeedBack = BoltSpeedBackwards; _boltSpeedForward = BoltSpeedForward; _boltSpringStiffness = BoltSpringStiffness; } if (BoltSpeedModifierType == CapType.AddTo) { _boltSpeedBack += BoltSpeedBackwards; _boltSpeedForward += BoltSpeedForward; _boltSpringStiffness += BoltSpringStiffness; } } if (ActType == actionType.detach) { _boltSpeedBack = prevBoltSpeedBackwards; _boltSpeedForward = prevBoltSpeedForward; _boltSpringStiffness = prevBoltSpringStiffness; } if (ChangesBoltSpeedRearward) { switch (wepType) { case 1: _OpenBoltWep.Bolt.BoltSpeed_Rearward = _boltSpeedBack; break; case 2: _ClosedBoltWep.Bolt.Speed_Rearward = _boltSpeedBack; break; case 3: _HandgunWep.Slide.Speed_Forward = _boltSpeedBack; break; } } if (ChangesBoltSpeedForward) { switch (wepType) { case 1: _OpenBoltWep.Bolt.BoltSpeed_Forward = _boltSpeedForward; break; case 2: _ClosedBoltWep.Bolt.Speed_Forward = _boltSpeedForward; break; case 3: _HandgunWep.Slide.Speed_Rearward = _boltSpeedForward; break; } } if (ChangesBoltSpeedStiffness) { switch (wepType) { case 1: _OpenBoltWep.Bolt.BoltSpringStiffness = _boltSpringStiffness; break; case 2: _ClosedBoltWep.Bolt.SpringStiffness = _boltSpringStiffness; break; case 3: _HandgunWep.Slide.SpringStiffness = _boltSpringStiffness; break; } } }