private void Start()
 {
     //you'll need code from PlayerOrbital and HoveringGunController (the base game one) to make this thing work
     //Add Lute support too
     if (owner == null)
     {
         owner = GameManager.Instance.PrimaryPlayer;
     }
     initialized = true;
     if (base.gameObject.GetComponent <tk2dSprite>() != null && !preventOutline) // needs a sprite to work!
     {
         sprite = base.gameObject.GetComponent <tk2dSprite>();
         SpriteOutlineManager.AddOutlineToSprite(sprite, outlineColor);
     }
     this.SetOrbitalTier(PlayerOrbital.CalculateTargetTier(owner, this));
     this.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(owner, orbitalTier));
     owner.orbitals.Add(this);
     ownerCenterPos = owner.CenterPosition;
     if (base.gameObject.GetComponent <SpeculativeRigidbody>() == null)
     {
         body = sprite.SetUpSpeculativeRigidbody(specBodyOffsets, specBodyDimensions);
         if (pixelColliders.Any())
         {
             body.PixelColliders.Clear();
             body.PixelColliders.AddRange(pixelColliders);
             body.CollideWithOthers = true;
         }
         else
         {
             body.PixelColliders.Clear();
             body.PixelColliders.Add(new PixelCollider
             {
                 ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                 CollisionLayer         = CollisionLayer.EnemyBlocker,
                 IsTrigger = false,
                 BagleUseFirstFrameOnly = false,
                 SpecifyBagelFrame      = string.Empty,
                 BagelColliderNumber    = 0,
                 ManualOffsetX          = specBodyOffsets.x,
                 ManualOffsetY          = specBodyOffsets.y,
                 ManualWidth            = specBodyDimensions.x,
                 ManualHeight           = specBodyDimensions.y,
                 ManualDiameter         = 0,
                 ManualLeftX            = 0,
                 ManualLeftY            = 0,
                 ManualRightX           = 0,
                 ManualRightY           = 0,
             });
             body.CollideWithOthers = false;
         }
         body.CollideWithTileMap = false;
     }
     if (projectile == null)
     {
         projectile         = ((Gun)ETGMod.Databases.Items[56]).DefaultModule.projectiles[0];
         projectile.Owner   = owner;
         projectile.Shooter = owner.specRigidbody;
     }
 }
        private void HandleMotion() // Add rotations to facing the target enemy
        {
            if (orbitingMode == OrbitingMode.ENEMY)
            {
                // if(retargetOrbiter <= 0)
                // {
                //     currentOrbitTarget = null;
                // }
                if (currentOrbitTarget == null || !currentOrbitTarget || currentOrbitTarget.healthHaver.IsDead)
                {
                    FindOrbitTarget();
                }
            }
            Vector2 centerPosition = owner.CenterPosition;

            if (Vector2.Distance(centerPosition, base.transform.position.XY()) > 20f)
            {
                base.transform.position = centerPosition.ToVector3ZUp(0f);
                body.Reinitialize();
            }
            if (orbitingMode == OrbitingMode.ENEMY && currentOrbitTarget != null)
            {
                centerPosition = currentOrbitTarget.CenterPosition;
            }
            else if (orbitingMode == OrbitingMode.CUSTOM && currentCustomOrbitTarget != null)
            {
                centerPosition = currentCustomOrbitTarget.transform.position;
            }
            Vector2 vector  = centerPosition - ownerCenterPos;
            float   num     = Mathf.Lerp(0.1f, 15f, vector.magnitude / 4f);
            float   d       = Mathf.Min(num * BraveTime.DeltaTime, vector.magnitude);
            float   num2    = 360f / (float)PlayerOrbital.GetNumberOfOrbitalsInTier(owner, this.GetOrbitalTier()) * (float)this.GetOrbitalTierIndex() + BraveTime.ScaledTimeSinceStartup * orbitalSpeed;
            Vector2 vector2 = ownerCenterPos + (centerPosition - ownerCenterPos).normalized * d;

            vector2 = Vector2.Lerp(vector2, centerPosition, perfectOrbitFactor);
            Vector2 vector3 = vector2 + (Quaternion.Euler(0f, 0f, num2) * Vector3.right * orbitalRadius).XY();

            if (hasSinWaveMovement)
            {
                float d2 = Mathf.Sin(Time.time * sinWavelength) * sinAmplitude;
                vector3 += (Quaternion.Euler(0f, 0f, num2) * Vector3.right).XY().normalized *d2;
            }
            ownerCenterPos = vector2;
            vector3        = vector3.Quantize(0.0625f);
            Vector2 velocity = (vector3 - base.transform.position.XY()) / BraveTime.DeltaTime;

            body.Velocity     = velocity;
            this.currentAngle = num2 % 360f;
            if (shouldRotate && hasTarget && targetToShoot == null || !targetToShoot || targetToShoot.healthHaver.IsDead)
            {
                hasTarget = false;
            }
            //fix rotating to target

            base.transform.localRotation = Quaternion.Euler(0f, 0f, currentAngle);
        }
Example #3
0
 private void ResetOrbitals(PlayerController player)
 {
     if (player.orbitals != null && player.orbitals.Count > 0)
     {
         foreach (var o in Owner.orbitals)
         {
             var orbital = (PlayerOrbital)o;
             if (orbital.gameObject.GetComponent <BoostedByAlbedo>() != null)
             {
                 orbital.orbitDegreesPerSecond /= orbital.gameObject.GetComponent <BoostedByAlbedo>().currentMultiplier;
                 orbital.SetOrbitalTier(PlayerOrbital.CalculateTargetTier(player, o));
                 orbital.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(player, orbital.gameObject.GetComponent <BoostedByAlbedo>().storedOrbitalTier));
                 UnityEngine.Object.Destroy(orbital.gameObject.GetComponent <BoostedByAlbedo>());
             }
         }
         RecalcOrbIndex();
     }
 }
Example #4
0
 private void UpdateOrbitals()
 {
     foreach (var o in Owner.orbitals)
     {
         var orbital = (PlayerOrbital)o;
         if (orbital.name == "IounStone_Glass(Clone)")
         {
             if (orbital.gameObject.GetComponent <BoostedByAlbedo>() == null)
             {
                 int mult = 3;
                 if (Owner.PlayerHasActiveSynergy("White Ethesia"))
                 {
                     mult = 4;
                 }
                 BoostedByAlbedo boost = orbital.gameObject.AddComponent <BoostedByAlbedo>();
                 boost.currentMultiplier        = mult;
                 boost.storedOrbitalTier        = orbital.GetOrbitalTier();
                 orbital.orbitDegreesPerSecond *= mult;
                 orbital.SetOrbitalTier(1010);
                 orbital.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(Owner, 1010));
             }
             else if (orbital.gameObject.GetComponent <BoostedByAlbedo>().currentMultiplier == 3 && Owner.PlayerHasActiveSynergy("White Ethesia"))
             {
                 orbital.orbitDegreesPerSecond /= 3;
                 orbital.orbitDegreesPerSecond *= 4;
                 orbital.gameObject.GetComponent <BoostedByAlbedo>().currentMultiplier = 4;
                 orbital.SetOrbitalTier(1010);
                 orbital.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(Owner, 1010));
             }
             else if (orbital.gameObject.GetComponent <BoostedByAlbedo>().currentMultiplier == 4 && !Owner.PlayerHasActiveSynergy("White Ethesia"))
             {
                 orbital.orbitDegreesPerSecond /= 4;
                 orbital.orbitDegreesPerSecond *= 3;
                 orbital.gameObject.GetComponent <BoostedByAlbedo>().currentMultiplier = 3;
                 orbital.SetOrbitalTier(1010);
                 orbital.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(Owner, 1010));
             }
         }
     }
     RecalcOrbIndex();
 }