void ASFireWeapon::Use() { ASWeapon::Use(); if (CanBeUsed()) { TArray<AActor*> damageReceivers; TArray<FHitResult> hits; GetTracedActors(damageReceivers, hits); if (damageReceivers.Num() > 0) { //Successful, and hit an Actor AActor* actorHit = damageReceivers[0]; FHitResult *hit = &hits[0]; OnSuccessfulWeaponUse(actorHit, true, hit->Location); //If the actor is a damage receiver, damage it IDamageReceiver* dmgReceiver = Cast<IDamageReceiver>(actorHit); if (dmgReceiver) dmgReceiver->ReceiveDamage(this, damage); } else OnSuccessfulWeaponUse(nullptr, false, FVector::ZeroVector); //Successful, but didnt hit any Actor NotifyWeaponUsed(); //Notify ASWeapon it has been really used (reset rate of fire time handler) --currentAmmo; } else //Weapon can NOT Be Used { OnNotSuccessfulWeaponUse(); } }
GrAAHairLinePathRenderer::GrAAHairLinePathRenderer( const GrContext* context, const GrIndexBuffer* linesIndexBuffer, const GrIndexBuffer* quadsIndexBuffer) { GrAssert(CanBeUsed(context)); fLinesIndexBuffer = linesIndexBuffer; linesIndexBuffer->ref(); fQuadsIndexBuffer = quadsIndexBuffer; quadsIndexBuffer->ref(); this->resetGeom(); }
GrPathRenderer* GrAAHairLinePathRenderer::Create(GrContext* context) { if (CanBeUsed(context)) { const GrIndexBuffer* lIdxBuffer = context->getQuadIndexBuffer(); if (NULL == lIdxBuffer) { return NULL; } GrGpu* gpu = context->getGpu(); GrIndexBuffer* qIdxBuf = gpu->createIndexBuffer(kQuadIdxSBufize, false); SkAutoTUnref<GrIndexBuffer> qIdxBuffer(qIdxBuf); // cons will take a ref if (NULL == qIdxBuf || !push_quad_index_data(qIdxBuffer.get())) { return NULL; } return new GrAAHairLinePathRenderer(context, lIdxBuffer, qIdxBuf); } else { return NULL; } }