Esempio n. 1
0
        private void RW_Misc()
        {
            InteractionDriver bodyIntDriver = this.RW_body.GetComponent <InteractionDriver>();

            bodyIntDriver.highlightInteractor = true;
            CharacterNetworkTransform bodyNetTrans = this.RW_body.GetComponent <CharacterNetworkTransform>();

            bodyNetTrans.positionTransmitInterval = 0.05f;
            bodyNetTrans.interpolationFactor      = 3f;

            SkinsCore.AddValidSkinOverride(this.RW_body, (skinInd) => true);
            SkinsCore.AddLockedSkinOverride(this.RW_body, (skinInd) => false);

            this.RW_body.tag = "Finish";
        }
        protected override bool PerformEquipmentAction(EquipmentSlot slot)
        {
            CharacterBody body = slot.characterBody;

            if (!body)
            {
                return(false);
            }
            InteractionDriver interactionDriver = body.GetComponent <InteractionDriver>();

            if (!interactionDriver)
            {
                return(false);
            }
            GameObject BestInteractableObject = interactionDriver.FindBestInteractableObject();

            if (!BestInteractableObject)
            {
                return(false);
            }
            PurchaseInteraction purchaseInteraction = BestInteractableObject.GetComponent <PurchaseInteraction>();

            if (!purchaseInteraction)
            {
                return(false);
            }

            float newUnlockChance = TrustyLockpicks_UnlockChance;

            if (ClassicItemsCompat.enabled && ClassicItemsCompat.CheckEmbryoProc(instance, body))
            {
                newUnlockChance *= 1.3f;
            }

            //interactionDriver.interactor.interactableCooldown = 0.25f;

            if (AttemptUnlock(BestInteractableObject, interactionDriver, newUnlockChance))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        // Token: 0x06002141 RID: 8513 RVA: 0x0009C2D0 File Offset: 0x0009A4D0
        private void Update()
        {
            string text   = "";
            string text2  = "";
            bool   active = false;

            if (this.hud && this.hud.targetBodyObject)
            {
                InteractionDriver component = this.hud.targetBodyObject.GetComponent <InteractionDriver>();
                if (component)
                {
                    GameObject gameObject = component.FindBestInteractableObject();
                    if (gameObject)
                    {
                        PlayerCharacterMasterController component2 = this.hud.targetMaster.GetComponent <PlayerCharacterMasterController>();
                        if (component2 && component2.networkUser && component2.networkUser.localUser != null)
                        {
                            IInteractable component3 = gameObject.GetComponent <IInteractable>();
                            if (component3 != null)
                            {
                                string text3 = (component3.GetInteractability(component.interactor) == Interactability.Available) ? component3.GetContextString(component.interactor) : null;
                                if (text3 != null)
                                {
                                    text2  = text3;
                                    text   = string.Format(CultureInfo.InvariantCulture, "<style=cKeyBinding>{0}</style>", Glyphs.GetGlyphString(this.eventSystemLocator, "Interact"));
                                    active = true;
                                }
                            }
                        }
                    }
                }
            }
            this.glyphTMP.text       = text;
            this.descriptionTMP.text = text2;
            this.contextDisplay.SetActive(active);
        }
Esempio n. 4
0
        private bool AttemptUnlock(GameObject chestObject, InteractionDriver interactionDriver, float UnlockChance)
        {
            if (!interactionDriver)
            {
                return(false);
            }
            Highlight           highlight           = chestObject.GetComponent <Highlight>();
            PurchaseInteraction purchaseInteraction = chestObject.GetComponent <PurchaseInteraction>();

            if (!highlight || !purchaseInteraction)
            {
                return(false);
            }
            BulletstormChestInteractorComponent chestComponent = chestObject.GetComponent <BulletstormChestInteractorComponent>();

            if (chestComponent && chestComponent.hasUsedLockpicks)
            {
                return(false);
            }

            GameObject selectedEffect = UnlockEffect;
            Vector3    offset         = Vector3.up * 1f;


            if (!purchaseInteraction.isShrine && purchaseInteraction.available && purchaseInteraction.costType == CostTypeIndex.Money)
            {
                Interactor interactor = interactionDriver.interactor;
                //interactionDriver.interactor.AttemptInteraction(chestObject);
                if (Util.CheckRoll(UnlockChance))
                {
                    purchaseInteraction.SetAvailable(false);
                    //purchaseInteraction.Networkavailable = false;

                    purchaseInteraction.gameObject.GetComponent <ChestBehavior>().Open();

                    //purchaseInteraction.cost = 0;
                    //purchaseInteraction.Networkcost = 0;

                    purchaseInteraction.onPurchase.Invoke(interactor);
                    purchaseInteraction.lastActivator = interactor;
                    Util.PlaySound(UnlockSound, interactor.gameObject);
                    EffectManager.SimpleEffect(UnlockEffect, chestObject.transform.position + offset, Quaternion.identity, true);
                }
                else
                {
                    purchaseInteraction.cost = Mathf.CeilToInt(purchaseInteraction.cost * cfgPriceMultiplier.Value);
                    //https://discord.com/channels/562704639141740588/562704639569428506/916819003064864788
                    purchaseInteraction.Networkcost = purchaseInteraction.cost; //weaver generated shit ^
                    selectedEffect = Fail_LockEffect;

                    //purchaseInteraction.displayNameToken = (prefix + purchaseInteraction.displayNameToken);
                    chestObject.AddComponent <BulletstormChestInteractorComponent>().hasUsedLockpicks = true; //does this even work? lol
                    EffectManager.SimpleEffect(selectedEffect, chestObject.transform.position + offset, Quaternion.identity, true);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        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 bool AttemptUnlock(GameObject chestObject, InteractionDriver interactionDriver, float UnlockChance)
        {
            Highlight           highlight           = chestObject.GetComponent <Highlight>();
            PurchaseInteraction purchaseInteraction = chestObject.GetComponent <PurchaseInteraction>();

            if (!highlight)
            {
                return(false);
            }
            if (!purchaseInteraction)
            {
                return(false);
            }
            TrustyLockpicksComponent component = chestObject.GetComponent <TrustyLockpicksComponent>();

            if (component && component.failed)
            {
                return(false);
            }
            if (!interactionDriver)
            {
                return(false);
            }

            GameObject selectedEffect;
            Vector3    offset = Vector3.up * 1f;


            if (!purchaseInteraction.isShrine && purchaseInteraction.available && purchaseInteraction.costType == CostTypeIndex.Money)
            {
                Interactor interactor = interactionDriver.interactor;
                //interactionDriver.interactor.AttemptInteraction(chestObject);
                if (Util.CheckRoll(UnlockChance))
                {
                    purchaseInteraction.SetAvailable(false);
                    purchaseInteraction.Networkavailable = false;

                    purchaseInteraction.gameObject.GetComponent <ChestBehavior>().Open();

                    //purchaseInteraction.cost = 0;
                    //purchaseInteraction.Networkcost = 0;

                    purchaseInteraction.onPurchase.Invoke(interactor);
                    purchaseInteraction.lastActivator = interactor;
                    Util.PlaySound(unlockSound, interactor.gameObject);
                    EffectManager.SimpleEffect(UnlockEffect, chestObject.transform.position + offset, Quaternion.identity, true);
                }
                else
                {
                    //var displaynamecomponent = chestObject.GetComponent<GenericDisplayNameProvider>();
                    //if (displaynamecomponent) displaynamecomponent.displayToken = prefix + displaynamecomponent.displayToken;
                    if (TrustyLockpicks_KillChest)
                    {
                        purchaseInteraction.costType = CostTypeIndex.None;
                        purchaseInteraction.SetAvailable(false);

                        selectedEffect = Fail_DestroyEffect;
                    }
                    else
                    {
                        purchaseInteraction.cost        = Mathf.CeilToInt(purchaseInteraction.cost * TrustyLockpicks_PriceHike);
                        purchaseInteraction.Networkcost = purchaseInteraction.cost;
                        selectedEffect = Fail_LockEffect;
                    }
                    purchaseInteraction.displayNameToken = (prefix + purchaseInteraction.displayNameToken);
                    chestObject.AddComponent <TrustyLockpicksComponent>().failed = true; //does this even work? lol
                    EffectManager.SimpleEffect(selectedEffect, chestObject.transform.position + offset, Quaternion.identity, true);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        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);
        }