Ejemplo n.º 1
0
        public static void Postfix(LaserEffect __instance, ref Color[] ___laserColor, ref BTLight ___laserLight, ref LineRenderer ___beamRenderer)
        {
            try
            {
                Weapon weapon = __instance.weapon;
                if (weapon.weaponDef.Description.Id == Fields.StreakTargetingLaserId)
                {
                    Logger.Debug($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) lightIntensity: {__instance.lightIntensity}");
                    Logger.Debug($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) lightRadius: {__instance.lightRadius}");
                    Logger.Debug($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) pulseDelay: {__instance.pulseDelay}");

                    Logger.Debug($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) __beamRenderer: {___beamRenderer.startColor}, {___beamRenderer.endColor}, {___beamRenderer.startWidth}, {___beamRenderer.endWidth}");

                    Logger.Debug($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) ___laserLight.lightColor: {___laserLight.lightColor}");

                    Vector4 tempColor   = (Vector4)AccessTools.Field(typeof(BTLight), "tempColor").GetValue(___laserLight);
                    Vector4 linearColor = (Vector4)AccessTools.Field(typeof(BTLight), "linearColor").GetValue(___laserLight);
                    Logger.Info($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) ___laserLight.tempColor: {tempColor}");
                    Logger.Info($"[LaserEffect_SetupLaser_POSTFIX] ({weapon.parent.DisplayName}) ___laserLight.linearColor: {linearColor}");
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Ejemplo n.º 2
0
 static void Postfix(ref int ___hitIndex, LaserEffect __instance)
 {
     if (___hitIndex >= __instance.hitInfo.numberOfShots - 1)
     {
         return;
     }
     ___hitIndex++;
     __instance.Fire(__instance.hitInfo, ___hitIndex);
 }
Ejemplo n.º 3
0
        public static void Prefix(LaserEffect __instance, ref Color[] ___laserColor, ref BTLight ___laserLight, ref LineRenderer ___beamRenderer)
        {
            try
            {
                Weapon weapon = __instance.weapon;
                if (weapon.weaponDef.Description.Id == Fields.StreakTargetingLaserId)
                {
                    Logger.Debug($"[LaserEffect_SetupLaser_PREFIX] ({weapon.parent.DisplayName}) lightIntensity: {__instance.lightIntensity}");
                    Logger.Debug($"[LaserEffect_SetupLaser_PREFIX] ({weapon.parent.DisplayName}) lightRadius: {__instance.lightRadius}");
                    Logger.Debug($"[LaserEffect_SetupLaser_PREFIX] ({weapon.parent.DisplayName}) pulseDelay: {__instance.pulseDelay}");

                    __instance.lightIntensity = 300000f; // Default: 3500000f (SmallLaserPulse: 50000)
                    //__instance.lightRadius = 120; // Default: 100 (SmallLaserPulse: 60)
                    //__instance.pulseDelay = 0.2f; // Default: ? (SmallLaserPulse: -1)

                    Color overrideColor = Fields.TargetingLaserColor;

                    ___beamRenderer = __instance.projectile.GetComponent <LineRenderer>();
                    Logger.Debug($"[LaserEffect_SetupLaser_PREFIX] ({weapon.parent.DisplayName}) __beamRenderer: {___beamRenderer.startColor}, {___beamRenderer.endColor}, {___beamRenderer.startWidth}, {___beamRenderer.endWidth}");
                    ___beamRenderer.startColor = overrideColor;
                    ___beamRenderer.endColor   = overrideColor;

                    ___beamRenderer.startWidth = 1.9f;
                    ___beamRenderer.endWidth   = 2.5f;

                    Logger.Debug($"[LaserEffect_SetupLaser_PREFIX] ({weapon.parent.DisplayName}) __beamRenderer: {___beamRenderer.startColor}, {___beamRenderer.endColor}, {___beamRenderer.startWidth}, {___beamRenderer.endWidth}");

                    // Used by LaserEffect.Update() for ___beamRenderer too;
                    ___laserColor[0] = overrideColor;
                    ___laserColor[1] = overrideColor;

                    ___laserLight            = ___beamRenderer.GetComponentInChildren <BTLight>(true);
                    ___laserLight.lightColor = overrideColor;
                    Logger.Debug($"[LaserEffect_SetupLaser_PREFIX] ({weapon.parent.DisplayName}) ___laserLight.lightColor: {___laserLight.lightColor}");

                    // Called in original method, not necessary here...
                    //___laserLight.RefreshLightSettings(true);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Ejemplo n.º 4
0
 static void Postfix(LaserEffect __instance)
 {
     Logger.Debug($"PlayImpact laser effect id: {__instance.GetInstanceID()}");
 }
Ejemplo n.º 5
0
 static void Postfix(float hitDamage, LaserEffect __instance)
 {
     Logger.Debug($"OnImpact laser effect id: {__instance.GetInstanceID()}");
 }
Ejemplo n.º 6
0
    private void SetupLaserEffects(GameObject prefab)
    {
        GameObject gameObject = new GameObject("LaserEffect");

        gameObject.transform.parent = prefab.transform;
        KBatchedAnimEventToggler kBatchedAnimEventToggler = gameObject.AddComponent <KBatchedAnimEventToggler>();

        kBatchedAnimEventToggler.eventSource  = prefab;
        kBatchedAnimEventToggler.enableEvent  = "LaserOn";
        kBatchedAnimEventToggler.disableEvent = "LaserOff";
        kBatchedAnimEventToggler.entries      = new List <KBatchedAnimEventToggler.Entry>();
        LaserEffect[] array = new LaserEffect[13]
        {
            new LaserEffect
            {
                id       = "DigEffect",
                animFile = "laser_kanim",
                anim     = "idle",
                context  = (HashedString)"dig"
            },
            new LaserEffect
            {
                id       = "BuildEffect",
                animFile = "construct_beam_kanim",
                anim     = "loop",
                context  = (HashedString)"build"
            },
            new LaserEffect
            {
                id       = "FetchLiquidEffect",
                animFile = "hose_fx_kanim",
                anim     = "loop",
                context  = (HashedString)"fetchliquid"
            },
            new LaserEffect
            {
                id       = "PaintEffect",
                animFile = "paint_beam_kanim",
                anim     = "loop",
                context  = (HashedString)"paint"
            },
            new LaserEffect
            {
                id       = "HarvestEffect",
                animFile = "plant_harvest_beam_kanim",
                anim     = "loop",
                context  = (HashedString)"harvest"
            },
            new LaserEffect
            {
                id       = "CaptureEffect",
                animFile = "net_gun_fx_kanim",
                anim     = "loop",
                context  = (HashedString)"capture"
            },
            new LaserEffect
            {
                id       = "AttackEffect",
                animFile = "attack_beam_fx_kanim",
                anim     = "loop",
                context  = (HashedString)"attack"
            },
            new LaserEffect
            {
                id       = "PickupEffect",
                animFile = "vacuum_fx_kanim",
                anim     = "loop",
                context  = (HashedString)"pickup"
            },
            new LaserEffect
            {
                id       = "StoreEffect",
                animFile = "vacuum_reverse_fx_kanim",
                anim     = "loop",
                context  = (HashedString)"store"
            },
            new LaserEffect
            {
                id       = "DisinfectEffect",
                animFile = "plant_spray_beam_kanim",
                anim     = "loop",
                context  = (HashedString)"disinfect"
            },
            new LaserEffect
            {
                id       = "TendEffect",
                animFile = "plant_tending_beam_fx_kanim",
                anim     = "loop",
                context  = (HashedString)"tend"
            },
            new LaserEffect
            {
                id       = "PowerTinkerEffect",
                animFile = "electrician_beam_fx_kanim",
                anim     = "idle",
                context  = (HashedString)"powertinker"
            },
            new LaserEffect
            {
                id       = "SpecialistDigEffect",
                animFile = "senior_miner_beam_fx_kanim",
                anim     = "idle",
                context  = (HashedString)"specialistdig"
            }
        };
        KBatchedAnimController component = prefab.GetComponent <KBatchedAnimController>();

        LaserEffect[] array2 = array;
        for (int i = 0; i < array2.Length; i++)
        {
            LaserEffect laserEffect = array2[i];
            GameObject  gameObject2 = new GameObject(laserEffect.id);
            gameObject2.transform.parent = gameObject.transform;
            KPrefabID kPrefabID = gameObject2.AddOrGet <KPrefabID>();
            kPrefabID.PrefabTag = new Tag(laserEffect.id);
            KBatchedAnimTracker kBatchedAnimTracker = gameObject2.AddOrGet <KBatchedAnimTracker>();
            kBatchedAnimTracker.controller     = component;
            kBatchedAnimTracker.symbol         = new HashedString("snapTo_rgtHand");
            kBatchedAnimTracker.offset         = new Vector3(195f, -35f, 0f);
            kBatchedAnimTracker.useTargetPoint = true;
            KBatchedAnimController kBatchedAnimController = gameObject2.AddOrGet <KBatchedAnimController>();
            kBatchedAnimController.AnimFiles = new KAnimFile[1]
            {
                Assets.GetAnim(laserEffect.animFile)
            };
            KBatchedAnimEventToggler.Entry entry = default(KBatchedAnimEventToggler.Entry);
            entry.anim       = laserEffect.anim;
            entry.context    = laserEffect.context;
            entry.controller = kBatchedAnimController;
            KBatchedAnimEventToggler.Entry item = entry;
            kBatchedAnimEventToggler.entries.Add(item);
            gameObject2.AddOrGet <LoopingSounds>();
        }
    }