예제 #1
0
        public static bool Prefix(WeaponEffect __instance, string ___activeProjectileName)
        {
            try
            {
                if (__instance.weapon.weaponDef.Description.Id == Fields.StreakTargetingLaserId)
                {
                    Logger.Debug($"[WeaponEffect_OnComplete_PREFIX] ({__instance.weapon.parent.DisplayName}) Supressing message for Weapon: {__instance.weapon.weaponDef.Description.Id} (WeaponEffect: {__instance.name})");

                    if (__instance.currentState == WeaponEffect.WeaponEffectState.Complete)
                    {
                        return(false);
                    }
                    __instance.currentState = WeaponEffect.WeaponEffectState.Complete;

                    /* This is to be prevented...
                     * if (!__instance.subEffect)
                     * {
                     *  AttackSequenceResolveDamageMessage message = new AttackSequenceResolveDamageMessage(__instance.hitInfo);
                     *  __instance.Combat.MessageCenter.PublishMessage(message);
                     * }
                     * __instance.PublishNextWeaponMessage();
                     * __instance.PublishWeaponCompleteMessage();
                     */

                    if (__instance.projectilePrefab != null)
                    {
                        AutoPoolObject autoPoolObject = __instance.projectile.GetComponent <AutoPoolObject>();
                        if (autoPoolObject == null)
                        {
                            autoPoolObject = __instance.projectile.AddComponent <AutoPoolObject>();
                        }
                        autoPoolObject.Init(__instance.weapon.parent.Combat.DataManager, ___activeProjectileName, 4f);
                        __instance.projectile = null;
                    }

                    return(false);
                }
                return(true);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(true);
            }
        }
예제 #2
0
        public static ParticleSystem PlayVFXAt(GameRepresentation gameRep, Transform parentTransform, Vector3 offset, string vfxName, string effectName,
                                               bool attached, Vector3 lookAtPos, bool oneShot, float duration)
        {
            if (string.IsNullOrEmpty(vfxName))
            {
                return(null);
            }

            GameObject gameObject = gameRep.parentCombatant.Combat.DataManager.PooledInstantiate(vfxName, BattleTechResourceType.Prefab, null, null, null);

            if (gameObject == null)
            {
                GameRepresentation.initLogger.LogError("Error instantiating VFX " + vfxName, gameRep);
                return(null);
            }
            ParticleSystem component = gameObject.GetComponent <ParticleSystem>();

            component.Stop(true);
            component.Clear(true);
            Transform transform = gameObject.transform;

            transform.SetParent(null);

            BTWindZone componentInChildren = gameObject.GetComponentInChildren <BTWindZone>(true);

            if (componentInChildren != null && componentInChildren.enabled)
            {
                componentInChildren.ResetZero();
            }

            BTLightAnimator componentInChildren2 = gameObject.GetComponentInChildren <BTLightAnimator>(true);

            if (attached)
            {
                transform.SetParent(parentTransform, false);
                transform.localPosition = offset;
            }
            else
            {
                transform.localPosition = Vector3.zero;
                if (parentTransform != null)
                {
                    transform.position = parentTransform.position;
                }
                transform.position += offset;
            }

            if (lookAtPos != Vector3.zero)
            {
                transform.LookAt(lookAtPos);
            }
            else
            {
                transform.localRotation = Quaternion.identity;
            }
            transform.localScale = Vector3.one;

            if (oneShot)
            {
                AutoPoolObject autoPoolObject = gameObject.GetComponent <AutoPoolObject>();
                if (autoPoolObject == null)
                {
                    autoPoolObject = gameObject.AddComponent <AutoPoolObject>();
                }
                if (duration > 0f)
                {
                    autoPoolObject.Init(gameRep.parentCombatant.Combat.DataManager, vfxName, duration);
                }
                else
                {
                    autoPoolObject.Init(gameRep.parentCombatant.Combat.DataManager, vfxName, component);
                }
            }
            else
            {
                List <ParticleSystem> list = null;
                if (gameRep.persistentVFXParticles.TryGetValue(effectName, out list))
                {
                    list.Add(component);
                    gameRep.persistentVFXParticles[effectName] = list;
                }
                else
                {
                    list = new List <ParticleSystem>();
                    list.Add(component);
                    gameRep.persistentVFXParticles[effectName] = list;
                }
            }

            BTCustomRenderer.SetVFXMultiplier(component);
            component.Play(true);
            if (componentInChildren != null)
            {
                componentInChildren.PlayAnimCurve();
            }
            if (componentInChildren2 != null)
            {
                componentInChildren2.PlayAnimation();
            }

            return(component);
        }