Example #1
0
            void Update()
            {
                try
                {
                    if (m_cables.Count > 0)
                    {
                        ArbitraryCableDrawer currentCable = m_cables[m_cables.Count - 1];

                        int     thePointOfTheMaskIs = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.PlayerBlocker);
                        Vector2 position            = currentCable.Attach2.position;
                        Vector2 position2           = currentCable.Attach1.position;

                        Vector2 direction = position2 - position;
                        float   distance  = Vector2.Distance(position, position2);

                        if (PhysicsEngine.Instance.Raycast(position, direction, distance, out RaycastResult result, true, true, thePointOfTheMaskIs) && result != null && result.Contact != null)
                        {
                            ETGModConsole.Log("is raycast hittin");
                            GameObject thisIsCrazy = new GameObject($"cableHelper");
                            GameObject superCrazy  = UnityEngine.Object.Instantiate <GameObject>(thisIsCrazy, result.Contact, Quaternion.identity);

                            currentCable.Attach1 = superCrazy.transform;


                            ArbitraryCableDrawer cable = superCrazy.gameObject.AddComponent <ArbitraryCableDrawer>();
                            cable.Initialize(m_rigidbody.transform, superCrazy.transform);
                            m_cables.Add(cable);
                        }
                        else
                        {
                            ETGModConsole.Log("dumb baby");
                        }
                    }
                    ETGModConsole.Log(m_cables.Count.ToString());
                } catch (Exception e) { ETGModConsole.Log(e.ToString()); }
Example #2
0
 private void RecalcCable()
 {
     if (m_cable)
     {
         UnityEngine.Object.Destroy(m_cable);
         m_cable = null;
     }
     this.m_cable = m_projectile.gameObject.AddComponent <ArbitraryCableDrawer>();
     this.m_cable.Attach2Offset = m_projectile.specRigidbody.UnitCenter - m_projectile.transform.position.XY();
     this.m_cable.Initialize(this.owner.CurrentGun.barrelOffset, m_projectile.transform);
 }
Example #3
0
            public void Initialize(SpeculativeRigidbody rigbody)
            {
                m_cables = new List <ArbitraryCableDrawer>();
                GameObject           thisIsCrazy = new GameObject("cableHelper");
                GameObject           superCrazy  = UnityEngine.Object.Instantiate <GameObject>(thisIsCrazy, rigbody.UnitCenter, Quaternion.identity);
                ArbitraryCableDrawer cable       = superCrazy.gameObject.GetOrAddComponent <ArbitraryCableDrawer>();

                cable.Initialize(rigbody.transform, superCrazy.transform);
                m_cables.Add(cable);

                m_rigidbody = rigbody;

                cable.GetComponent <Mesh>().SetColors(new List <Color>()
                {
                    Color.red
                });
            }