Ejemplo n.º 1
0
 public static void Prefix(MicroHID __instance)
 {
     if (!timers.ContainsKey(__instance))
     {
         timers.Add(__instance, 0f);
     }
     if (__instance.refHub.inventory.curItem == ItemType.MicroHID && __instance.NetworkCurrentHidState == MicroHID.MicroHidState.Idle)
     {
         timers[__instance] += Time.deltaTime;
         if (timers[__instance] >= MicroHIDPlugin.instance.Config.mhid_charge_interval)
         {
             timers[__instance] = 0f;
             __instance.ChangeEnergy(__instance.GetEnergy() + MicroHIDPlugin.instance.Config.mhid_charge_rate);
             __instance.Energy        = __instance.GetEnergy();
             __instance.NetworkEnergy = __instance.GetEnergy();
         }
     }
     if (__instance.refHub.inventory.curItem == ItemType.MicroHID && (__instance.NetworkCurrentHidState == MicroHID.MicroHidState.Discharge || __instance.NetworkCurrentHidState == MicroHID.MicroHidState.Spinning))
     {
         timers[__instance] += Time.deltaTime;
         if (timers[__instance] >= MicroHIDPlugin.instance.Config.mhid_charge_use_interval)
         {
             timers[__instance] = 0f;
             __instance.ChangeEnergy(__instance.GetEnergy() + MicroHIDPlugin.instance.Config.mhid_charge_use_rate);
             __instance.Energy        = __instance.GetEnergy();
             __instance.NetworkEnergy = __instance.GetEnergy();
         }
     }
 }
Ejemplo n.º 2
0
 public static bool Prefix(MicroHID __instance)
 {
     if (__instance.refHub.TryGetComponent(out InfiniteAmmoComponent infAmmo) && __instance.refHub.inventory.curItem == ItemType.MicroHID)
     {
         __instance.ChangeEnergy(1);
         __instance.NetworkEnergy = 1;
     }
     return(true);
 }
Ejemplo n.º 3
0
        private static void Prefix(MicroHID __instance)
        {
            var ply = Player.Get(__instance.gameObject);

            if (SameThings.Instance.Config.InfiniteMicroAmmo && ply.CurrentItem.id == ItemType.MicroHID)
            {
                __instance.ChangeEnergy(1);
                __instance.NetworkEnergy = 1;
            }
        }
Ejemplo n.º 4
0
 public static void Prefix(MicroHID __instance)
 {
     __instance.chargeupTime   = MicroHIDPlugin.instance.Config.chargeupTime;
     __instance.chargedownTime = MicroHIDPlugin.instance.Config.chargedownTime;
     if (MicroHIDPlugin.instance.Config.disablePreDischarge)
     {
         __instance.soundEffectPause = 1.5f;
     }
     if (!timers.ContainsKey(__instance))
     {
         timers.Add(__instance, 0f);
     }
     if (__instance.refHub.inventory.curItem == ItemType.MicroHID && __instance.NetworkCurrentHidState == MicroHID.MicroHidState.Idle)
     {
         timers[__instance] += Time.deltaTime;
         if (timers[__instance] >= MicroHIDPlugin.instance.Config.mhid_charge_interval)
         {
             timers[__instance] = 0f;
             __instance.ChangeEnergy(__instance.GetEnergy() + MicroHIDPlugin.instance.Config.mhid_charge_rate);
             __instance.NetworkEnergy = __instance.GetEnergy();
         }
     }
     if (__instance.refHub.inventory.curItem == ItemType.MicroHID && __instance.NetworkCurrentHidState == MicroHID.MicroHidState.Discharge)
     {
         timers[__instance] += Time.deltaTime;
         if (timers[__instance] >= MicroHIDPlugin.instance.Config.mhid_charge_use_interval)
         {
             timers[__instance] = 0f;
             __instance.ChangeEnergy(__instance.GetEnergy() + MicroHIDPlugin.instance.Config.mhid_charge_use_rate);
             __instance.NetworkEnergy = __instance.GetEnergy();
         }
     }
     if (__instance.refHub.inventory.curItem == ItemType.MicroHID && __instance.NetworkCurrentHidState == MicroHID.MicroHidState.Spinning)
     {
         timers[__instance] += Time.deltaTime;
         if (timers[__instance] >= MicroHIDPlugin.instance.Config.mhid_charge_use_idle_interval)
         {
             timers[__instance] = 0f;
             __instance.ChangeEnergy(__instance.GetEnergy() + MicroHIDPlugin.instance.Config.mhid_charge_use_idle_rate);
             __instance.NetworkEnergy = __instance.GetEnergy();
         }
     }
 }
        private static bool Prefix(MicroHID __instance)
        {
            if (!__instance.refHub.TryGetComponent(out InfiniteAmmoComponent infAmmo) ||
                __instance.refHub.inventory.curItem != ItemType.MicroHID)
            {
                return(true);
            }

            __instance.ChangeEnergy(1);
            __instance.NetworkEnergy = 1;
            return(true);
        }
