public override void StartPerform(Creature creature)
 {
     SafeAnimator.SetBool(creature.GetAnimator(), "attacking", true);
     UpdateAttackPoint();
     lastTarget.SetLockedTarget(currentTarget);
     isAttacking = true;
 }
Exemplo n.º 2
0
        private static void StartHatchingVisuals(IncubatorEgg egg)
        {
            egg.fxControl.Play();
            Utils.PlayFMODAsset(egg.hatchSound, egg.transform, 30f);

            SafeAnimator.SetBool(egg.animationController.eggAnimator, egg.animParameter, true);
        }
        public GameObject Spawn(Transform parent, TechType techType, GameObject model)
        {
            if (!_initialized)
            {
                return(null);
            }

            var gameObject = model != null?Instantiate(model) : Instantiate(CraftData.GetPrefabForTechType(techType));

            if (techType == TechType.CrashPowder)
            {
                var crash = gameObject.GetComponent <CrashHome>();
                SafeAnimator.SetBool(crash.animator, "attacking", true);
                GameObject.Destroy(crash);
            }


            gameObject.transform.SetParent(parent, false);
            gameObject.transform.localScale    = GetModelScale(techType);
            gameObject.transform.localPosition = Vector3.zero;

            var growingPlant = gameObject.GetComponent <GrowingPlant>();

            if (growingPlant != null)
            {
                growingPlant.EnableIndoorState();
                growingPlant.enabled = false;
                growingPlant.SetProgress(1f);
                Transform transform = model.transform;
                growingPlant.SetScale(transform, 1f);
                growingPlant.SetPosition(transform);
            }
            else
            {
                Destroy(gameObject.GetComponent <Pickupable>());
                gameObject.AddComponent <TechTag>().type = techType;
                Destroy(gameObject.GetComponent <UniqueIdentifier>());
                gameObject.AddComponent <GrownPlant>().seed = null;
            }



            Destroy(gameObject.GetComponent <Rigidbody>());
            Destroy(gameObject.GetComponent <WorldForces>());

            SetActiveAllChildren(parent.transform, true);

            if (!_invalidAdjustTechTypes.Contains(techType))
            {
                SetLocalZeroAllChildren(parent.transform);
            }

            if (techType == TechType.TreeMushroomPiece)
            {
                gameObject.transform.localRotation = Quaternion.Euler(0f, 180f, 180f);
            }

            return(gameObject);
        }
Exemplo n.º 4
0
 void setAnimationEnabled(bool state)
 {
     if (animator && animator.isActiveAndEnabled)
     {
         SafeAnimator.SetBool(animator, "use_loop", state);
         SafeAnimator.SetBool(animator, "terraformer_mode_on", state);
     }
 }
Exemplo n.º 5
0
        static void Postfix(CrashHome __instance)
        {
            SafeAnimator.SetBool(__instance.animator, "attacking", true);

            __instance.spawnTime = -1f;

            __instance.gameObject.AddComponent <Destructor>();
        }
 public override void StopPerform(Creature creature)
 {
     SafeAnimator.SetBool(creature.GetAnimator(), "attacking", false);
     lastTarget.UnlockTarget();
     lastTarget.target = null;
     isAttacking       = false;
     StopAttack();
 }
Exemplo n.º 7
0
        public override bool OnLeftHandHeld()
        {
            if (grabbedObject != null)
            {
                SafeAnimator.SetBool(animator, "use_loop", true);
            }

            return(base.OnLeftHandHeld());
        }
Exemplo n.º 8
0
 public override void StopPerform(Creature creature)
 {
     SafeAnimator.SetBool(creature.GetAnimator(), "attacking", false);
     if (this.attackStartFXcontrol != null)
     {
         this.attackStartFXcontrol.Stop();
     }
     this.timeStopAttack = Time.time;
 }
        public void UpdateEquipped(GameObject sender, string slot)
        {
            if (usingPlayer != null && !usingPlayer.IsInSub())
            {
                freezeCannon.usingCannon = GameInput.GetButtonDown(GameInput.Button.RightHand);

                freezeCannon.UpdateActive();

                SafeAnimator.SetBool(Player.main.armsController.GetComponent <Animator>(), "cangrab_propulsioncannon", freezeCannon.CanFreeze || freezeCannon.TargetObject != null);
            }
        }
Exemplo n.º 10
0
 public override void StartPerform(Creature creature)
 {
     this.timeStartAttack = Time.time;
     if (this.attackStartSound)
     {
         this.attackStartSound.Play();
         Debugger.Log("Play sound !");
     }
     if (this.attackStartFXcontrol != null)
     {
         this.attackStartFXcontrol.Play();
     }
     SafeAnimator.SetBool(creature.GetAnimator(), "attacking", true);
 }
Exemplo n.º 11
0
        public override bool OnLeftHandUp()
        {
            if (grabbedObject != null)
            {
                SafeAnimator.SetBool(animator, "use_loop", false);

                var transformInfo = GetNewPos(grabbedObject.transform);

                WarpObject(grabbedObject, transformInfo.Position, transformInfo.Rotation);
                grabbedObject.AddComponent <WarpedObject>();

                grabbedObject = null;
            }

            return(base.OnLeftHandUp());
        }
