Пример #1
0
	void SelectionVisualizer::clearSelectionForUnifiedHandle(UnifiedHandle uh)
	{
		if (!VALIDATE_UNIFIED_HANDLE_BITS(uh))
		{
			LOG_WARNING_W_DEBUG("SelectionVisualizer::clearSelectionForUnifiedHandle - Given unified handle is not valid.", int2str(uh));
			return;
		}

		for (int i = 0; i < (int)selectionUnifiedHandles.size(); i++)
		{
			if (selectionUnifiedHandles[i] == uh)
			{
				selectionUnifiedHandles.erase(selectionUnifiedHandles.begin() + i);
				return;
			}
		}

		LOG_WARNING_W_DEBUG("SelectionVisualizer::clearSelectionForUnifiedHandle - Given unified handle not found in list.", int2str(uh));
	}
Пример #2
0
	void SelectionVisualizer::setSelectionForUnifiedHandle(UnifiedHandle uh)
	{
		if (!VALIDATE_UNIFIED_HANDLE_BITS(uh))
		{
			LOG_WARNING_W_DEBUG("SelectionVisualizer::setSelectionForUnifiedHandle - Given unified handle is not valid.", int2str(uh));
			return;
		}

		for (int i = 0; i < (int)selectionUnifiedHandles.size(); i++)
		{
			if (selectionUnifiedHandles[i] == uh)
			{
				LOG_WARNING_W_DEBUG("SelectionVisualizer::setSelectionForUnifiedHandle - Given unified handle already found in list.", int2str(uh));
				return;
			}
		}

		selectionUnifiedHandles.push_back(uh);
	}
void ScriptableAIDirectControl::addCustomEvent(int afterTicks, const char *customEventName)
{
    if (customEventName == NULL)
    {
        LOG_ERROR("ScriptableAIDirectControl::addCustomEvent - Attempt to add a custom event with null name.");
        return;
    }
    if (afterTicks <= 0)
    {
        LOG_ERROR("ScriptableAIDirectControl::addCustomEvent - Attempt to add a custom event with zero or less tick delay.");
        return;
    }

    bool foundSlot = false;
    int addToSlot = -1;
    if (this->customEventsUsed < SCRIPTABLEAIDIRECTCONTROL_MAX_CUSTOM_EVENTS)
    {
        addToSlot = this->customEventsUsed;
        foundSlot = true;
    }

    if (this->customEventsUsed > 0)
    {
        for (int ceve = 0; ceve < this->customEventsUsed; ceve++)
        {
            if (this->customEventsTicksLeft[ceve] == 0)
            {
                foundSlot = true;
                addToSlot = ceve;
                break;
            }
        }
    } else {
        foundSlot = true;
        assert(addToSlot == 0);
    }

    if (foundSlot)
    {
        assert(addToSlot >= 0 && addToSlot < SCRIPTABLEAIDIRECTCONTROL_MAX_CUSTOM_EVENTS);

        int slen = strlen(customEventName);

        this->customEventsTicksLeft[addToSlot] = afterTicks;
        this->customEventsName[addToSlot] = new char[slen + 1];
        strcpy(this->customEventsName[addToSlot], customEventName);

        if (this->customEventsUsed < addToSlot + 1)
            this->customEventsUsed = addToSlot + 1;
    } else {
        LOG_WARNING_W_DEBUG("ScriptableAIDirectControl::addCustomEvent - Failed to add custom event, maximum amount reached.", customEventName);
    }
}