Example #1
0
void CFireMode::UpdateMannequinTags(bool enable)
{
	IActionController* pActionController = m_pWeapon->GetActionController();
	if (pActionController)
	{
		const uint32 firemodeCrC = CCrc32::ComputeLowercase(m_fireParams->fireparams.tag.c_str());
		if (firemodeCrC)
		{
			SAnimationContext& animationContext = pActionController->GetContext();
			animationContext.state.SetByCRC(firemodeCrC, enable);
		}
	}
}
Example #2
0
//------------------------------------------------------------------------
int CItem::GetFragmentID(const char* actionName, const CTagDefinition** tagDef)
{
    int fragmentID = FRAGMENT_ID_INVALID;

    IActionController *pActionController = GetActionController();
    if (pActionController)
        {
            SAnimationContext &animContext = pActionController->GetContext();
            fragmentID = animContext.controllerDef.m_fragmentIDs.Find(actionName);

            if(tagDef && fragmentID != FRAGMENT_ID_INVALID)
                {
                    *tagDef = animContext.controllerDef.GetFragmentTagDef(fragmentID);
                }
        }

    return fragmentID;
}
Example #3
0
void CVehicleWeapon::UpdateCurrentActionController()
{
	IActionController* pActionController = m_pItemActionController;
	if(!pActionController)
	{
		if(IVehicle* pVehicle = GetVehicle())
		{
			if(pActionController = pVehicle->GetAnimationComponent().GetActionController())
			{
				// Set the PlayMode group flag on the context.
				SAnimationContext &animContext = pActionController->GetContext();
				const SMannequinVehicleParams* pParams = GetMannequinUserParams<SMannequinVehicleParams>(animContext);
				animContext.state.SetGroup(pParams->tagGroupIDs.playMode, gEnv->bMultiplayer ? pParams->tagIDs.MP : pParams->tagIDs.SP);
			}
		}
	}
	SetCurrentActionController(pActionController);
}
Example #4
0
// ----------------------------------------------------------------------------
const char* CMannequinAGState::GetCurrentStateName()
{
	const char* result = "<unknown>";

	// Figure out something which could pose as a 'state name'
	// Currently it's the name of the first fragmentID I can find on the scopes
	IActionController* pActionController = GetActionController();
	if (!pActionController)
		return result;

	for(int scopeIndex = 0; scopeIndex < pActionController->GetTotalScopes(); ++scopeIndex)
	{
		IScope* pScope = pActionController->GetScope(scopeIndex);
		FragmentID fragmentID = pScope->GetLastFragmentID();
		if (fragmentID != FRAGMENT_ID_INVALID)
		{
			result = pActionController->GetContext().controllerDef.m_fragmentIDs.GetTagName(fragmentID);
			break;
		}
	}

	return result ;
}
Example #5
0
//------------------------------------------------------------------------
_smart_ptr<IAction> CItem::PlayAction(FragmentID action, int layer, bool loop, uint32 flags, float speedOverride, float animWeigth, float ffeedbackWeight)
{
    _smart_ptr<IAction> pAction;

    const CWeapon* pWeapon = static_cast<CWeapon*>(GetIWeapon());
    if (pWeapon && pWeapon->IsProxyWeapon())
        {
            return pAction;
        }

    IActionController* pActionController = GetActionController();

    if (pActionController && action != FRAGMENT_ID_INVALID)
        {
            SAnimationContext& animContext = pActionController->GetContext();
            const CTagDefinition* pTagDefinition = animContext.controllerDef.GetFragmentTagDef(action);
            float timeOverride = -1.0f;

            bool concentratedFire = (flags&eIPAF_ConcentratedFire) != 0;

            TagState actionTags = TAG_STATE_EMPTY;

            if (pTagDefinition)
                {
                    CTagState fragTags(*pTagDefinition);

                    SetFragmentTags(fragTags);
                    actionTags = fragTags.GetMask();
                }

            pAction = new CItemAction(PP_PlayerAction, action, actionTags);

            PlayFragment(pAction, speedOverride, timeOverride, animWeigth, ffeedbackWeight, concentratedFire);
        }

    return pAction;
}
Example #6
0
void CHeavyMountedWeapon::FinishRipOff()
{
	m_rippingOff = false;
	m_rippedOff = true;
	
	RemoveViewLimits();

	if(IsClient() && gEnv->pGame->GetIGameFramework()->GetClientActorId()==GetOwnerId())
	{
		if(IEntity* pEntity = GetEntity())
		{
			const char* collectibleId = pEntity->GetClass()->GetName();
			CPersistantStats* pStats = g_pGame->GetPersistantStats();
			if(pStats && pStats->GetStat(collectibleId, EMPS_SPWeaponByName) == 0)
			{
				pStats->SetMapStat(EMPS_SPWeaponByName, collectibleId, eDatabaseStatValueFlag_Available);

				if(!gEnv->bMultiplayer)
				{
					// Show hud unlock msg
					SHUDEventWrapper::DisplayWeaponUnlockMsg(collectibleId);
				}
			}
		}
	}

	CActor* pOwner = GetOwnerActor();
	IActionController* pController = pOwner ? pOwner->GetAnimatedCharacter()->GetActionController() : NULL;
	if(pController)
	{
		CMannequinUserParamsManager& mannequinUserParams = g_pGame->GetIGameFramework()->GetMannequinInterface().GetMannequinUserParamsManager();
		const SMannequinItemParams* pParams = mannequinUserParams.FindOrCreateParams<SMannequinItemParams>(pController);

		UpdateMountedTags(pParams, pController->GetContext().state, true);
	}
}
Example #7
0
// ----------------------------------------------------------------------------
bool CMannequinAGState::SetActionOrSignalInput(_smart_ptr<CAnimActionAGAction>& pAction, TKeyValue& currentValue, InputID inputID, EAIActionType actionType, const char* defaultValue, uint32 defaultValueCRC, const char* value, TAnimationGraphQueryID* pQueryID, bool optional)
{
	IActionController* pActionController = GetActionController();
	if (!pActionController)
		return false;

	// TODO Where to get the priorities from?
	const int MANNEQUIN_PRIORITY = 2; // currently equal to PP_Action, just above movement, but underneath urgent actions, hit death, etc.

	TAnimationGraphQueryID queryID = 0;
	if (pQueryID)
		queryID = *pQueryID = GenerateQueryID();

	const uint32 valueCRC = CCrc32::ComputeLowercase(value);

	static uint32 idleCRC = CCrc32::ComputeLowercase("idle");
	static uint32 noneCRC = CCrc32::ComputeLowercase("none");
	const bool isUnsupportedFragmentID = ((valueCRC == idleCRC) || (valueCRC == noneCRC));
	const FragmentID fragmentID = isUnsupportedFragmentID ? FRAGMENT_ID_INVALID : pActionController->GetContext().controllerDef.m_fragmentIDs.Find(valueCRC);

	const bool isDefaultValue = (valueCRC == defaultValueCRC);

	const bool somethingIsPendingOrInstalled = pAction && pAction->IsPendingOrInstalled();

	if (isDefaultValue)
	{
		if ( actionType == EAT_Looping )
		{
			StopAnyLoopingExactPositioningAction();
		}

		const bool isPendingOrInstalled = !somethingIsPendingOrInstalled; // the fake action 'idle' isPendingOrInstalled if something else is NOT pending or installed
		if (isPendingOrInstalled)
		{
			// In the old sense: the current requested 'value' did not change, we were already 'idle'
			SendEvent_Entered(NULL, queryID, true);
		}
		else
		{
			currentValue = defaultValue;

			if (pAction)
			{
				pAction->Stop(); // this will eventually call Entered(..,false) of the user that was waiting on Entered()
				pAction = NULL;
			}

			// TODO: This is not entirely correct. The Entered() event for the idle action should only
			//   be called when you exactly "go back to idle". But this is not well defined in mannequin,
			//   so I just send it right away...
			SendEvent_Entered(NULL, queryID, true);

			SendEvent_ChangedInput(inputID, true); // tell whoever is listening to the input that it changed
		}

		return true;
	}
	else if (fragmentID != FRAGMENT_ID_INVALID)
	{
		const bool isPendingOrInstalled = 
			somethingIsPendingOrInstalled &&
			(pAction->GetValueCRC() == valueCRC);
		if (isPendingOrInstalled)
		{
			// In the old sense: the current requested 'value' did not change
			
			// reuse the old queryid, if there is one, otherwise set the new one
			if (pAction->GetQueryID())
			{
				queryID = pAction->GetQueryID();
				if (pQueryID)
					*pQueryID = queryID;
			}
			else
			{
				if (queryID)
					pAction->SetQueryID(queryID);
			}

			if (pAction->GetStatus() == IAction::Installed)
			{
				// The other system is already playing the same action.
				// Send the 'entered' event immediately
				// (afai can see the AG only did this for signals for some reason??)
				SendEvent_Entered(pAction, pAction->GetQueryID(), true);
			}
		}
		else
		{
			currentValue = value;

			pAction = new CAnimActionAGAction(MANNEQUIN_PRIORITY, fragmentID, *this, actionType, value, valueCRC, queryID);
			pActionController->Queue(*pAction.get());

			SendEvent_ChangedInput(inputID, true); // tell whoever is listening the input that it changed
		}

		return true;
	}
	else if (!optional)
	{
		// 'not optional' means invalid values get translated into the default value
		// (so we always set a value, hence the setting of values is 'not optional')
		// Recurse and pass the defaultValue as value:
		return SetActionOrSignalInput(pAction, currentValue, inputID, actionType, defaultValue, defaultValueCRC, defaultValue, NULL, true);
	}
	else
	{
#ifndef _RELEASE
		if(!isUnsupportedFragmentID)
		{
			CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CMannequinAGState::SetInput: Unable to find animation '%s'", value);
		}
#endif //#ifndef _RELEASE
		return false;
	}
}