Exemplo n.º 12
0
        private void GrabVehicle(Vehicle vehicle, VehicleType vehicleType)
        {
            vehicle.GetComponent <Rigidbody>().isKinematic = true;
            vehicle.collisionModel.SetActive(false);
            heldVehicle     = vehicle;
            heldVehicleType = vehicleType;
            if (heldVehicleType == VehicleType.Exosuit)
            {
                SafeAnimator.SetBool(vehicle.mainAnimator, "reaper_attack", true);
                Exosuit component = vehicle.GetComponent <Exosuit>();
                if (component != null)
                {
                    component.cinematicMode = true;
                }
            }
            timeVehicleGrabbed     = Time.time;
            vehicleInitialRotation = vehicle.transform.rotation;
            vehicleInitialPosition = vehicle.transform.position;
            if (heldVehicleType == VehicleType.GenericSub)
            {
                vehicleGrabSound.clip = seamothSounds.GetRandomClip();
            }
            else if (heldVehicleType == VehicleType.Exosuit)
            {
                vehicleGrabSound.clip = exosuitSounds.GetRandomClip();
            }
            else
            {
                ECCLog.AddMessage("Unknown Vehicle Type detected");
            }
            vehicleGrabSound.Play();
            InvokeRepeating("DamageVehicle", 1f, 1f);
            float attackLength = 6f + UnityEngine.Random.value;

            Invoke("ReleaseVehicle", attackLength);
            if (Player.main.GetVehicle() == heldVehicle)
            {
                MainCameraControl.main.ShakeCamera(4f, attackLength, MainCameraControl.ShakeMode.BuildUp, 1.2f);
            }
        }
Exemplo n.º 13
0
 public override void StartPerform(Creature creature)
 {
     SafeAnimator.SetBool(creature.GetAnimator(), "attacking", true);
     lastTarget.SetLockedTarget(Player.main.currentSub.gameObject);
 }
Exemplo n.º 14
0
        public override void Process(PlayerHeldItemChanged packet)
        {
            Optional <RemotePlayer> opPlayer = playerManager.Find(packet.PlayerId);

            Validate.IsPresent(opPlayer);

            Optional <GameObject> opItem = NitroxEntity.GetObjectFrom(packet.ItemId);

            Validate.IsPresent(opItem);

            Pickupable pickupable = opItem.Value.GetComponent <Pickupable>();

            Validate.IsTrue(pickupable);

            InventoryItem inventoryItem = (InventoryItem)inventoryItemFromPickupable.GetValue(pickupable);

            Validate.NotNull(inventoryItem);

            ItemsContainer inventory = opPlayer.Value.Inventory;
            PlayerTool     tool      = opItem.Value.GetComponent <PlayerTool>();

            // Copied from QuickSlots
            switch (packet.Type)
            {
            case PlayerHeldItemChangedType.DRAW_AS_TOOL:
                Validate.IsTrue(tool);
                ModelPlug.PlugIntoSocket(tool, opPlayer.Value.ItemAttachPoint);
                Utils.SetLayerRecursively(opItem.Value, viewModelLayer);
                foreach (Animator componentsInChild in tool.GetComponentsInChildren <Animator>())
                {
                    componentsInChild.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                }
                if (tool.mainCollider)
                {
                    tool.mainCollider.enabled = false;
                }
                tool.GetComponent <Rigidbody>().isKinematic = true;
                opItem.Value.SetActive(true);
                setHandIK.Invoke(tool, new object[] { true });
                SafeAnimator.SetBool(opPlayer.Value.ArmsController.GetComponent <Animator>(), $"holding_{tool.animToolName}", true);
                opPlayer.Value.AnimationController["using_tool_first"] = packet.IsFirstTime == null;

                if (opItem.Value.TryGetComponent(out FPModel fpModelDraw))     //FPModel needs to be updated
                {
                    fpModelDraw.OnEquip(null, null);
                }
                break;

            case PlayerHeldItemChangedType.HOLSTER_AS_TOOL:
                Validate.IsTrue(tool);
                opItem.Value.SetActive(false);
                Utils.SetLayerRecursively(opItem.Value, defaultLayer);
                if (tool.mainCollider)
                {
                    tool.mainCollider.enabled = true;
                }
                tool.GetComponent <Rigidbody>().isKinematic = false;
                inventoryItem.item.Reparent(inventory.tr);
                foreach (Animator componentsInChild in tool.GetComponentsInChildren <Animator>())
                {
                    componentsInChild.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
                }
                SafeAnimator.SetBool(opPlayer.Value.ArmsController.GetComponent <Animator>(), $"holding_{tool.animToolName}", false);
                opPlayer.Value.AnimationController["using_tool_first"] = false;

                if (opItem.Value.TryGetComponent(out FPModel fpModelHolster))     //FPModel needs to be updated
                {
                    fpModelHolster.OnUnequip(null, null);
                }

                break;

            case PlayerHeldItemChangedType.DRAW_AS_ITEM:
                inventoryItem.item.Reparent(opPlayer.Value.ItemAttachPoint);
                inventoryItem.item.SetVisible(true);
                Utils.SetLayerRecursively(inventoryItem.item.gameObject, viewModelLayer);
                break;

            case PlayerHeldItemChangedType.HOLSTER_AS_ITEM:
                inventoryItem.item.Reparent(inventory.tr);
                inventoryItem.item.SetVisible(false);
                Utils.SetLayerRecursively(inventoryItem.item.gameObject, defaultLayer);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }