protected void FireChild(Vector3 direction) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.childrenProjectilePrefab, base.transform.position, Util.QuaternionSafeLookRotation(direction)); ProjectileController component = gameObject.GetComponent <ProjectileController>(); if (component) { component.procChainMask = this.projectileController.procChainMask; component.procCoefficient = this.projectileController.procCoefficient; component.Networkowner = this.projectileController.owner; } gameObject.GetComponent <TeamFilter>().teamIndex = base.GetComponent <TeamFilter>().teamIndex; ProjectileDamage component2 = gameObject.GetComponent <ProjectileDamage>(); if (component2) { component2.damage = this.projectileDamage.damage * this.childrenDamageCoefficient; component2.crit = this.projectileDamage.crit; component2.force = this.projectileDamage.force; component2.damageColorIndex = this.projectileDamage.damageColorIndex; } if (gameObject.GetComponent <ProjectileStickOnImpact>() != null) { ProjectileStickOnImpact stickComponent = gameObject.GetComponent <ProjectileStickOnImpact>(); stickComponent.TrySticking(hitEnemyCollider, hitEnemyInfo.estimatedImpactNormal); } NetworkServer.Spawn(gameObject); }
private static bool IsMineStuck(WaitForStick waitForStick) { ProjectileStickOnImpact projectileStickOnImpact = (ProjectileStickOnImpact)typeof(WaitForStick) .GetProperty("projectileStickOnImpact", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(waitForStick); return(projectileStickOnImpact && projectileStickOnImpact.stuck); }
public void Awake() { this.stickOnImpact = base.GetComponent <ProjectileStickOnImpact>(); this.projectileController = base.GetComponent <ProjectileController>(); this.projectileDamage = base.GetComponent <ProjectileDamage>(); this.singleTargetImpact = base.GetComponent <ProjectileSingleTargetImpact>(); this.stickOnImpact.stickEvent.AddListener(this.OnStickEvent); }
//Adds nano beacon to the projectile register list internal static void RegisterNanoBeacon() { //Nab the projectile that's usually used for MUL-T scrap launcher nanoBeaconPrefab = LegacyResourcesAPI.Load <GameObject>("prefabs/projectiles/toolbotgrenadelauncherprojectile").InstantiateClone("NanoBeacon", true); //Ofc check if it actually exists if (nanoBeaconPrefab) { //Make it move at our own speed of choice nanoBeaconPrefab.GetComponent <ProjectileSimple>().desiredForwardSpeed = 140f; //Make it so it won't kersplode itself on impact ProjectileSingleTargetImpact nanoBeaconSingle = nanoBeaconPrefab.AddComponent <ProjectileSingleTargetImpact>(); nanoBeaconSingle.destroyWhenNotAlive = false; nanoBeaconSingle.destroyOnWorld = false; //This timed buff only applies on direct hit with nano beacon ProjectileInflictTimedBuff nanoDebuff = nanoBeaconPrefab.AddComponent <ProjectileInflictTimedBuff>(); nanoDebuff.buffDef = BuffsLoading.buffDefTracking; //Tracking lasts for 5 seconds from this nanoDebuff.duration = 5f; //We do in fact want it to stick on impact ProjectileStickOnImpact nanoBeaconStick = nanoBeaconPrefab.AddComponent <ProjectileStickOnImpact>(); //This makes it so it doesn't pass through anything nanoBeaconStick.ignoreCharacters = false; nanoBeaconStick.ignoreWorld = false; //If we enable this the beacon sticks at gross angles, it feels more natural this way nanoBeaconStick.alignNormals = false; //This handles the 'explosion' of the beacon, we are changing it a lot ProjectileImpactExplosion nanoBeaconExplosion = nanoBeaconPrefab.GetComponent <ProjectileImpactExplosion>(); //No more self-destruction nanoBeaconExplosion.destroyOnEnemy = false; nanoBeaconExplosion.destroyOnWorld = false; //No more blast radius nanoBeaconExplosion.blastRadius = 0f; //Live 'forever' or until our code says we want it to vanish nanoBeaconExplosion.lifetime = 100f; //Which is here, it should die 3.5 seconds after impact nanoBeaconExplosion.lifetimeAfterImpact = 3.5f; //No damage for the blast nanoBeaconExplosion.blastDamageCoefficient = 0f; //No blast force nanoBeaconExplosion.bonusBlastForce = Vector3.zero; //Basically no blast, so no falloffmodel either nanoBeaconExplosion.falloffModel = BlastAttack.FalloffModel.None; //This is our component that 'talks' to the MUL-T player's swarm component nanoBeaconPrefab.AddComponent <OnStuckCaller>(); //Add it to the list projList.Add(nanoBeaconPrefab); } }
private void Start() { //Start countdown this.countDown = this.baseCountDown; //Prep stopwatch this.stopwatch = this.stopwatchMax; //Grab components and owner this.owner = GetComponent <ProjectileController>().owner; this.stick = GetComponent <ProjectileStickOnImpact>(); this.controller = GetComponent <ProjectileController>(); //Establish indicator this.indicator = Object.Instantiate(ArrowRain.areaIndicatorPrefab); this.indicator.SetActive(true); this.indicator.transform.position = base.transform.position; this.indicator.transform.localScale = Vector3.zero; }
private static GameObject CreateKnifeProjectile() { GameObject obj = PrefabsCore.CreatePrefab("KnifeProjectile", true); obj.layer = LayerIndex.projectile.intVal; _ = obj.AddOrGetComponent <NetworkIdentity>(); _ = obj.AddOrGetComponent <TeamFilter>(); ProjectileController projControl = obj.AddOrGetComponent <ProjectileController>(); projControl.allowPrediction = false; projControl.catalogIndex = -1; projControl.ghostPrefab = null; // FUTURE: Knife projectile ghost projControl.ghostTransformAnchor = null; projControl.owner = null; projControl.procCoefficient = 1f; projControl.startSound = null; // FUTURE: Knife start sound Rigidbody rb = obj.AddOrGetComponent <Rigidbody>(); rb.mass = 1f; rb.drag = 0.6f; rb.angularDrag = 0.05f; rb.useGravity = true; rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; rb.collisionDetectionMode = CollisionDetectionMode.Continuous; ProjectileNetworkTransform projNetTrans = obj.AddOrGetComponent <ProjectileNetworkTransform>(); projNetTrans.positionTransmitInterval = 0.033333334f; projNetTrans.interpolationFactor = 1f; projNetTrans.allowClientsideCollision = false; ProjectileStickOnImpact projStick = obj.AddOrGetComponent <ProjectileStickOnImpact>(); projStick.alignNormals = false; projStick.ignoreCharacters = false; projStick.ignoreWorld = false; projStick.stickEvent = new UnityEngine.Events.UnityEvent(); ProjectileSingleTargetImpact projImpact = obj.AddOrGetComponent <ProjectileSingleTargetImpact>(); projImpact.destroyOnWorld = false; projImpact.destroyWhenNotAlive = false; projImpact.enemyHitSoundString = null; // FUTURE: Knife hit sound projImpact.hitSoundString = null; // FUTURE: Knife world hit sound projImpact.impactEffect = null; // FUTURE: Knife impact effect ProjectileSimple projSimple = obj.AddOrGetComponent <ProjectileSimple>(); projSimple.enableVelocityOverLifetime = false; projSimple.lifetime = 18f; projSimple.updateAfterFiring = false; projSimple.velocity = 175f; projSimple.velocityOverLifetime = null; SphereCollider col = obj.AddOrGetComponent <SphereCollider>(); col.center = Vector3.zero; col.contactOffset = 0f; col.isTrigger = false; col.material = null; col.radius = 0.3f; ProjectileDamage damage = obj.AddOrGetComponent <ProjectileDamage>(); damage.crit = false; damage.damage = 0f; damage.damageColorIndex = DamageColorIndex.Default; damage.force = 0f; var debuff = obj.AddOrGetComponent <ProjectileInflictTimedBuff>(); debuff.duration = CatalogModule.resetDuration * 2f; _ = obj.AddOrGetComponent <Deployable>(); _ = obj.AddOrGetComponent <KnifeDeployableSync>(); SphereCollider ownerDetection = obj.AddComponent <SphereCollider>(); ownerDetection.isTrigger = true; ownerDetection.radius = 10f; foreach (IRuntimePrefabComponent runtimePrefabComp in obj.GetComponents <IRuntimePrefabComponent>()) { runtimePrefabComp.InitializePrefab(); } return(obj); }
private void CreateLightningSword(Int32 meshInd) { GameObject ghost = this.CreateLightningSwordGhost(meshInd); GameObject proj = Resources.Load <GameObject>("Prefabs/Projectiles/LunarNeedleProjectile").InstantiateClone("LightningSwordProjectile" + meshInd.ToString()); ProjectileCatalog.getAdditionalEntries += (list) => list.Add(proj); AltArtiPassive.lightningProjectile[meshInd] = proj; ProjectileController projController = proj.GetComponent <ProjectileController>(); projController.ghostPrefab = ghost; projController.procCoefficient = 0.2f; ProjectileSimple projSimple = proj.GetComponent <ProjectileSimple>(); projSimple.enabled = true; projSimple.enableVelocityOverLifetime = false; projSimple.velocity = 60f; ProjectileDirectionalTargetFinder projTargetFind = proj.GetComponent <ProjectileDirectionalTargetFinder>(); projTargetFind.enabled = false; ProjectileSteerTowardTarget projSteering = proj.GetComponent <ProjectileSteerTowardTarget>(); projSteering.enabled = true; projSteering.rotationSpeed = 140f; ProjectileStickOnImpact projStick = proj.GetComponent <ProjectileStickOnImpact>(); //projStick.ignoreCharacters = false; //projStick.ignoreWorld = false; projStick.alignNormals = false; ProjectileImpactExplosion projExpl = proj.GetComponent <ProjectileImpactExplosion>(); projExpl.impactEffect = Resources.Load <GameObject>("Prefabs/Effects/LightningStakeNova"); projExpl.explosionSoundString = "Play_item_lunar_primaryReplace_impact"; projExpl.lifetimeExpiredSoundString = ""; projExpl.offsetForLifetimeExpiredSound = 0f; projExpl.destroyOnEnemy = false; projExpl.destroyOnWorld = false; projExpl.timerAfterImpact = true; projExpl.falloffModel = BlastAttack.FalloffModel.None; projExpl.lifetime = 10f; projExpl.lifetimeAfterImpact = 1f; projExpl.lifetimeRandomOffset = 0f; projExpl.blastRadius = 1f; projExpl.blastDamageCoefficient = 1f; projExpl.blastProcCoefficient = 0.2f; projExpl.bonusBlastForce = Vector3.zero; projExpl.fireChildren = false; projExpl.childrenProjectilePrefab = null; projExpl.childrenCount = 0; projExpl.childrenDamageCoefficient = 0f; projExpl.minAngleOffset = Vector3.zero; projExpl.maxAngleOffset = Vector3.zero; projExpl.transformSpace = ProjectileImpactExplosion.TransformSpace.World; projExpl.projectileHealthComponent = null; ProjectileSingleTargetImpact projStimp = proj.GetComponent <ProjectileSingleTargetImpact>(); projStimp.destroyOnWorld = false; projStimp.hitSoundString = "Play_item_proc_dagger_impact"; projStimp.enemyHitSoundString = "Play_item_proc_dagger_impact"; proj.AddComponent <Components.SoundOnAwake>().sound = "Play_item_proc_dagger_spawn"; //UnityEngine.Object.DestroyImmediate( proj.GetComponent<ProjectileSingleTargetImpact>() ); UnityEngine.Object.Destroy(proj.GetComponent <AwakeEvent>()); UnityEngine.Object.Destroy(proj.GetComponent <DelayedEvent>()); }