Esempio n. 1
0
        public void Spray(SprayEvent e, SingleNode <GraffitiInstanceComponent> graffitiInstanceNode, [JoinByUser] WeaponNode weaponNode)
        {
            RaycastHit          hit;
            MuzzleLogicAccessor accessor          = new MuzzleLogicAccessor(weaponNode.muzzlePoint, weaponNode.weaponInstance);
            Vector3             worldPosition     = accessor.GetWorldPosition();
            Vector3             barrelOriginWorld = accessor.GetBarrelOriginWorld();
            Vector3             dir = worldPosition - barrelOriginWorld;

            if (PhysicsUtil.RaycastWithExclusion(barrelOriginWorld, dir, out hit, (worldPosition - barrelOriginWorld).magnitude + 10f, LayerMasks.VISUAL_STATIC, null))
            {
                base.ScheduleEvent(new CreateGraffitiEvent(barrelOriginWorld, dir, weaponNode.weaponInstance.WeaponInstance.transform.up), graffitiInstanceNode);
            }
        }
Esempio n. 2
0
        public void UpdateReticleSpotScale(WeaponRotationUpdateAimEvent e, ShaftAimingWorkingReticleEffectNode weapon)
        {
            MuzzleLogicAccessor accessor = new MuzzleLogicAccessor(weapon.muzzlePoint, weapon.weaponInstance);
            float   distance             = Vector3.Magnitude(weapon.shaftAimingTargetPointContainer.Point - accessor.GetBarrelOriginWorld());
            Vector3 barrelOriginWorld    = accessor.GetBarrelOriginWorld();
            float   z          = weapon.muzzlePoint.Current.transform.localPosition.z;
            Vector2 canvasSize = weapon.shaftAimingReticleEffect.CanvasSize;
            Vector2 vector7    = Camera.main.WorldToScreenPoint(barrelOriginWorld + (weapon.shaftAimingWorkingState.WorkingDirection * z));
            Vector2 vector8    = new Vector2((vector7.x / ((float)Screen.width)) * canvasSize.x, (vector7.y / ((float)Screen.height)) * canvasSize.y);

            weapon.shaftAimingReticleEffect.DynamicReticle.localPosition = (Vector3)(vector8 - (canvasSize / 2f));
            weapon.shaftAimingReticleEffect.ShaftReticleSpotBehaviour.SetSizeByDistance(distance, weapon.shaftAimingTargetPointContainer.IsInsideTankPart);
        }
Esempio n. 3
0
        public unsafe void UpdateCameraAtWorkingState(WeaponRotationUpdateShaftAimingCameraEvent e, AimingWorkingStateNode weapon, [JoinAll] AimingCameraNode cameraNode)
        {
            Transform           root     = cameraNode.cameraRootTransform.Root;
            MuzzleLogicAccessor accessor = new MuzzleLogicAccessor(weapon.muzzlePoint, weapon.weaponInstance);
            ShaftAimingCameraConfigEffectComponent shaftAimingCameraConfigEffect = weapon.shaftAimingCameraConfigEffect;
            ShaftAimingWorkingStateComponent       shaftAimingWorkingState       = weapon.shaftAimingWorkingState;

            root.SetPositionSafe(accessor.GetBarrelOriginWorld());
            root.SetRotationSafe(Quaternion.LookRotation(shaftAimingWorkingState.WorkingDirection, accessor.GetUpDirectionWorld()));
            Vector3 eulerAngles = root.eulerAngles;

            weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle = Mathf.Clamp(weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle, -weapon.shaftAimingRotationConfig.AimingOffsetClipping, weapon.shaftAimingRotationConfig.AimingOffsetClipping);
            float    num        = Mathf.Clamp(weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle, -weapon.shaftAimingRotationConfig.MaxAimingCameraOffset, weapon.shaftAimingRotationConfig.MaxAimingCameraOffset);
            Vector3 *vectorPtr1 = &eulerAngles;

            vectorPtr1->y += num;
            Vector3 *vectorPtr2 = &eulerAngles;

            vectorPtr2->x        -= weapon.weaponRotationControl.MouseShaftAimCumulativeVerticalAngle;
            root.eulerAngles      = eulerAngles;
            cameraNode.camera.FOV = Mathf.Lerp(shaftAimingCameraConfigEffect.ActivationStateTargetFov, shaftAimingCameraConfigEffect.WorkingStateMinFov, shaftAimingWorkingState.InitialEnergy - weapon.weaponEnergy.Energy);
        }
Esempio n. 4
0
        public void InterpolateManualTargetingCamera(UpdateEvent evt, AimingWorkActivationStateNode weapon, [JoinAll] AimingCameraNode cameraNode)
        {
            MuzzleVisualAccessor       accessor          = new MuzzleVisualAccessor(weapon.muzzlePoint);
            CameraComponent            camera            = cameraNode.camera;
            Transform                  root              = cameraNode.cameraRootTransform.Root;
            ShaftAimingCameraComponent shaftAimingCamera = cameraNode.shaftAimingCamera;
            float t = Mathf.Clamp01(weapon.shaftAimingWorkActivationState.ActivationTimer / weapon.shaftStateConfig.ActivationToWorkingTransitionTimeSec);
            MuzzleLogicAccessor accessor2 = new MuzzleLogicAccessor(weapon.muzzlePoint, weapon.weaponInstance);

            root.SetPositionSafe(Vector3.Lerp(shaftAimingCamera.WorldInitialCameraPosition, accessor2.GetBarrelOriginWorld(), t));
            Quaternion quaternion2 = Quaternion.LookRotation(accessor.GetFireDirectionWorld(), accessor.GetUpDirectionWorld());

            weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle = Mathf.Clamp(weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle, -weapon.shaftAimingRotationConfig.AimingOffsetClipping, weapon.shaftAimingRotationConfig.AimingOffsetClipping);
            Vector3 eulerAngles = quaternion2.eulerAngles;

            root.SetRotationSafe(Quaternion.Slerp(shaftAimingCamera.WorldInitialCameraRotation, Quaternion.Euler(eulerAngles.x, eulerAngles.y + weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle, eulerAngles.z), t));
            camera.FOV = Mathf.Lerp(shaftAimingCamera.InitialFOV, weapon.shaftAimingCameraConfigEffect.ActivationStateTargetFov, t);
        }