当前位置: 首页>>代码示例>>C++>>正文


C++ Ship::GetHangar方法代码示例

本文整理汇总了C++中Ship::GetHangar方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::GetHangar方法的具体用法?C++ Ship::GetHangar怎么用?C++ Ship::GetHangar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ship的用法示例。


在下文中一共展示了Ship::GetHangar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindShipByObjID

void
NetGameClient::DoShipLaunch(NetMsg* msg)
{
	if (!msg) return;

	NetShipLaunch ship_launch;
	ship_launch.Unpack(msg->Data());

	Sim*  sim      = Sim::GetSim();
	int   squadron = ship_launch.GetSquadron();
	int   slot     = ship_launch.GetSlot();

	Ship* carrier = FindShipByObjID(ship_launch.GetObjID());

	if (carrier) {
		Hangar* hangar = carrier->GetHangar();

		if (hangar) {
			hangar->Launch(squadron, slot);
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:22,代码来源:NetGameClient.cpp

示例2: if


//.........这里部分代码省略.........
                ClearRadioOrders();
            }
            break;

        case RadioMessage::ESCORT:
        case RadioMessage::COVER_ME:
            {
                SimObject* tgt = orders->GetTarget();
                if (tgt && tgt->Type() == SimObject::SIM_SHIP) {
                    roe = DEFENSIVE;
                    ship_ai->SetWard((Ship*) tgt);
                    ship_ai->SetNavPoint(0);
                }
                else {
                    ClearRadioOrders();
                }
            }
            break;

        case RadioMessage::WEP_FREE:
            roe = AGRESSIVE;
            ship_ai->DropTarget(0.1);
            break;

        case RadioMessage::WEP_HOLD:
        case RadioMessage::FORM_UP:
            roe = NONE;
            ship_ai->DropTarget(5);
            break;

        case RadioMessage::MOVE_PATROL:
            roe = SELF_DEFENSIVE;
            ship_ai->SetPatrol(orders->Location());
            ship_ai->SetNavPoint(0);
            ship_ai->DropTarget(Random(5, 10));
            break;

        case RadioMessage::RTB:
        case RadioMessage::DOCK_WITH:
            roe = NONE;

            ship_ai->DropTarget(10);
            
            if (!ship->GetInbound()) {
                RadioMessage* msg = 0;
                Ship* controller = ship->GetController();

                if (orders->Action() == RadioMessage::DOCK_WITH && orders->GetTarget()) {
                    controller = (Ship*) orders->GetTarget();
                }

                if (!controller) {
                    Element* elem = ship->GetElement();
                    if (elem && elem->GetCommander()) {
                        Element* cmdr = elem->GetCommander();
                        controller    = cmdr->GetShip(1);
                    }
                }

                if (controller && controller->GetHangar() &&
                        controller->GetHangar()->CanStow(ship)) {
                    SimRegion*  self_rgn = ship->GetRegion();
                    SimRegion*  rtb_rgn  = controller->GetRegion();

                    if (self_rgn == rtb_rgn) {
                        double range = Point(controller->Location() - ship->Location()).length();

                        if (range < 50e3) {
                            msg = new(__FILE__,__LINE__) RadioMessage(controller, ship, RadioMessage::CALL_INBOUND);
                            RadioTraffic::Transmit(msg);
                        }
                    }
                }
                else {
                    ship->ClearRadioOrders();
                }

                ship_ai->SetNavPoint(0);
            }
            break;

        case RadioMessage::QUANTUM_TO:
        case RadioMessage::FARCAST_TO:
            roe = NONE;
            ship_ai->DropTarget(10);
            break;

        }

        action = orders->Action();
        return true;
    }

    // if we had an action before, this must be a "cancel orders" 
    else if (action) {
        ClearRadioOrders();
    }

    return false;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:101,代码来源:TacticalAI.cpp

示例3: new

void
NetGameClient::DoElemCreate(NetMsg* msg)
{
	if (!msg) return;

	NetElemCreate elem_create;
	elem_create.Unpack(msg->Data());

	const char* elem_name = elem_create.GetName().data();

	::Print("NetGameClient::DoElemCreate name: %s iff: %d type %s\n",
	elem_name,
	elem_create.GetIFF(),
	Mission::RoleName(elem_create.GetType()));

	Sim*     sim   = Sim::GetSim();
	Element* elem  = sim->FindElement(elem_name);
	if (elem) {
		::Print("  element '%' already exists - ignored\n", elem_name);
		return;
	}

	elem = sim->CreateElement(elem_name,
	elem_create.GetIFF(),
	elem_create.GetType());

	int*     load     = elem_create.GetLoadout();
	int*     slots    = elem_create.GetSlots();
	int      squadron = elem_create.GetSquadron();
	int      code     = elem_create.GetObjCode();
	Text     target   = elem_create.GetObjective();
	bool     alert    = elem_create.GetAlert();
	bool     active   = elem_create.GetInFlight();

	elem->SetIntelLevel(elem_create.GetIntel());
	elem->SetLoadout(load);

	if (code > Instruction::RTB || target.length() > 0) {
		Instruction* obj  = new(__FILE__,__LINE__) Instruction(code, target);
		elem->AddObjective(obj);
	}

	Ship* carrier = sim->FindShip(elem_create.GetCarrier());
	if (carrier) {
		elem->SetCarrier(carrier);

		Hangar* hangar = carrier->GetHangar();
		if (hangar) {
			Text squadron_name = hangar->SquadronName(squadron);
			elem->SetSquadron(squadron_name);

			if (active) {
				for (int i = 0; i < 4; i++) {
					int slot = slots[i];
					if (slot > -1) {
						hangar->GotoActiveFlight(squadron, slot, elem, load);
					}
				}
			}

			else {
				FlightDeck* deck   = 0;
				int         queue  = 1000;

				for (int i = 0; i < carrier->NumFlightDecks(); i++) {
					FlightDeck* d = carrier->GetFlightDeck(i);

					if (d && d->IsLaunchDeck()) {
						int dq = hangar->PreflightQueue(d);

						if (dq < queue) {
							queue = dq;
							deck  = d;
						}
					}
				}

				for (int i = 0; i < 4; i++) {
					int slot = slots[i];
					if (slot > -1) {
						hangar->GotoAlert(squadron, slot, deck, elem, load, !alert);
					}
				}
			}
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:87,代码来源:NetGameClient.cpp


注:本文中的Ship::GetHangar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。