Ejemplo n.º 6
0
        private static bool Prefix(MicroHID __instance)
        {
            try
            {
                if (!NetworkServer.active)
                {
                    return(false);
                }

                if (__instance.refHub.inventory.curItem == ItemType.MicroHID && __instance.GetEnergy() != __instance.Energy)
                {
                    __instance.ChangeEnergy(__instance.Energy);
                }

                else
                {
                    foreach (var item in __instance.refHub.inventory.items)
                    {
                        if (item.id == ItemType.MicroHID)
                        {
                            __instance.NetworkEnergy = item.durability;
                        }
                    }
                }

                if (__instance.keyAntiSpamCooldown > 0f)
                {
                    __instance.keyAntiSpamCooldown -= Time.deltaTime;
                }

                if (__instance.refHub.inventory.curItem == ItemType.MicroHID || __instance.chargeup > 0f)
                {
                    if (__instance.CurrentHidState != MicroHID.MicroHidState.Idle)
                    {
                        __instance.refHub.weaponManager.scp268.ServerDisable();
                        __instance._visionController.MakeNoise(__instance.CurrentHidState == MicroHID.MicroHidState.Discharge ? 20 : 75);
                    }

                    MicroHID.MicroHidState state = MicroHID.MicroHidState.Idle;

                    if (__instance.refHub.inventory.curItem == ItemType.MicroHID)
                    {
                        if (__instance.Energy > 0f && __instance.chargeup >= 1f && __instance.SyncKeyCode == 2)
                        {
                            state = MicroHID.MicroHidState.Discharge;
                        }
                        else if (__instance.Energy > 0f && __instance.chargeup < 1f && __instance.SyncKeyCode != 0 && __instance.CurrentHidState != MicroHID.MicroHidState.RampDown)
                        {
                            state = MicroHID.MicroHidState.RampUp;
                        }
                        else if (__instance.chargeup > 0f && (__instance.SyncKeyCode == 0 || __instance.Energy <= 0f || __instance.CurrentHidState == MicroHID.MicroHidState.RampDown))
                        {
                            state = MicroHID.MicroHidState.RampDown;
                        }
                        else if (__instance.chargeup <= 0f && (__instance.SyncKeyCode == 0 || __instance.Energy <= 0f || __instance.CurrentHidState == MicroHID.MicroHidState.RampDown))
                        {
                            state = MicroHID.MicroHidState.Idle;
                        }
                        else if (__instance.chargeup >= 1f)
                        {
                            state = MicroHID.MicroHidState.Spinning;
                        }
                    }
                    else
                    {
                        state = MicroHID.MicroHidState.RampDown;
                    }

                    var player = __instance.refHub.GetPlayer();
                    var item   = player.ItemInHand;

                    SynapseController.Server.Events.Player.InvokeMicroUse(player, item, ref state);
                    //ItemUseEvent Invoke
                    if (state != MicroHID.MicroHidState.Idle)
                    {
                        var itemstate = ItemState.Initiating;
                        switch (state)
                        {
                        case MicroHID.MicroHidState.Spinning:
                        case MicroHID.MicroHidState.Discharge:
                            itemstate = ItemState.Finalizing;
                            break;

                        case MicroHID.MicroHidState.RampUp:
                            itemstate = ItemState.Initiating;
                            break;

                        case MicroHID.MicroHidState.RampDown:
                            itemstate = ItemState.Stopping;
                            break;
                        }
                        var allow = true;
                        SynapseController.Server.Events.Player.InvokePlayerItemUseEvent(player, item, itemstate, ref allow);
                        if (!allow)
                        {
                            state = MicroHID.MicroHidState.Idle;
                        }
                    }

                    switch (state)
                    {
                    case MicroHID.MicroHidState.Discharge:
                        if (__instance.soundEffectPause >= 1f)
                        {
                            __instance.NetworkEnergy = Mathf.Clamp01(__instance.Energy - Time.deltaTime * __instance.dischargeEnergyLoss);
                            __instance.DealDamage();
                        }
                        else
                        {
                            __instance.NetworkEnergy = Mathf.Clamp01(__instance.Energy - Time.deltaTime * __instance.speedBasedEnergyLoss.Evaluate(1f));
                        }
                        break;

                    case MicroHID.MicroHidState.RampUp:
                        __instance.chargeup      = Mathf.Clamp01(__instance.chargeup + Time.deltaTime / __instance.chargeupTime);
                        __instance.NetworkEnergy = Mathf.Clamp01(__instance.Energy - Time.deltaTime * __instance.speedBasedEnergyLoss.Evaluate(__instance.chargeup));
                        break;

                    case MicroHID.MicroHidState.RampDown:
                        __instance.chargeup = Mathf.Clamp01(__instance.chargeup - Time.deltaTime / __instance.chargedownTime);
                        break;

                    case MicroHID.MicroHidState.Spinning:
                        __instance.NetworkEnergy = Mathf.Clamp01(__instance.Energy - Time.deltaTime * __instance.speedBasedEnergyLoss.Evaluate(__instance.chargeup));
                        break;

                        //Idle does nothing
                    }

                    __instance.NetworkCurrentHidState = state;
                }

                if (__instance.Energy <= 0.05f)
                {
                    __instance.NetworkEnergy = 0f;
                }

                return(false);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: PlayerUseMicro failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }