private void AW_UtilityProjGhost() { var obj = PrefabsCore.CreatePrefab("PrimaryProjGhost", false); var ghostControl = obj.AddComponent <ProjectileGhostController>(); var skinner = obj.AddComponent <WispSkinnedEffect>(); var sound = obj.AddComponent <StartEndSound>(); sound.startSound = "Play_lemurianBruiser_m1_fly_loop"; sound.endSound = "Stop_lemurianBruiser_m1_fly_loop"; sound.mult = 2; //Play_greater_wisp_active_loop //Stop_greater_wisp_active_loop if (!this.AW_lowPerf.Value) { var light = EffectHelper.AddLight(obj, skinner, true, 8f, 4f); } //var trail1 = EffectHelper.AddTrail( obj, skinner, MaterialType.Tracer, 0.5f, 1f, 0f, 0.5f, false ); //var trail2 = EffectHelper.AddTrail( obj, skinner, MaterialType.Tracer, 0.5f, 1f, 0f, 0.5f, false ); //var rotator = EffectHelper.AddRotator( obj, new Vector3( 0f, 0f, 360f ), Vector3.forward, 1f, trail1.transform, trail2.transform ); var flame = EffectHelper.AddFire(obj, skinner, MaterialType.Flames, 10f, 0.3f, 5f, 1f, 0f, true); AW_utilityProjGhost = obj; }
private void AW_UtilityChargeEffect() { var obj = PrefabsCore.CreatePrefab("UtilityChargeEffect", false); var skinner = obj.AddComponent <WispSkinnedEffect>(); if (!this.AW_lowPerf.Value) { var light = EffectHelper.AddLight(obj, skinner, true, 4f, 2f); } var chargeLines = EffectHelper.AddChargeSphereLines(obj, skinner, MaterialType.Tracer, 0.75f, 0.15f, 0.05f, 30f); var arcCircle = EffectHelper.AddArcaneCircle(obj, skinner, MaterialType.ArcaneCircle, 5f, 2f); var arcMain = arcCircle.main; arcMain.simulationSpace = ParticleSystemSimulationSpace.Local; arcMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform; var arcEmis = arcCircle.emission; arcEmis.burstCount = 1; arcEmis.SetBurst(0, new ParticleSystem.Burst(0f, 1f, 1, 0.01f)); var arcShape = arcCircle.shape; arcShape.enabled = false; var arcCOL = arcCircle.colorOverLifetime; arcCOL.enabled = true; arcCOL.color = new ParticleSystem.MinMaxGradient(new Gradient { mode = GradientMode.Blend, alphaKeys = new[] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 1f), }, colorKeys = new[] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 0f), }, }); var arcSOL = arcCircle.sizeOverLifetime; arcSOL.enabled = true; arcSOL.separateAxes = false; arcSOL.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0f)); var arcROL = arcCircle.rotationOverLifetime; arcROL.enabled = true; arcROL.z = 2f; AW_utilityChargeEffect = obj; }
private void Main_Load3() { var master = PrefabsCore.CreatePrefab("RogueWispMonsterMaster", true); var netID = master.AddOrGetComponent <NetworkIdentity>(); var charMaster = master.AddComponent <CharacterMaster>(); charMaster.masterIndex = (MasterCatalog.MasterIndex)(-1); charMaster.bodyPrefab = this.RW_body; charMaster.spawnOnStart = false; charMaster.teamIndex = TeamIndex.Monster; charMaster.destroyOnBodyDeath = true; charMaster.isBoss = false; charMaster.preventGameOver = true; var inv = master.AddComponent <Inventory>(); var ai = master.AddComponent <BaseAI>(); ai.fullVision = true; ai.neverRetaliateFriendlies = false; ai.minDistanceFromEnemy = 8f; ai.enemyAttention = 5f; ai.navigationType = BaseAI.NavigationType.Nodegraph; ai.desiredSpawnNodeGraphType = RoR2.Navigation.MapNodeGroup.GraphType.Ground; var esm = ai.stateMachine = master.AddComponent <EntityStateMachine>(); ai.scanState = new EntityStates.SerializableEntityStateType(typeof(EntityStates.AI.Walker.Wander)); ai.isHealer = false; ai.enemyAttention = 0f; ai.aimVectorDampTime = 0.1f; ai.aimVectorMaxSpeed = 360f; ai.desiredAimDirection = new Vector3(0f, 0f, 1f); ai.drawAIPath = false; ai.selectedSkilldriverName = null; ai.debugEnemyHurtBox = null; ai.currentEnemy = null; ai.leader = null; ai.customTarget = null; esm.customName = "AI"; esm.initialStateType = new EntityStates.SerializableEntityStateType(typeof(EntityStates.AI.Walker.Wander)); esm.mainStateType = new EntityStates.SerializableEntityStateType(typeof(EntityStates.AI.Walker.Wander)); var minionOwn = master.AddOrGetComponent <MinionOwnership>(); this.AddDrivers(master); var wispyManager = master.AddComponent <WispyAIManager>(); this.RW_master = master; MasterCatalog.getAdditionalEntries += (list) => list.Add(this.RW_master); }
internal static GameObject CreateRicochetEffect() { GameObject obj = PrefabsCore.CreatePrefab( "SniperRicochetEffect", false ); var effectComp = obj.AddComponent<EffectComponent>(); var vfxAtrib = obj.AddComponent<VFXAttributes>(); obj.AddComponent<RicochetEffectController>().destroyDelay = 2f; EffectsCore.AddEffect( obj ); return obj; }
private void AW_PrimaryProjGhost() { var obj = PrefabsCore.CreatePrefab("PrimaryProjGhost", false); var ghostControl = obj.AddComponent <ProjectileGhostController>(); var skinner = obj.AddComponent <WispSkinnedEffect>(); if (!this.AW_lowPerf.Value) { var light = EffectHelper.AddLight(obj, skinner, true, 8f, 4f); } var trail1 = EffectHelper.AddTrail(obj, skinner, MaterialType.Tracer, 0.5f, 1f, 0f, 0.5f, false); var trail2 = EffectHelper.AddTrail(obj, skinner, MaterialType.Tracer, 0.5f, 1f, 0f, 0.5f, false); var rotator = EffectHelper.AddRotator(obj, new Vector3(0f, 0f, 360f), Vector3.forward, 1f, trail1.transform, trail2.transform); var flame = EffectHelper.AddFire(obj, skinner, MaterialType.Flames, 4f, 0.3f, 5f, 1f, 0f, true); AW_primaryProjGhost = obj; }
private void AW_UtilityOrbEffect() { var obj = PrefabsCore.CreatePrefab("LeechOrb", false); var effComp = obj.AddComponent <EffectComponent>(); effComp.positionAtReferencedTransform = false; effComp.parentToReferencedTransform = false; effComp.applyScale = true; effComp.soundName = "Play_gravekeeper_attack1_fire"; var skin = obj.AddComponent <WispSkinnedEffect>(); var vfxAtrib = obj.AddComponent <VFXAttributes>(); vfxAtrib.vfxPriority = VFXAttributes.VFXPriority.Always; vfxAtrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; var eventFuncs = obj.AddComponent <EventFunctions>(); var orb = obj.AddComponent <WispOrbEffect>(); orb.startVelocity1 = new Vector3(-10f, 10f, -10f); orb.startVelocity2 = new Vector3(10f, 0f, 10f); orb.endVelocity1 = new Vector3(-4f, 0f, -4f); orb.endVelocity2 = new Vector3(4f, 0f, 10f); orb.movementCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); orb.faceMovement = true; orb.callArrivalIfTargetIsGone = false; orb.soundString = "Play_treeBot_m1_hit_heal"; var fireParticles = EffectHelper.AddFire(obj, skin, MaterialType.Flames, 2f, 0.3f, 20f, 10f, 0f, true); AW_utilityOrbEffect = obj; RegisterEffect(AW_utilityOrbEffect); }
private void AW_UtilityZoneGhost() { var obj = PrefabsCore.CreatePrefab("PrimaryProjGhost", false); var sound = obj.AddComponent <StartEndSound>(); sound.startSound = "Play_lemurianBruiser_m2_loop"; sound.endSound = "Stop_lemurianBruiser_m2_loop"; sound.mult = 5; //sound.startSound = "Play_magmaWorm_idle_burn_loop"; //sound.endSound = "Stop_magmaWorm_idle_burn_loop"; var ghostControl = obj.AddComponent <ProjectileGhostController>(); var skinner = obj.AddComponent <WispSkinnedEffect>(); var vecScale = obj.AddComponent <EffectVectorScale>(); vecScale.scaleOverTime = true; vecScale.durationFrac = 1f; vecScale.duration = 10f; vecScale.startScale = new Vector3(1f, 1f, 1f); vecScale.endScale = new Vector3(150f, 150f, 150f); vecScale.useEffectComponent = false; //var light = EffectHelper.AddLight( obj, skinner, true, 8f, 4f ); //var trail1 = EffectHelper.AddTrail( obj, skinner, MaterialType.Tracer, 0.5f, 1f, 0f, 0.5f, false ); //var trail2 = EffectHelper.AddTrail( obj, skinner, MaterialType.Tracer, 0.5f, 1f, 0f, 0.5f, false ); //var rotator = EffectHelper.AddRotator( obj, new Vector3( 0f, 0f, 360f ), Vector3.forward, 1f, trail1.transform, trail2.transform ); //var flame = EffectHelper.AddFire( obj, skinner, MaterialType.Flames, 10f, 0.3f, 5f, 1f, 0f, true ); //var tornado = EffectHelper.AddFlameTornado( obj, skinner, MaterialType.FlameTornado, 1f , 10f, 10f, 5f ); var indicator = EffectHelper.AddMeshIndicator(obj, skinner, MaterialType.BossAreaExplosion, MeshIndex.Sphere, false); AW_utilityZoneGhost = obj; }
private void AW_CreateUtilityZoneProjectile() { var obj = PrefabsCore.CreatePrefab("AWPrimaryProjectile", true); obj.layer = LayerIndex.projectile.intVal; var netID = obj.GetComponent <NetworkIdentity>(); netID.localPlayerAuthority = true; netID.serverOnly = false; var projControl = obj.AddComponent <ProjectileController>(); projControl.catalogIndex = -1; projControl.ghostPrefab = AW_utilityZoneGhost; projControl.isPrediction = false; projControl.allowPrediction = true; projControl.procChainMask = default; projControl.procCoefficient = 1f; var rb = obj.AddComponent <Rigidbody>(); rb.mass = 1f; rb.drag = 0f; rb.angularDrag = 0.05f; rb.useGravity = false; rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; rb.collisionDetectionMode = CollisionDetectionMode.Continuous; var projNetTransform = obj.AddComponent <ProjectileNetworkTransform>(); projNetTransform.positionTransmitInterval = 0.03333334f; projNetTransform.interpolationFactor = 1f; projNetTransform.allowClientsideCollision = false; var projSimple = obj.AddComponent <ProjectileSimple>(); projSimple.velocity = 0f; projSimple.lifetime = 10f; projSimple.updateAfterFiring = false; projSimple.enableVelocityOverLifetime = false; var collider = obj.AddComponent <SphereCollider>(); collider.isTrigger = true; collider.material = null; collider.center = new Vector3(0f, 0f, 0f); collider.radius = 1f; var colliderRadScale = obj.AddComponent <ScaleColliderRadiusOverTime>(); colliderRadScale.startRadius = 1f; colliderRadScale.endRadius = 75f; colliderRadScale.duration = 10f; colliderRadScale.durationFrac = 1f; var damage = obj.AddComponent <ProjectileDamage>(); damage.damage = 0f; damage.crit = false; damage.force = 0f; damage.damageColorIndex = DamageColorIndex.Default; damage.damageType = DamageType.Generic; var teamFilter = obj.AddComponent <TeamFilter>(); var healOrb = obj.AddComponent <ProjectileUniversalHealOrbOnDamage>(); healOrb.effectPrefab = AW_utilityOrbEffect; healOrb.healTarget = UniversalHealOrb.HealTarget.Barrier; healOrb.healType = UniversalHealOrb.HealType.PercentMissing; healOrb.value = 0.05f; healOrb.useSkin = true; var damageZone = obj.AddComponent <ProjectileColliderDamageZone>(); damageZone.damageInterval = 0.5f; damageZone.damageMult = 0.5f; damageZone.procCoef = 0.5f; AW_utilityZoneProjectile = obj; RegisterProjectile(AW_utilityZoneProjectile); }
private void AW_PrimaryExplosionEffect() { var obj = PrefabsCore.CreatePrefab("PrimaryExplosionEffect", false); var effComp = obj.AddComponent <EffectComponent>(); effComp.positionAtReferencedTransform = false; effComp.parentToReferencedTransform = false; effComp.applyScale = true; effComp.soundName = "Play_item_use_meteor_impact"; var vfxAttrib = obj.AddComponent <VFXAttributes>(); vfxAttrib.vfxPriority = VFXAttributes.VFXPriority.Always; vfxAttrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; var skinner = obj.AddComponent <WispSkinnedEffect>(); var flash = EffectHelper.AddFlash(obj, skinner, MaterialType.Tracer, 2f); var flashLines = EffectHelper.AddFlashLines(obj, skinner, MaterialType.Tracer, 30, 0.05f, 0.05f, 1f); var flashLineShape = flashLines.shape; flashLineShape.enabled = true; flashLineShape.shapeType = ParticleSystemShapeType.Cone; flashLineShape.radius = 0.01f; flashLineShape.length = 1f; flashLineShape.angle = 60f; flashLineShape.rotation = new Vector3(-90f, 0f, 0f); flashLineShape.radiusThickness = 0.5f; if (!this.AW_lowPerf.Value) { var distortion = EffectHelper.AddDistortion(obj, skinner, MaterialType.DistortionHeavy, 2f, 0.25f, 0f); var distortionEmis = distortion.emission; distortionEmis.enabled = true; distortionEmis.burstCount = 1; distortionEmis.SetBurst(0, new ParticleSystem.Burst(0f, 1f, 1, 0.1f)); var distortionSOL = distortion.sizeOverLifetime; distortionSOL.enabled = true; distortionSOL.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0f, 0f, 1f, 1f)); } var explosion = EffectHelper.AddExplosion(obj, skinner, MaterialType.Explosion, 15, 0.25f, 5f, 1f); var explMain = explosion.main; explMain.gravityModifier = 0.5f; var explShape = explosion.shape; explShape.enabled = true; explShape.shapeType = ParticleSystemShapeType.Cone; explShape.angle = 60f; explShape.radius = 0.25f; explShape.rotation = new Vector3(-90f, 0f, 0f); if (!this.AW_lowPerf.Value) { var light = EffectHelper.AddLight(obj, skinner, true, 10f, 10f); light.transform.localPosition += new Vector3(0f, 0.5f, 0f); EffectHelper.EditLightOverTime(light, 0.5f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f), AnimationCurve.EaseInOut(0f, 1f, 1f, 0f)); } AW_primaryExplosionEffect = obj; RegisterEffect(AW_primaryExplosionEffect); }
private static GameObject CreateDecoyMaster() { GameObject master = PrefabsCore.CreatePrefab("SniperDecoyMaster", true); NetworkIdentity netId = master.AddOrGetComponent <NetworkIdentity>(); CharacterMaster charMaster = master.AddOrGetComponent <CharacterMaster>(); charMaster.masterIndex = new MasterCatalog.MasterIndex(-1); charMaster.bodyPrefab = GetDecoyPrefab(); charMaster.spawnOnStart = false; charMaster.teamIndex = TeamIndex.Player; charMaster.destroyOnBodyDeath = true; charMaster.isBoss = false; charMaster.preventGameOver = true; _ = master.AddOrGetComponent <Inventory>(); BaseAI ai = master.AddOrGetComponent <BaseAI>(); ai.fullVision = true; ai.neverRetaliateFriendlies = true; //ai.minDistanceFromEnemy = 0; ai.enemyAttentionDuration = 0; //ai.navigationType = BaseAI.NavigationType.Nodegraph; ai.desiredSpawnNodeGraphType = RoR2.Navigation.MapNodeGroup.GraphType.Ground; EntityStateMachine esm = ai.stateMachine = master.AddOrGetComponent <EntityStateMachine>(); ai.isHealer = false; ai.enemyAttention = 0f; ai.aimVectorDampTime = 0f; ai.aimVectorMaxSpeed = 0f; //ai.desiredAimDirection = Vector3.up; //ai.drawAIPath = false; ai.selectedSkilldriverName = null; ai.debugEnemyHurtBox = null; ai.currentEnemy = null; ai.leader = null; ai.customTarget = null; esm.customName = "AI"; esm.initialStateType = SkillsCore.StateType <BlankAI>(); esm.mainStateType = SkillsCore.StateType <BlankAI>(); AISkillDriver driver = master.AddOrGetComponent <AISkillDriver>(); driver.customName = "Sit there and look pretty"; driver.skillSlot = SkillSlot.None; driver.requiredSkill = null; driver.requireSkillReady = false; driver.requireEquipmentReady = false; driver.moveTargetType = AISkillDriver.TargetType.CurrentEnemy; driver.minUserHealthFraction = Single.NegativeInfinity; driver.maxUserHealthFraction = Single.PositiveInfinity; driver.minTargetHealthFraction = Single.NegativeInfinity; driver.maxTargetHealthFraction = Single.PositiveInfinity; driver.minDistance = Single.NegativeInfinity; driver.maxDistance = Single.PositiveInfinity; driver.selectionRequiresTargetLoS = false; driver.activationRequiresTargetLoS = false; driver.activationRequiresAimConfirmation = false; driver.movementType = AISkillDriver.MovementType.Stop; driver.moveInputScale = 0f; driver.aimType = AISkillDriver.AimType.None; driver.ignoreNodeGraph = true; driver.driverUpdateTimerOverride = 1f; driver.resetCurrentEnemyOnNextDriverSelection = false; driver.noRepeat = false; driver.shouldSprint = true; driver.shouldFireEquipment = false; driver.shouldTapButton = false; _ = master.AddOrGetComponent <MinionOwnership>(); AIOwnership aiOwnership = master.AddOrGetComponent <AIOwnership>(); aiOwnership.ownerMaster = null; foreach (IRuntimePrefabComponent comp in master.GetComponents <IRuntimePrefabComponent>()) { comp.InitializePrefab(); } MastersCore.Add(master); return(master); }
private static GameObject CreateDecoyPrefab() { GameObject obj = PrefabsCore.CreatePrefab("SniperDecoy", true); TeamComponent teamComp = obj.AddOrGetComponent <TeamComponent>(); teamComp.hideAllyCardDisplay = false; teamComp.teamIndex = TeamIndex.None; NetworkIdentity netId = obj.AddOrGetComponent <NetworkIdentity>(); Transform modelBase = new GameObject("ModelBase").transform; modelBase.parent = obj.transform; modelBase.localPosition = new Vector3(0f, -0.81f, 0f); modelBase.localScale = Vector3.one; modelBase.localRotation = Quaternion.identity; GameObject mdlSniper = UnityEngine.Object.Instantiate <GameObject>(ModelModule.GetModel(), modelBase); mdlSniper.transform.localPosition = Vector3.zero; mdlSniper.transform.localScale = Vector3.one; mdlSniper.transform.localRotation = Quaternion.identity; CharacterBody body = obj.AddOrGetComponent <CharacterBody>(); body.bodyIndex = (BodyIndex)(-1); body.baseNameToken = Properties.Tokens.SNIPER_NAME; body.subtitleNameToken = Properties.Tokens.SNIPER_SUBTITLE; body.bodyFlags = CharacterBody.BodyFlags.ResistantToAOE | CharacterBody.BodyFlags.ImmuneToExecutes; body.rootMotionInMainState = false; body.mainRootSpeed = 0f; // CLEANUP: Abstract out base stats for decoy and sniper body.baseMaxHealth = 130f; body.levelMaxHealth = 39f; body.baseRegen = 1f; body.levelRegen = 0.2f; body.baseMaxShield = 0f; body.levelMaxShield = 0f; body.baseMoveSpeed = 0f; body.levelMoveSpeed = 0f; body.baseAcceleration = 0f; body.baseJumpPower = 0f; body.levelJumpPower = 0f; body.baseDamage = 12f; body.levelDamage = 2.4f; body.baseAttackSpeed = 1f; body.levelAttackSpeed = 0f; body.baseCrit = 0f; body.levelCrit = 0f; body.baseArmor = 50f; body.levelArmor = 10f; body.baseJumpCount = 1; body.sprintingSpeedMultiplier = 0f; //body.killCount = 0; body.wasLucky = false; body.spreadBloomDecayTime = 0.45f; body.spreadBloomCurve = new AnimationCurve(); body.crosshairPrefab = null; body.hideCrosshair = false; body.aimOriginTransform = body.transform; body.hullClassification = HullClassification.Human; body.portraitIcon = UIModule.GetPortraitIcon(); body.isChampion = false; body.currentVehicle = null; body.preferredPodPrefab = null; body.preferredInitialStateType = SkillsCore.StateType <GenericCharacterMain>(); body.skinIndex = 0u; CharacterModel model = mdlSniper.AddOrGetComponent <CharacterModel>(); model.body = body; model.itemDisplayRuleSet = ItemDisplayModule.GetSniperItemDisplay(model.AddOrGetComponent <ChildLocator>()); HealthComponent health = obj.AddOrGetComponent <HealthComponent>(); health.health = 100; health.shield = 0; health.barrier = 0; health.magnetiCharge = 0; health.body = null; health.dontShowHealthbar = false; health.globalDeathEventChanceCoefficient = 1f; HurtBoxGroup hurtBoxGroup = model.AddOrGetComponent <HurtBoxGroup>(); HurtBox tempHb = model.GetComponentInChildren <HurtBox>(); tempHb.gameObject.layer = LayerIndex.entityPrecise.intVal; tempHb.healthComponent = health; tempHb.isBullseye = true; tempHb.damageModifier = HurtBox.DamageModifier.Normal; tempHb.hurtBoxGroup = hurtBoxGroup; tempHb.indexInGroup = 0; hurtBoxGroup.hurtBoxes = new[] { tempHb, }; hurtBoxGroup.mainHurtBox = tempHb; hurtBoxGroup.bullseyeCount = 1; InputBankTest inputs = obj.AddOrGetComponent <InputBankTest>(); inputs.moveVector = Vector3.zero; CameraTargetParams cameraTargetParams = obj.AddOrGetComponent <CameraTargetParams>(); cameraTargetParams.cameraParams = MiscModule.GetCharCameraParams(); cameraTargetParams.cameraPivotTransform = null; cameraTargetParams.aimMode = CameraTargetParams.AimType.Standard; cameraTargetParams.recoil = Vector2.zero; cameraTargetParams.idealLocalCameraPos = Vector3.zero; cameraTargetParams.dontRaycastToPivot = false; ModelLocator modelLocator = obj.AddOrGetComponent <ModelLocator>(); modelLocator.modelTransform = mdlSniper.transform; modelLocator.modelBaseTransform = modelBase; modelLocator.dontReleaseModelOnDeath = false; modelLocator.autoUpdateModelTransform = true; modelLocator.dontDetatchFromParent = false; modelLocator.noCorpse = true; modelLocator.normalizeToFloor = false; modelLocator.preserveModel = false; EntityStateMachine esm = obj.AddOrGetComponent <EntityStateMachine>(); esm.customName = "Body"; esm.initialStateType = SkillsCore.StateType <BeingADecoy>(); esm.mainStateType = SkillsCore.StateType <BeingADecoy>(); SkillLocator skillLocator = obj.AddOrGetComponent <SkillLocator>(); skillLocator.primary = null; skillLocator.secondary = null; skillLocator.utility = null; skillLocator.special = null; CharacterDeathBehavior deathBehaviour = obj.AddOrGetComponent <CharacterDeathBehavior>(); deathBehaviour.deathStateMachine = esm; deathBehaviour.deathState = SkillsCore.StateType <DecoyDeathState>(); deathBehaviour.idleStateMachine = Array.Empty <EntityStateMachine>(); CharacterNetworkTransform netTrans = obj.AddOrGetComponent <CharacterNetworkTransform>(); netTrans.positionTransmitInterval = 0.1f; netTrans.lastPositionTransmitTime = Single.NegativeInfinity; netTrans.interpolationFactor = 2f; netTrans.debugDuplicatePositions = false; netTrans.debugSnapshotReceived = false; NetworkStateMachine netStates = obj.AddOrGetComponent <NetworkStateMachine>(); //netStates._SetStateMachines( esm ); netStates.stateMachines = new[] { esm }; Interactor interactor = obj.AddOrGetComponent <Interactor>(); interactor.maxInteractionDistance = 1f; InteractionDriver interactionDriver = obj.AddOrGetComponent <InteractionDriver>(); interactionDriver.highlightInteractor = false; CapsuleCollider cap = obj.AddOrGetComponent <CapsuleCollider>(); cap.isTrigger = false; cap.material = null; cap.center = Vector3.zero; cap.radius = 0.5f; cap.height = 1.82f; cap.direction = 1; SetStateOnHurt hurtState = obj.AddOrGetComponent <SetStateOnHurt>(); hurtState.hitThreshold = 5f; hurtState.targetStateMachine = esm; hurtState.idleStateMachine = Array.Empty <EntityStateMachine>(); hurtState.hurtState = SkillsCore.StateType <Idle>(); hurtState.canBeHitStunned = false; hurtState.canBeFrozen = true; hurtState.canBeStunned = false; SfxLocator sfx = obj.AddOrGetComponent <SfxLocator>(); // FUTURE: Death sounds for decoy Rigidbody rb = obj.AddOrGetComponent <Rigidbody>(); rb.mass = 1000f; rb.drag = 0f; rb.angularDrag = 0f; rb.useGravity = false; rb.isKinematic = true; rb.interpolation = RigidbodyInterpolation.None; rb.collisionDetectionMode = CollisionDetectionMode.Discrete; CharacterMotor charMot = obj.AddOrGetComponent <CharacterMotor>(); charMot.walkSpeedPenaltyCoefficient = 1f; CharacterDirection charDir = charMot.characterDirection = obj.AddOrGetComponent <CharacterDirection>(); charMot.muteWalkMotion = false; charMot.mass = 1000f; charMot.airControl = 0.25f; charMot.disableAirControlUntilCollision = false; charMot.generateParametersOnAwake = true; charMot.useGravity = true; charMot.isFlying = false; charDir.moveVector = Vector3.zero; charDir.targetTransform = modelBase; charDir.overrideAnimatorForwardTransform = null; charDir.rootMotionAccumulator = null; charDir.modelAnimator = null; charDir.driveFromRootRotation = false; charDir.driveFromRootRotation = false; charDir.turnSpeed = 180f; KinematicCharacterController.KinematicCharacterMotor kinCharMot = obj.AddOrGetComponent <KinematicCharacterController.KinematicCharacterMotor>(); kinCharMot.CharacterController = charMot; kinCharMot.Capsule = cap; kinCharMot.Rigidbody = rb; kinCharMot.CapsuleRadius = 0.5f; kinCharMot.CapsuleHeight = 1.8f; kinCharMot.CapsuleYOffset = 0f; kinCharMot.DetectDiscreteCollisions = false; kinCharMot.GroundDetectionExtraDistance = 0f; kinCharMot.MaxStepHeight = 0.5f; kinCharMot.MinRequiredStepDepth = 0.1f; kinCharMot.MaxStableSlopeAngle = 55f; kinCharMot.MaxStableDistanceFromLedge = 0.5f; kinCharMot.PreventSnappingOnLedges = false; kinCharMot.MaxStableDenivelationAngle = 55f; kinCharMot.RigidbodyInteractionType = KinematicCharacterController.RigidbodyInteractionType.None; kinCharMot.PreserveAttachedRigidbodyMomentum = true; kinCharMot.HasPlanarConstraint = false; kinCharMot.PlanarConstraintAxis = Vector3.up; kinCharMot.StepHandling = KinematicCharacterController.StepHandlingMethod.Standard; kinCharMot.LedgeHandling = true; kinCharMot.InteractiveRigidbodyHandling = true; kinCharMot.SafeMovement = false; _ = obj.AddComponent <DecoyDeployableSync>(); obj.layer = LayerIndex.fakeActor.intVal; foreach (IRuntimePrefabComponent comp in obj.GetComponents <IRuntimePrefabComponent>()) { comp.InitializePrefab(); } BodiesCore.Add(obj); return(obj); }
private void AW_SecondaryPredictionEffect() { var obj = PrefabsCore.CreatePrefab("SecondaryPredictionEffect", false); var effComp = obj.AddComponent <EffectComponent>(); effComp.positionAtReferencedTransform = false; effComp.parentToReferencedTransform = false; effComp.applyScale = false; effComp.soundName = "Play_elite_antiHeal_turret_die"; var sound = obj.AddComponent <StartEndSound>(); sound.startSound = "Play_elite_antiHeal_turret_die"; sound.mult = 2; var skinner = obj.AddComponent <WispSkinnedEffect>(); var vecScale = obj.AddComponent <EffectVectorScale>(); vecScale.effectComp = effComp; vecScale.applyX = true; vecScale.applyY = false; vecScale.applyZ = true; vecScale.scaleOverTime = true; vecScale.durationFrac = 0.2f; var vfxAtrib = obj.AddComponent <VFXAttributes>(); vfxAtrib.vfxPriority = VFXAttributes.VFXPriority.Always; vfxAtrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; var timer = obj.AddComponent <DestroyOnEffectTimer>(); timer.effectComp = effComp; var indicator = EffectHelper.AddMeshIndicator(obj, skinner, MaterialType.BossAreaIndicator, MeshIndex.Cylinder, false, false, 0.5f, 1f, true, false, true); indicator.transform.localScale = new Vector3(1f, 1000f, 1f); indicator.transform.localPosition = new Vector3(0f, 995f, 0f); //var indPS = indicator.GetComponent<ParticleSystem>(); //timer.AddLifetimeParticle( indPS ); //var indPSMain = indPS.main; //indPSMain.maxParticles = 100; //var indPSCOL = indPS.colorOverLifetime; //indPSCOL.enabled = false; //indPSCOL.color = new ParticleSystem.MinMaxGradient( new Gradient //{ // mode = GradientMode.Blend, // alphaKeys = new[] // { // new GradientAlphaKey( 0f, 0f ), // new GradientAlphaKey( 1f, 0.1f ), // new GradientAlphaKey( 1f, 1f ), // }, // colorKeys = new[] // { // new GradientColorKey( Color.white, 0f ), // new GradientColorKey( Color.white, 1f ), // }, //} ); AW_secondaryPrediction = obj; RegisterEffect(AW_secondaryPrediction); }
private void AW_SecondaryExplosion() { var obj = PrefabsCore.CreatePrefab("SecondaryExplosionEffect", false); var effComp = obj.AddComponent <EffectComponent>(); effComp.positionAtReferencedTransform = false; effComp.parentToReferencedTransform = false; effComp.applyScale = false; effComp.soundName = null; var skin = obj.AddComponent <WispSkinnedEffect>(); var vecScale = obj.AddComponent <EffectVectorScale>(); vecScale.effectComp = effComp; vecScale.applyX = true; vecScale.applyY = false; vecScale.applyZ = true; vecScale.durationFrac = 0f; vecScale.scaleOverTime = false; var vfxAtrib = obj.AddComponent <VFXAttributes>(); vfxAtrib.vfxPriority = VFXAttributes.VFXPriority.Always; vfxAtrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; var timer = obj.AddComponent <DestroyOnTimer>(); timer.duration = 1f; var sounds = obj.AddComponent <EffectSoundPlayer>(); sounds.AddSound(new SoundEvent(0f, "Play_gravekeeper_attack2_shoot", 1f)); var flash1 = EffectHelper.AddFlash(obj, skin, MaterialType.Tracer); var flash1Main = flash1.main; flash1Main.scalingMode = ParticleSystemScalingMode.Local; var pillar = EffectHelper.AddFlamePillar(obj, skin, MaterialType.FlamePillar, 1000f, 3f, 0.75f); if (!this.AW_lowPerf.Value) { var sparks = EffectHelper.AddSparks(obj, skin, MaterialType.Tracer, 5000, 0.15f, 1.2f); var sparkMain = sparks.main; sparkMain.scalingMode = ParticleSystemScalingMode.Shape; sparkMain.maxParticles = 10000; var sparkShape = sparks.shape; sparkShape.enabled = true; sparkShape.shapeType = ParticleSystemShapeType.ConeVolume; sparkShape.angle = 0f; sparkShape.radius = 2f; sparkShape.length = 1000f; sparkShape.rotation = new Vector3(-90f, 0f, 0f); } var flashLines = EffectHelper.AddFlashLines(obj, skin, MaterialType.Tracer, 10, 0.2f); var flashLinesMain = flashLines.main; flashLinesMain.scalingMode = ParticleSystemScalingMode.Shape; var flashLineShape = flashLines.shape; flashLineShape.enabled = true; flashLineShape.shapeType = ParticleSystemShapeType.Cone; flashLineShape.radius = 1f; flashLineShape.length = 5f; flashLineShape.angle = 30f; flashLineShape.rotation = new Vector3(-90f, 0f, 0f); //var explosion = EffectHelper.AddExplosion( obj, skin, MaterialType.Explosion, 20, 0.3f, 5, 5f ); //var explShape = explosion.shape; //explShape.enabled = true; //explShape.shapeType = ParticleSystemShapeType.Hemisphere; //explShape.radius = 0.5f; //explShape.rotation = new Vector3( -90f, 0f, 0f ); if (!this.AW_lowPerf.Value) { var light = EffectHelper.AddLight(obj, skin, true, 20f, 100f); light.transform.localPosition += new Vector3(0f, 3f, 0f); EffectHelper.EditLightOverTime(light, 2f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f), AnimationCurve.EaseInOut(0f, 1f, 1f, 0f)); } if (!this.AW_lowPerf.Value) { var distortion = EffectHelper.AddDistortion(obj, skin, MaterialType.Distortion, 8f, 0.3f, 0f); } AW_secondaryExplosion = obj; RegisterEffect(AW_secondaryExplosion); }
internal static GameObject CreatePlasmaBurnPrefab() { var obj = PrefabsCore.CreatePrefab("PlasmaBurn", false); var holder = new GameObject("Particles"); holder.transform.parent = obj.transform; var mainPs = holder.AddComponent <ParticleSystem>(); var mainPsr = holder.AddOrGetComponent <ParticleSystemRenderer>(); mainPs .BurnMain() .BurnEmission() .BurnShape() .BurnCOL() .BurnSOL(); mainPsr .BurnRenderer(); ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime; mainPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime; mainPsLvol.enabled = false; ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity; mainPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime; mainPsFol.enabled = false; ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed; mainPsCbs.enabled = false; ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed; mainPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime; mainPsRol.enabled = false; ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed; mainPsRbs.enabled = false; ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces; mainPsExt.enabled = false; ParticleSystem.NoiseModule mainPsNoise = mainPs.noise; mainPsNoise.enabled = false; ParticleSystem.CollisionModule mainPsColl = mainPs.collision; mainPsColl.enabled = false; ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger; mainPsTrig.enabled = false; ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters; mainPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation; mainPsTex.enabled = false; ParticleSystem.LightsModule mainPsLigh = mainPs.lights; mainPsLigh.enabled = false; ParticleSystem.TrailModule mainPsTrail = mainPs.trails; mainPsTrail.enabled = false; ParticleSystem.CustomDataModule mainPsData = mainPs.customData; mainPsData.enabled = false; return(obj); }
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); }
internal static void CreatePrefab() { SniperMain.sniperBodyPrefab = PrefabsCore.CreatePrefab("Sniper", true); SniperMain.sniperBodyPrefab.tag = "Finish"; GameObject obj = SniperMain.sniperBodyPrefab; NetworkIdentity netId = obj.AddOrGetComponent <NetworkIdentity>(); netId.localPlayerAuthority = true; var modelBase = new GameObject("ModelBase"); modelBase.transform.parent = obj.transform; modelBase.transform.localPosition = new Vector3(0f, -0.81f, 0f); modelBase.transform.localRotation = Quaternion.identity; modelBase.transform.localScale = new Vector3(1f, 1f, 1f); var cameraPivot = new GameObject("CameraPivot"); cameraPivot.transform.parent = modelBase.transform; cameraPivot.transform.localPosition = new Vector3(0f, 1.6f, 0f); cameraPivot.transform.localRotation = Quaternion.identity; cameraPivot.transform.localScale = Vector3.one; var aimOrigin = new GameObject("AimOrigin"); aimOrigin.transform.parent = modelBase.transform; aimOrigin.transform.localPosition = new Vector3(0f, 1.4f, 0f); aimOrigin.transform.localRotation = Quaternion.identity; aimOrigin.transform.localScale = Vector3.one; GameObject model = ModelModule.GetModel(); Transform modelTransform = model.transform; modelTransform.parent = modelBase.transform; modelTransform.localPosition = Vector3.zero; modelTransform.localScale = Vector3.one; modelTransform.localRotation = Quaternion.identity; CharacterDirection direction = obj.AddOrGetComponent <CharacterDirection>(); direction.moveVector = Vector3.zero; direction.targetTransform = modelBase.transform; direction.overrideAnimatorForwardTransform = null; direction.rootMotionAccumulator = null; direction.modelAnimator = null; direction.driveFromRootRotation = false; direction.turnSpeed = 720f; //CharacterBody borkBorkBody = null; //if(borkBorkBody is null) return; //borkBorkBody.baseMaxHealth = 150f; //borkBorkBody.baseMoveSpeed = 9f; //borkBorkBody.baseJumpPower = 20f; //borkBorkBody.baseDamage = 12f; SniperCharacterBody body = obj.AddOrGetComponent <SniperCharacterBody>(); body.bodyIndex = (BodyIndex)(-1); body.baseNameToken = Tokens.SNIPER_NAME; body.subtitleNameToken = Tokens.SNIPER_SUBTITLE; body.bodyFlags = CharacterBody.BodyFlags.ImmuneToExecutes; body.rootMotionInMainState = false; body.mainRootSpeed = 0f; body.baseMaxHealth = 130f; body.levelMaxHealth = 39f; body.baseRegen = 2f; body.levelRegen = 0.4f; body.baseMaxShield = 0f; body.levelMaxShield = 0f; body.baseMoveSpeed = 7f; body.levelMoveSpeed = 0f; body.baseAcceleration = 60f; body.baseJumpPower = 15f; body.levelJumpPower = 0f; body.baseDamage = 12f; body.levelDamage = 3.6f; body.baseAttackSpeed = 1f; body.levelAttackSpeed = 0f; body.baseCrit = 1f; body.levelCrit = 0f; body.baseArmor = 0f; body.levelArmor = 0f; body.baseJumpCount = 1; body.sprintingSpeedMultiplier = 1.45f; body.wasLucky = false; body.spreadBloomDecayTime = 1f; body.spreadBloomCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); body.crosshairPrefab = UIModule.GetCrosshair(); body.hideCrosshair = false; body.aimOriginTransform = aimOrigin.transform; body.hullClassification = HullClassification.Human; body.portraitIcon = UIModule.GetPortraitIcon(); body.isChampion = false; body.currentVehicle = null; body.preferredPodPrefab = MiscModule.GetPodPrefab(); body.preferredInitialStateType = SkillsCore.StateType <Uninitialized>(); body.skinIndex = 0u; CharacterMotor motor = obj.AddOrGetComponent <CharacterMotor>(); motor.walkSpeedPenaltyCoefficient = 1f; motor.characterDirection = direction; motor.muteWalkMotion = false; motor.mass = 100f; motor.airControl = 0.25f; motor.disableAirControlUntilCollision = false; motor.generateParametersOnAwake = true; motor.useGravity = true; motor.isFlying = false; InputBankTest input = obj.AddOrGetComponent <InputBankTest>(); input.moveVector = Vector3.zero; CameraTargetParams ctp = obj.AddOrGetComponent <CameraTargetParams>(); ctp.cameraParams = MiscModule.GetCharCameraParams(); ctp.cameraPivotTransform = null; ctp.aimMode = CameraTargetParams.AimType.Standard; ctp.recoil = Vector2.zero; ctp.idealLocalCameraPos = Vector3.zero; ctp.dontRaycastToPivot = false; ModelLocator modelLocator = obj.AddOrGetComponent <ModelLocator>(); modelLocator.modelTransform = modelTransform; modelLocator.modelBaseTransform = modelBase.transform; modelLocator.dontReleaseModelOnDeath = false; modelLocator.autoUpdateModelTransform = true; modelLocator.dontDetatchFromParent = false; modelLocator.noCorpse = false; modelLocator.normalizeToFloor = false; modelLocator.preserveModel = false; EntityStateMachine bodyMachine = obj.AddOrGetComponent <EntityStateMachine>(); bodyMachine.customName = "Body"; bodyMachine.initialStateType = SkillsCore.StateType <SpawnTeleporterState>(); bodyMachine.mainStateType = SkillsCore.StateType <GenericCharacterMain>(); EntityStateMachine weaponMachine = obj.AddComponent <EntityStateMachine>(); weaponMachine.customName = "Weapon"; weaponMachine.initialStateType = SkillsCore.StateType <Idle>(); weaponMachine.mainStateType = SkillsCore.StateType <Idle>(); EntityStateMachine scopeMachine = obj.AddComponent <EntityStateMachine>(); scopeMachine.customName = "Scope"; scopeMachine.initialStateType = SkillsCore.StateType <Idle>(); scopeMachine.mainStateType = SkillsCore.StateType <Idle>(); EntityStateMachine reloadMachine = obj.AddComponent <EntityStateMachine>(); reloadMachine.customName = "Reload"; reloadMachine.initialStateType = SkillsCore.StateType <Idle>(); reloadMachine.mainStateType = SkillsCore.StateType <Idle>(); EntityStateMachine[] allStateMachines = new[] { bodyMachine, weaponMachine, scopeMachine, reloadMachine }; EntityStateMachine[] nonBodyStateMachines = new[] { weaponMachine, scopeMachine, reloadMachine }; GenericSkill ammoSkill = obj.AddOrGetComponent <GenericSkill>(); ammoSkill._skillFamily = SkillFamiliesModule.GetAmmoSkillFamily(); HooksModule.AddReturnoverride(ammoSkill); //GenericSkill passiveSkill = obj.AddComponent<GenericSkill>(); //passiveSkill._skillFamily = SkillFamiliesModule.GetPassiveSkillFamily(); //HooksModule.AddReturnoverride( passiveSkill ); GenericSkill primarySkill = obj.AddComponent <GenericSkill>(); primarySkill._skillFamily = SkillFamiliesModule.GetPrimarySkillFamily(); GenericSkill secondarySkill = obj.AddComponent <GenericSkill>(); secondarySkill._skillFamily = SkillFamiliesModule.GetSecondarySkillFamily(); GenericSkill utilitySkill = obj.AddComponent <GenericSkill>(); utilitySkill._skillFamily = SkillFamiliesModule.GetUtilitySkillFamily(); GenericSkill specialSkill = obj.AddComponent <GenericSkill>(); specialSkill._skillFamily = SkillFamiliesModule.GetSpecialSkillFamily(); SkillLocator skillLocator = obj.AddOrGetComponent <SkillLocator>(); skillLocator.primary = primarySkill; skillLocator.secondary = secondarySkill; skillLocator.utility = utilitySkill; skillLocator.special = specialSkill; skillLocator.passiveSkill = new SkillLocator.PassiveSkill { enabled = false, icon = null, skillDescriptionToken = null, skillNameToken = null, }; TeamComponent team = obj.AddOrGetComponent <TeamComponent>(); team.hideAllyCardDisplay = false; team.teamIndex = TeamIndex.None; HealthComponent health = obj.AddOrGetComponent <HealthComponent>(); health.health = 100; health.shield = 0; health.barrier = 0; health.magnetiCharge = 0; health.body = null; health.dontShowHealthbar = false; health.globalDeathEventChanceCoefficient = 1f; Interactor interactor = obj.AddOrGetComponent <Interactor>(); interactor.maxInteractionDistance = 3f; InteractionDriver interaction = obj.AddOrGetComponent <InteractionDriver>(); interaction.highlightInteractor = true; CharacterDeathBehavior death = obj.AddOrGetComponent <CharacterDeathBehavior>(); death.deathStateMachine = bodyMachine; death.deathState = SkillsCore.StateType <EntityStates.Commando.DeathState>(); death.idleStateMachine = nonBodyStateMachines; CharacterNetworkTransform netTrans = obj.AddOrGetComponent <CharacterNetworkTransform>(); netTrans.positionTransmitInterval = 0.05f; netTrans.lastPositionTransmitTime = Single.MinValue; netTrans.interpolationFactor = 3f; netTrans.debugDuplicatePositions = false; netTrans.debugSnapshotReceived = false; NetworkStateMachine netStates = obj.AddOrGetComponent <NetworkStateMachine>(); netStates.stateMachines = allStateMachines; //stateMachines.Set( netStates, allStateMachines ); CharacterEmoteDefinitions emotes = obj.AddOrGetComponent <CharacterEmoteDefinitions>(); emotes.emoteDefinitions = null; EquipmentSlot equip = obj.AddOrGetComponent <EquipmentSlot>(); SfxLocator sfx = obj.AddOrGetComponent <SfxLocator>(); sfx.deathSound = "Play_ui_player_death"; sfx.barkSound = ""; sfx.openSound = ""; sfx.landingSound = "Play_char_land"; sfx.fallDamageSound = "Play_char_land_fall_damage"; sfx.aliveLoopStart = ""; sfx.aliveLoopStop = ""; Rigidbody rb = obj.AddOrGetComponent <Rigidbody>(); rb.mass = 100f; rb.drag = 0f; rb.angularDrag = 0f; rb.useGravity = false; rb.isKinematic = true; rb.interpolation = RigidbodyInterpolation.None; rb.collisionDetectionMode = CollisionDetectionMode.Discrete; rb.constraints = RigidbodyConstraints.None; CapsuleCollider col = obj.AddOrGetComponent <CapsuleCollider>(); col.isTrigger = false; col.material = null; col.center = new Vector3(0f, 0f, 0f); col.radius = 0.5f; col.height = 1.82f; col.direction = 1; KinematicCharacterMotor kinCharMot = obj.AddOrGetComponent <KinematicCharacterMotor>(); kinCharMot.CharacterController = motor; kinCharMot.Capsule = col; kinCharMot.Rigidbody = rb; kinCharMot.CapsuleRadius = 0.5f; kinCharMot.CapsuleHeight = 1.82f; kinCharMot.CapsuleYOffset = 0f; kinCharMot.CapsulePhysicsMaterial = null; kinCharMot.DetectDiscreteCollisions = false; kinCharMot.GroundDetectionExtraDistance = 0f; kinCharMot.MaxStepHeight = 0.2f; kinCharMot.MinRequiredStepDepth = 0.1f; kinCharMot.MaxStableSlopeAngle = 55f; kinCharMot.MaxStableDistanceFromLedge = 0.5f; kinCharMot.PreventSnappingOnLedges = false; kinCharMot.MaxStableDenivelationAngle = 55f; kinCharMot.RigidbodyInteractionType = RigidbodyInteractionType.None; kinCharMot.PreserveAttachedRigidbodyMomentum = true; kinCharMot.HasPlanarConstraint = false; kinCharMot.PlanarConstraintAxis = Vector3.up; kinCharMot.StepHandling = StepHandlingMethod.None; kinCharMot.LedgeHandling = true; kinCharMot.InteractiveRigidbodyHandling = true; kinCharMot.SafeMovement = false; SetStateOnHurt hurt = obj.AddOrGetComponent <SetStateOnHurt>(); hurt.hitThreshold = 5f; hurt.targetStateMachine = bodyMachine; hurt.idleStateMachine = nonBodyStateMachines; hurt.hurtState = SkillsCore.StateType <Idle>(); hurt.canBeHitStunned = false; hurt.canBeStunned = false; hurt.canBeFrozen = true; CharacterModel charModel = model.AddOrGetComponent <CharacterModel>(); charModel.body = body; charModel.itemDisplayRuleSet = ItemDisplayModule.GetSniperItemDisplay(model.AddOrGetComponent <ChildLocator>()); HurtBoxGroup hurtBoxGroup = model.AddOrGetComponent <HurtBoxGroup>(); HurtBox tempHb = model.GetComponentInChildren <HurtBox>(); tempHb.gameObject.layer = LayerIndex.entityPrecise.intVal; tempHb.healthComponent = health; tempHb.isBullseye = true; tempHb.damageModifier = HurtBox.DamageModifier.Normal; tempHb.hurtBoxGroup = hurtBoxGroup; tempHb.indexInGroup = 0; hurtBoxGroup.hurtBoxes = new[] { tempHb, }; hurtBoxGroup.mainHurtBox = tempHb; hurtBoxGroup.bullseyeCount = 1; FootstepHandler footsteps = model.AddComponent <FootstepHandler>(); footsteps.baseFootstepString = "Play_player_footstep"; footsteps.sprintFootstepOverrideString = ""; footsteps.enableFootstepDust = true; footsteps.footstepDustPrefab = UnityEngine.Resources.Load <GameObject>("Prefabs/GenericFootstepDust"); RagdollController ragdoll = model.AddOrGetComponent <RagdollController>(); ragdoll.bones = null; // FUTURE: Setup sniper ragdoll controller ragdoll.componentsToDisableOnRagdoll = null; AimAnimator aimAnimator = model.AddOrGetComponent <AimAnimator>(); aimAnimator.inputBank = input; aimAnimator.directionComponent = direction; aimAnimator.pitchRangeMax = 55f; aimAnimator.pitchRangeMin = -50f; aimAnimator.yawRangeMin = -40f; aimAnimator.yawRangeMax = 45f; aimAnimator.pitchGiveupRange = 30f; aimAnimator.yawGiveupRange = 10f; aimAnimator.giveupDuration = 8f; ModelSkinController skinController = model.AddOrGetComponent <ModelSkinController>(); SkinDef[] skinsArray = skinController.skins; for (Int32 i = 0; i < skinsArray.Length; ++i) { SkinDef skin = skinsArray[i]; skin.minionSkinReplacements = new[] { new SkinDef.MinionSkinReplacement { minionBodyPrefab = DecoyModule.GetDecoyPrefab(), minionSkin = skin }, }; } foreach (IRuntimePrefabComponent comp in obj.GetComponents <IRuntimePrefabComponent>()) { comp.InitializePrefab(); } }
private void AW_CreatePrimaryProjectile() { var obj = PrefabsCore.CreatePrefab("AWPrimaryProjectile", true); obj.layer = LayerIndex.projectile.intVal; var netID = obj.GetComponent <NetworkIdentity>(); netID.localPlayerAuthority = true; netID.serverOnly = false; var projControl = obj.AddComponent <ProjectileController>(); projControl.catalogIndex = -1; projControl.ghostPrefab = AW_primaryProjGhost; projControl.isPrediction = false; projControl.allowPrediction = true; projControl.procChainMask = default; projControl.procCoefficient = 1f; var rb = obj.AddComponent <Rigidbody>(); rb.mass = 1f; rb.drag = 0f; rb.angularDrag = 0.05f; rb.useGravity = false; rb.isKinematic = false; rb.interpolation = RigidbodyInterpolation.Interpolate; rb.collisionDetectionMode = CollisionDetectionMode.Continuous; var projNetTransform = obj.AddComponent <ProjectileNetworkTransform>(); projNetTransform.positionTransmitInterval = 0.03333334f; projNetTransform.interpolationFactor = 1f; projNetTransform.allowClientsideCollision = false; var projSimple = obj.AddComponent <ProjectileSimple>(); projSimple.velocity = 76f; projSimple.lifetime = 5f; projSimple.updateAfterFiring = false; projSimple.enableVelocityOverLifetime = false; var collider = obj.AddComponent <SphereCollider>(); collider.isTrigger = false; collider.material = null; collider.center = Vector3.zero; collider.radius = 1.5f; var damage = obj.AddComponent <ProjectileDamage>(); damage.damage = 0f; damage.crit = false; damage.force = 0f; damage.damageColorIndex = DamageColorIndex.Default; damage.damageType = DamageType.Generic; var teamFilter = obj.AddComponent <TeamFilter>(); var impactExplosion = obj.AddComponent <ProjectileImpactExplosion>(); impactExplosion.impactEffect = AW_primaryExplosionEffect; impactExplosion.explosionSoundString = Main.skinnedProjExplosionString; impactExplosion.lifetimeExpiredSoundString = ""; impactExplosion.offsetForLifetimeExpiredSound = 0f; impactExplosion.destroyOnEnemy = true; impactExplosion.destroyOnWorld = true; impactExplosion.timerAfterImpact = false; impactExplosion.falloffModel = BlastAttack.FalloffModel.Linear; impactExplosion.lifetime = 5f; impactExplosion.lifetimeAfterImpact = 0f; impactExplosion.lifetimeRandomOffset = 0f; impactExplosion.blastRadius = 14f; impactExplosion.blastDamageCoefficient = 1f; impactExplosion.blastProcCoefficient = 1f; impactExplosion.bonusBlastForce = new Vector3(0f, 750f, 0f); impactExplosion.fireChildren = false; impactExplosion.childrenProjectilePrefab = null; impactExplosion.childrenCount = 0; impactExplosion.childrenDamageCoefficient = 0f; impactExplosion.minAngleOffset = Vector3.zero; impactExplosion.maxAngleOffset = Vector3.zero; impactExplosion.transformSpace = ProjectileImpactExplosion.TransformSpace.World; impactExplosion.projectileHealthComponent = null; AW_primaryProjectile = obj; RegisterProjectile(AW_primaryProjectile); }
internal static GameObject CreateSmallAmmoTracer(Material mainMat, Material trailMat) { GameObject obj = PrefabsCore.CreatePrefab("Standard Tracer", false); Transform tracerHead = new GameObject("TracerHead").transform; tracerHead.parent = obj.transform; tracerHead.localPosition = Vector3.zero; tracerHead.localRotation = Quaternion.identity; //tracerHead.localEulerAngles = new Vector3( 0f, 90f, 0f ); tracerHead.localScale = Vector3.one; Transform tracerTail = new GameObject("TracerTail").transform; tracerTail.parent = obj.transform; tracerTail.localPosition = Vector3.zero; tracerTail.localRotation = Quaternion.identity; tracerTail.localScale = Vector3.one; Transform trail = new GameObject("trail").transform; trail.parent = tracerTail; trail.localPosition = Vector3.zero; trail.localRotation = Quaternion.identity; trail.localScale = Vector3.one; Transform headBeam = new GameObject("HeadBeam").transform; headBeam.parent = tracerTail; headBeam.localPosition = Vector3.zero; headBeam.localEulerAngles = new Vector3(0f, 90f, 0f); headBeam.localScale = Vector3.one; EffectComponent effectComp = obj.AddComponent <EffectComponent>(); Tracer tracer = obj.AddComponent <Tracer>(); VFXAttributes vfxAtrib = obj.AddComponent <VFXAttributes>(); Rigidbody headRb = tracerHead.AddComponent <Rigidbody>(); Rigidbody tailRb = tracerTail.AddComponent <Rigidbody>(); ParticleSystem mainPs = headBeam.AddComponent <ParticleSystem>(); ParticleSystemRenderer mainPsr = headBeam.AddOrGetComponent <ParticleSystemRenderer>(); ParticleSystem trailPs = trail.AddComponent <ParticleSystem>(); ParticleSystemRenderer trailPsr = trail.AddOrGetComponent <ParticleSystemRenderer>(); DestroyTracerOnDelay cleanup = obj.AddComponent <DestroyTracerOnDelay>(); cleanup.delay = 2f; cleanup.tracer = tracer; ZeroTracerLengthOverDuration zeroLength = obj.AddComponent <ZeroTracerLengthOverDuration>(); zeroLength.tracer = tracer; DestroyOnTimer timer = obj.AddComponent <DestroyOnTimer>(); timer.duration = 10f; effectComp.effectIndex = EffectIndex.Invalid; effectComp.positionAtReferencedTransform = false; effectComp.parentToReferencedTransform = false; effectComp.applyScale = false; effectComp.soundName = null; effectComp.disregardZScale = false; tracer.startTransform = null; tracer.beamObject = null; tracer.beamDensity = 0f; tracer.speed = 600f; tracer.headTransform = tracerHead; tracer.tailTransform = tracerTail; tracer.length = 20f; tracer.reverse = false; headRb.isKinematic = true; headRb.useGravity = false; tailRb.isKinematic = true; tailRb.useGravity = false; vfxAtrib.optionalLights = null; vfxAtrib.secondaryParticleSystem = null; vfxAtrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; vfxAtrib.vfxPriority = VFXAttributes.VFXPriority.Always; mainPs.PlayOnStart(); mainPs.SetupSmallTracerMain(); mainPs.SetupSmallTracerEmission(); mainPs.SetupSmallTracerShape(); mainPs.SetupSmallTracerColorOverLifetime(); mainPs.SetupSmallTracerSizeOverLifetime(); mainPsr.SetupSmallTracerRenderer(mainMat); ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime; mainPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime; mainPsLvol.enabled = false; ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity; mainPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime; mainPsFol.enabled = false; ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed; mainPsCbs.enabled = false; ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed; mainPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime; mainPsRol.enabled = false; ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed; mainPsRbs.enabled = false; ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces; mainPsExt.enabled = false; ParticleSystem.NoiseModule mainPsNoise = mainPs.noise; mainPsNoise.enabled = false; ParticleSystem.CollisionModule mainPsColl = mainPs.collision; mainPsColl.enabled = false; ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger; mainPsTrig.enabled = false; ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters; mainPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation; mainPsTex.enabled = false; ParticleSystem.LightsModule mainPsLight = mainPs.lights; mainPsLight.enabled = false; ParticleSystem.TrailModule mainPsTrail = mainPs.trails; mainPsTrail.enabled = false; ParticleSystem.CustomDataModule mainPsData = mainPs.customData; mainPsData.enabled = false; trailPs.PlayOnStart(); trailPs.SetupSmallTracerTrailMain(); trailPs.SetupSmallTracerTrailEmission(); trailPs.SetupSmallTracerTrailNoise(); trailPs.SetupSmallTracerTrailTrail(); trailPsr.SetupSmallTracerTrailRenderer(trailMat); ParticleSystem.ShapeModule trailPsShape = trailPs.shape; trailPsShape.enabled = false; ParticleSystem.VelocityOverLifetimeModule trailPsVol = trailPs.velocityOverLifetime; trailPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule trailPsLvol = trailPs.limitVelocityOverLifetime; trailPsLvol.enabled = false; ParticleSystem.InheritVelocityModule trailPsIvel = trailPs.inheritVelocity; trailPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule trailPsFol = trailPs.forceOverLifetime; trailPsFol.enabled = false; ParticleSystem.ColorOverLifetimeModule trailPsCol = trailPs.colorOverLifetime; trailPsCol.enabled = false; ParticleSystem.ColorBySpeedModule trailPsCbs = trailPs.colorBySpeed; trailPsCbs.enabled = false; ParticleSystem.SizeOverLifetimeModule trailPsSol = trailPs.sizeOverLifetime; trailPsSol.enabled = false; ParticleSystem.SizeBySpeedModule trailPsSbs = trailPs.sizeBySpeed; trailPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule trailPsRol = trailPs.rotationOverLifetime; trailPsRol.enabled = false; ParticleSystem.RotationBySpeedModule trailPsRbs = trailPs.rotationBySpeed; trailPsRbs.enabled = false; ParticleSystem.ExternalForcesModule trailPsExt = trailPs.externalForces; trailPsExt.enabled = false; ParticleSystem.NoiseModule trailPsNoise = trailPs.noise; trailPsNoise.enabled = true; ParticleSystem.CollisionModule trailPsColl = trailPs.collision; trailPsColl.enabled = false; ParticleSystem.TriggerModule trailPsTrig = trailPs.trigger; trailPsTrig.enabled = false; ParticleSystem.SubEmittersModule trailPsSub = trailPs.subEmitters; trailPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule trailPsTex = trailPs.textureSheetAnimation; trailPsTex.enabled = false; ParticleSystem.LightsModule trailPsLigh = trailPs.lights; trailPsLigh.enabled = false; ParticleSystem.CustomDataModule trailPsData = trailPs.customData; trailPsData.enabled = false; return(obj); }
internal static void CreateReloadBarPrefab() { ITextureJob texBatch = TexturesCore.GenerateBarTextureBatch(128, 640, true, 64, 16, new Color(0f, 0f, 0f, 1f), reloadHandleColor, 4); //JobHandle.ScheduleBatchedJobs(); GameObject obj = PrefabsCore.CreateUIPrefab("ReloadBar", false); var objTrans = obj.transform as RectTransform; objTrans.sizeDelta = new Vector2(512f, 64f); objTrans.anchorMin = new Vector2(0.5f, 0.5f); objTrans.anchorMax = new Vector2(0.5f, 0.5f); objTrans.pivot = new Vector2(0.5f, 0.5f); objTrans.localPosition = new Vector3(0.0f, 0f, 0f); //objTrans.localEulerAngles = new Vector3( 0f, 0f, 0f ); GameObject holder = PrefabsCore.CreateUIPrefab("BarHolder", false); var holderTrans = holder.transform as RectTransform; holderTrans.SetParent(objTrans, false); holderTrans.sizeDelta = Vector2.zero; holderTrans.anchorMax = Vector2.one; holderTrans.anchorMin = Vector2.zero; holderTrans.pivot = new Vector2(0.5f, 0.5f); holderTrans.localPosition = new Vector3(0f, 330f, 0f); GameObject background = PrefabsCore.CreateUIPrefab("Background", false); var bgTrans = background.transform as RectTransform; bgTrans.SetParent(holderTrans, false); bgTrans.localPosition = Vector3.zero; bgTrans.sizeDelta = Vector2.zero; bgTrans.anchorMin = new Vector2(0f, 0.1f); bgTrans.anchorMax = new Vector2(1f, 0.9f); bgTrans.pivot = new Vector2(0.5f, 0.5f); CanvasRenderer bgRend = background.AddComponent <CanvasRenderer>(); bgRend.cullTransparentMesh = false; Image bgImg = background.AddComponent <Image>(); bgImg.sprite = null; bgImg.color = Color.white; bgImg.material = null; bgImg.raycastTarget = false; bgImg.type = Image.Type.Simple; bgImg.useSpriteMesh = false; bgImg.preserveAspect = false; GameObject slideArea = PrefabsCore.CreateUIPrefab("Handle Slide Area", false); var slideAreaTrans = slideArea.transform as RectTransform; slideAreaTrans.SetParent(holderTrans, false); slideAreaTrans.localPosition = Vector3.zero; slideAreaTrans.sizeDelta = Vector2.zero; slideAreaTrans.anchorMin = new Vector2(0f, 0f); slideAreaTrans.anchorMax = new Vector2(1f, 1f); slideAreaTrans.pivot = new Vector2(0.5f, 0.5f); GameObject handle = PrefabsCore.CreateUIPrefab("Handle", false); var handleTrans = handle.transform as RectTransform; handleTrans.SetParent(slideAreaTrans, false); handleTrans.localPosition = Vector3.zero; handleTrans.sizeDelta = new Vector2(16f, 0f); handleTrans.pivot = new Vector2(0.5f, 0.5f); CanvasRenderer handleRend = handle.AddComponent <CanvasRenderer>(); handleRend.cullTransparentMesh = false; Image handleImg = handle.AddComponent <Image>(); Texture2D tex = texBatch.OutputTextureAndDispose(); handleImg.sprite = Sprite.Create(tex, new Rect(0f, 0f, tex.width, tex.height), new Vector2(0.5f, 0.5f)); handleImg.color = Color.white; handleImg.material = null; handleImg.raycastTarget = false; handleImg.type = Image.Type.Simple; handleImg.useSpriteMesh = false; handleImg.preserveAspect = false; Slider slider = holder.AddComponent <Slider>(); slider.interactable = false; slider.transition = Selectable.Transition.None; slider.navigation = new Navigation { mode = Navigation.Mode.None }; slider.fillRect = null; slider.handleRect = handleTrans; slider.direction = Slider.Direction.LeftToRight; slider.minValue = 0f; slider.maxValue = 1f; slider.wholeNumbers = false; slider.value = 0f; _ = obj.AddComponent <ReloadUIController>(); reloadBarPrefab = obj; }