Ejemplo n.º 1
0
 public CDamageInfo(int iDamage, EDamageType eType, CBaseEntity pAttacker, Vector3 vDmgPosition)
 {
     m_iDamage         = m_iBaseDamage = iDamage;
     m_pAttacker       = pAttacker;
     m_vDamagePosition = vDmgPosition;
     m_eDamageType     = eType;
 }
Ejemplo n.º 2
0
        /****************************************************************************************
         * Public helper functions
         ***************************************************************************************/
        bool                            FilterEntity(CBaseEntity pEnt)
        {
            bool bResult = false;

            if (pEnt != null)
            {
                switch (m_eFilterMode)
                {
                case EFilterMode.Normal:
                    bResult = FilterEntityNorm(pEnt);
                    break;

                case EFilterMode.Inverted:
                    bResult = !FilterEntityNorm(pEnt);
                    break;

                case EFilterMode.Random:
                    bResult = NRand.randBool(m_flRandomChance);
                    break;

                case EFilterMode.AllowAll:
                    bResult = true;
                    break;

                case EFilterMode.BlockAll:
                    bResult = false;
                    break;
                }
            }
            return(bResult);
        }
Ejemplo n.º 3
0
 public CDamageInfo(int iDamage, CBaseEntity pAttacker, Vector3 vDmgPosition, Vector3 vForce)
 {
     m_iDamage         = m_iBaseDamage = iDamage;
     m_pAttacker       = pAttacker;
     m_vDamagePosition = vDmgPosition;
     m_vForce          = vForce;
 }
Ejemplo n.º 4
0
 private static bool Hook_Use(CBaseEntity pEnt, CBaseController pController)
 {
     if (pEnt.GetOffsetTo(pController).magnitude < pEnt.m_flInputEventRadius)
     {
         return(pEnt.Use(pController));
     }
     return(false);
 }
Ejemplo n.º 5
0
 public CDamageInfo(int iDamage, int iMinDmg, int iMaxDmg, CBaseEntity pAttacker, Vector3 vDmgPosition)
 {
     m_iDamage         = m_iBaseDamage = iDamage;
     m_pAttacker       = pAttacker;
     m_vDamagePosition = vDmgPosition;
     m_iMinDamage      = iMinDmg;
     m_iMaxDamage      = iMaxDmg;
 }
Ejemplo n.º 6
0
        private void OnTriggerEnter(Collider collider)
        {
            CBaseEntity pEnt = g.ToBaseEntity(collider.gameObject);

            if (pEnt != null)
            {
                pEnt.SetIsTouchedByController(true);
                m_pColliding.Add(pEnt);
            }
        }
Ejemplo n.º 7
0
 public CDamageInfo(int iDamage, int iMinDmg, int iMaxDmg, EDamageType eType, CBaseEntity pAttacker, Vector3 vDmgPosition, Vector3 vForce)
 {
     m_iDamage         = m_iBaseDamage = iDamage;
     m_pAttacker       = pAttacker;
     m_vDamagePosition = vDmgPosition;
     m_vForce          = vForce;
     m_iMinDamage      = iMinDmg;
     m_iMaxDamage      = iMaxDmg;
     m_eDamageType     = eType;
 }
Ejemplo n.º 8
0
        private void OnTriggerExit(Collider collider)
        {
            CBaseEntity pEnt = g.ToBaseEntity(collider.gameObject);

            if (pEnt != null)
            {
                pEnt.SetIsTouchedByController(false);
                m_pColliding.Remove(pEnt);
                pEnt.ForceDrop(this);
            }
        }
Ejemplo n.º 9
0
 public void AddFlagToChildren(int iFlag)
 {
     for (int i = 0; i < GetTransform().childCount; i++)
     {
         CBaseEntity pEnt = g.ToBaseEntity(GetTransform().GetChild(i).gameObject);
         if (pEnt != null)
         {
             pEnt.AddFlags(iFlag);
             pEnt.AddFlagToChildren(iFlag);
         }
     }
 }
