void InfluenceMap::RegisterGameObj(TID objId, PlayerType ownerId)
{
    if (m_registeredObjects.count(objId) == 0)
    {
        RegObjEntry *pNewObj = new RegObjEntry;
        GameEntity *pGameObj = nullptr;
        GameType *pObjType = nullptr;

        pNewObj->ObjId = objId;
        pNewObj->OwnerId = ownerId;
        pNewObj->Stamped = false;

        pGameObj = g_Game->GetPlayer(ownerId)->GetEntity(objId);
        _ASSERTE(pGameObj);
        pNewObj->LastPosition = Vector2(-1, -1);

        pObjType = g_Game->GetEntityType((EntityClassType)pGameObj->TypeId());
        _ASSERTE(pObjType);

        pNewObj->ObjWidth = pObjType->P(TP_Width) + pObjType->P(TP_BuildingExpansionIncrement);
        pNewObj->ObjHeight = pObjType->P(TP_Height);

        m_registeredObjects[objId] = pNewObj;
    }
}
Esempio n. 2
0
void TrainAction::InitializePostConditions()
{
    vector<Expression*> m_terms;
    EntityClassType entityTypeId = (EntityClassType)_params[PARAM_EntityClassId];
    GameType *pGameType = g_Game->GetEntityType(entityTypeId);

    if (!pGameType->P(TP_IsWorker))
    {
        m_terms.push_back(new PlayerAttributeExist(PLAYER_Self, PATTR_AlliedAttackersTotalHP, g_Game->GetEntityType(entityTypeId)->P(TP_MaxHp)));
        m_terms.push_back(new PlayerAttributeExist(PLAYER_Self, PATTR_AlliedAttackersTotalDamage, g_Game->GetEntityType(entityTypeId)->P(TP_GroundAttack)));
    }

    m_terms.push_back(new EntityClassExist(PLAYER_Self, entityTypeId, 1));
    _postCondition = new And(m_terms);
}
void OccupanceDataIM::RegisterGameObj(TID objId, PlayerType ownerId)
{
    if (m_registeredObjects.count(objId) == 0)
        UnregisterGameObj(objId);

    RegObjEntry *pNewObj = new RegObjEntry;
    GameEntity *pGameObj = nullptr;
    GameType *pObjType = nullptr;

    pNewObj->ObjId = objId;
    pNewObj->OwnerId = ownerId;
    pNewObj->Stamped = false;

    pGameObj = g_Game->GetPlayer(ownerId)->GetEntity(objId);
    _ASSERTE(pGameObj);
    pNewObj->LastPosition = Vector2(-1, -1);

    pObjType = g_Game->GetEntityType((EntityClassType)pGameObj->TypeId());
    _ASSERTE(pObjType);

    pNewObj->ObjWidth = pObjType->P(TP_Width) + pObjType->P(TP_BuildingExpansionIncrement);
    pNewObj->ObjHeight = pObjType->P(TP_Height);

    if ((pNewObj->OwnerId == PLAYER_Self &&
        (pObjType->P(TP_IsResoureDepot) ||
        g_Game->Self()->Race()->GetResourceSource(RESOURCE_Secondary) == pGameObj->TypeId())) ||
        pObjType->P(TP_IsSecondaryResource) ||
        pObjType->P(TP_IsPrimaryResource))
    {
        pNewObj->IsAllSidePadded = true;
        pNewObj->PaddingSize = m_cellSide;

        pNewObj->ObjWidth += (2 * pNewObj->PaddingSize);
        pNewObj->ObjHeight += (2 * pNewObj->PaddingSize);
    }

    m_registeredObjects[objId] = pNewObj;
}