Пример #1
0
/**
 * @brief Call the reset function for those triggers that are no longer touched (left the trigger zone)
 * @param ent The edict that is leaving the trigger area
 * @param touched The edicts that the activating ent currently touches
 * @param num The amount of edicts in the @c touched list
 */
static void G_ResetTriggers (edict_t *ent, edict_t **touched, int num)
{
    edict_t *trigger = NULL;

    /* check all edicts to find all triggers */
    while ((trigger = G_EdictsGetNextInUse(trigger))) {
        if (trigger->solid == SOLID_TRIGGER) {
            /* check if our edict is among the known triggerers of this trigger */
            if (G_TriggerIsInList(trigger, ent)) {
                /* if so, check if it still touches it */
                int i;
                for (i = 0; i < num; i++) {
                    if (touched[i] == trigger)
                        break;	/* Yes ! */
                }
                if (i == num) {	/* No ! */
                    G_TriggerRemoveFromList(trigger, ent);
                    /* the ent left the trigger area */
                    if (trigger->reset != NULL)
                        trigger->reset(trigger, ent);
                }
            }
        }
    }
}
Пример #2
0
/**
 * @brief Adds the activator to the list of recognized edicts for this trigger_touch edict
 * @param self The trigger self pointer
 * @param activator The activating edict (might be nullptr)
 */
void G_TriggerAddToList (Edict* self, Edict* activator)
{
	Edict* e = self->touchedNext;

	if (activator == nullptr)
		return;

	if (G_TriggerIsInList(self, activator))
		return;

	activator->touchedNext = e;
	self->touchedNext = activator;
}
Пример #3
0
/**
 * @brief Adds the activator to the list of recognized edicts for this trigger_touch edict
 * @param self The trigger self pointer
 * @param activator The activating edict (might be nullptr)
 */
void G_TriggerAddToList (Edict* self, Edict* activator)
{
    if (activator == nullptr)
        return;

    if (G_TriggerIsInList(self, activator))
        return;

    linkedList_t* entry = static_cast<linkedList_t*>(G_TagMalloc(sizeof(linkedList_t), TAG_LEVEL));
    entry->data = activator;
    entry->next = self->touchedList;
    self->touchedList = entry;
}