Ejemplo n.º 10
0
        public static CBaseEntity ToBaseEntity(string objName)
        {
            CBaseEntity result = null;

            foreach (CBaseEntity pEnt in CBaseEntity.g_aEntList)
            {
                if (pEnt.obj().name.Equals(objName))
                {
                    result = pEnt;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 11
0
        public override void OnUsed(CBaseEntity pUser)
        {
            base.OnUsed(pUser);
            CBaseController controller = pUser as CBaseController;

            if (controller != null)
            {
                if (controller.ButtonsPressed().HasButton(g.IN_TRIGGER))
                {
                    obj().GetComponent <MeshRenderer>().material = m_pToggledMaterial;
                }
                else
                {
                    obj().GetComponent <MeshRenderer>().material = m_pStartingMaterial;
                }
            }
        }
Ejemplo n.º 12
0
 /**
  * Sets all entities to their default health and spawn flags.
  * Does this by calling Respawn() on all entities.
  */
 static void ReloadAllEntities()
 {
     for (int i = 0; i < g_aEntList.Count; i++)
     {
         CBaseEntity pEnt = g_aEntList[i];
         if (pEnt != null)
         {
             if (pEnt.HasFlag(FL_DESTROY_ON_RESPAWN))
             {
                 Destroy(pEnt.obj());
             }
             else
             {
                 pEnt.Respawn();
             }
         }
     }
 }
Ejemplo n.º 13
0
            public void Start(CBaseController pController, CBaseEntity pEnt)
            {
                //builds flags from our booleans
                ulong pressPressedFlags  = m_pPressPressed.GetFlags();
                ulong pressReleasedFlags = m_pPressReleased.GetFlags();
                ulong touchPressedFlags  = m_pTouchPressed.GetFlags();
                ulong touchReleasedFlags = m_pTouchReleased.GetFlags();

                CButtonSet touch = pController.ButtonsTouched();
                CButtonSet press = pController.ButtonsPressed();

                //iterate through all the buttons
                if (pEnt.m_bInputEventsTriggersUse)
                {
                    EntityControllerInputEvent input = new EntityControllerInputEvent();
                    input.m_pEnt      = pEnt;
                    input.m_pFunction = CBaseEntity.Hook_Use;

                    for (int i = 0; i < g.IN_NUM_BUTTONS; i++)
                    {
                        CButton b = press.m_pButtons[i];
                        if ((pressPressedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pPressedEvents.Add(input);
                        }
                        if ((pressReleasedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pReleasedEvents.Add(input);
                        }
                    }
                    for (int i = 0; i < g.IN_NUM_BUTTONS; i++)
                    {
                        CButton b = touch.m_pButtons[i];
                        if ((touchPressedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pPressedEvents.Add(input);
                        }
                        if ((touchReleasedFlags & b.m_iFlag) > 0)
                        {
                            b.m_pReleasedEvents.Add(input);
                        }
                    }
                }
            }
Ejemplo n.º 14
0
        bool    FilterEntityNorm(CBaseEntity pEnt)
        {
            bool result = false;

            switch (m_eFilterType)
            {
            case EFilterType.ByName:
                result = pEnt.name.Equals(m_sTextComparator);
                break;

            case EFilterType.ByTag:
                result = pEnt.CompareTag(m_sTextComparator);
                break;

            case EFilterType.ByIsActive:
                result = pEnt.obj().activeInHierarchy;
                break;

            case EFilterType.ByIsVisible:
                Renderer pRenderer = pEnt.obj().GetComponent <Renderer>();
                if (pRenderer != null)
                {
                    result = pRenderer.enabled;
                }
                break;

            case EFilterType.ByIsSolid:
                Collider pCollider = pEnt.obj().GetComponent <Collider>();
                if (pCollider != null)
                {
                    result = pCollider.enabled;
                }
                break;

            case EFilterType.ByIsPhysicsSimulated:
                Rigidbody pBody = pEnt.obj().GetComponent <Rigidbody>();
                result = pBody != null;
                break;
            }

            return(result);
        }
Ejemplo n.º 15
0
        public bool                    Use(CBaseEntity pUser)
        {
            bool bUsed = IsUseable();

            if (bUsed)
            {
                if (m_bUseTogglesPickup && pUser is CBaseController)
                {
                    if (!m_bIsPickedUp || !HasParent() || pUser != GetParent())
                    {
                        Pickup(pUser as CBaseController);
                    }
                    else
                    {
                        Drop(pUser as CBaseController);
                    }
                }
                OnUsed(pUser);
            }
            return(bUsed);
        }
Ejemplo n.º 16
0
 public Vector3 GetOffsetTo(CBaseEntity pEnt)
 {
     return(GetOffsetTo(pEnt.GetAbsOrigin()));
 }
Ejemplo n.º 17
0
 public bool ToggleBlockDrop(CBaseEntity pEnt, CBaseController pController)
 {
     m_bDropBlocks = !m_bDropBlocks;
     return(true);
 }
Ejemplo n.º 18
0
 public bool ToggleMusic(CBaseEntity pEnt, CBaseController pController)
 {
     m_bMuteStatus       = !m_bMuteStatus;
     m_pMusicSource.mute = !m_pMusicSource.mute;
     return(true);
 }
Ejemplo n.º 19
0
 public Quaternion GetAngleTo(CBaseEntity pEnt)
 {
     return(Quaternion.LookRotation(GetOffsetTo(pEnt.GetAbsOrigin())));
 }
Ejemplo n.º 20
0
 /****************************************************************************************
  * Aliases for transform parenting
  ***************************************************************************************/
 public void                    SetParent(CBaseEntity pParent)
 {
     GetTransform().parent = pParent.GetTransform();
 }
Ejemplo n.º 21
0
 public virtual void    OnUsed(CBaseEntity pUser)
 {
 }
Ejemplo n.º 22
0
 public bool    CanSee(CBaseEntity pEnt)
 {
     return(Physics.Raycast(GetPosition(), pEnt.GetPosition() - GetPosition()));
 }