Skip to content

Instantly share code, notes, and snippets.

View dorgonman's full-sized avatar
☯️
inner peace

dorgon chang dorgonman

☯️
inner peace
View GitHub Profile
@dorgonman
dorgonman / wordpress_post1583_03.cpp
Created June 30, 2018 16:21
wordpress_post1583_03.cpp
bool AMyGameModeBase::MustSpectate_Implementation(APlayerController* NewPlayerController) const
{
return false;
}
@dorgonman
dorgonman / wordpress_post1583_02.cpp
Created June 30, 2018 16:20
wordpress_post1583_02.cpp
UFUNCTION(Server, Reliable, WithValidation)
void Server_SpectatorReady();
virtual void Server_SpectatorReady_Implementation();
void ASpectatorTestPlayerController::Server_SpectatorReady_Implementation()
{
auto pGameMode = Cast<AMyGameModeBase>(GetWorld()->GetAuthGameMode());
if (pGameMode)
{
++pGameMode->NumReadySpectator;//pGameMode->OnSpectatorReady();
UE_LOG(LogTemp, Log, TEXT("NumReadySpectator: %d"), pGameMode->NumReadySpectator);
@dorgonman
dorgonman / wordpress_post1583_01.cpp
Created June 30, 2018 16:19
wordpress_post1583_01.cpp
void AMySpectatorPawn::PossessedBy(class AController* NewController)
{
Super::PossessedBy(NewController);
auto pPC = Cast<ASpectatorTestPlayerController>(GetController());
if (pPC)
{
pPC->Server_SpectatorReady();
}
}
@dorgonman
dorgonman / wordpress_post1561_03.cpp
Created June 26, 2018 15:44
wordpress_post1561_03.cpp
bool AActor::IsWithinNetRelevancyDistance(const FVector& SrcLocation) const
{
return FVector::DistSquared(SrcLocation, GetActorLocation()) < NetCullDistanceSquared;
}
@dorgonman
dorgonman / wordpress_post1561_02.cpp
Created June 26, 2018 15:43
wordpress_post1561_02.cpp
int32 UNetDriver::ServerReplicateActors_ProcessPrioritizedActors( UNetConnection* Connection, const TArray<FNetViewer>& ConnectionViewers, FActorPriority** PriorityActors, const int32 FinalSortedCount, int32& OutUpdated )
{
...
// If the actor wasn't recently relevant, or if it was torn off, close the actor channel if it exists for this connection
if ( ( !bIsRecentlyRelevant || Actor->bTearOff ) && Channel != NULL )
{
...
UE_LOG( LogNetTraffic, Log, TEXT( "- Closing channel for no longer relevant actor %s" ), *Actor->GetName() );
Channel->Close();
...
@dorgonman
dorgonman / wordpress_post1561_01.cpp
Created June 26, 2018 15:42
wordpress_post1561_01.cpp
// We have fully received the bunch, so process it.
if( Bunch.bClose )
{
...
UE_LOG(LogNetTraffic, Log, TEXT("UChannel::ReceivedSequencedBunch: Bunch.bClose == true. Calling ConditionalCleanUp. ChIndex: %i"), ChIndex );
ConditionalCleanUp();
...
}
@dorgonman
dorgonman / UE4_GAS_Attribute_Replicate.cpp
Created June 14, 2018 15:45
UE4_GAS_Attribute_Replicate
void UMyHealthSet::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
   DOREPLIFETIME_CONDITION_NOTIFY(UMyHealthSet, Health, COND_None, REPNOTIFY_Always);
}
void UMyHealthSet::OnRep_Health()
{
    GAMEPLAYATTRIBUTE_REPNOTIFY(UMyHealthSet, Health);
}
PredictionKey.NewRejectedDelegate().BindUObject(this, &UAbilitySystemComponent::OnPredictiveMontageRejected, NewAnimMontage);
void UAbilitySystemComponent::OnPredictiveMontageRejected(UAnimMontage* PredictiveMontage)
{
static const float MONTAGE_PREDICTION_REJECT_FADETIME = 0.25f;
UAnimInstance* AnimInstance = AbilityActorInfo.IsValid() ? AbilityActorInfo->GetAnimInstance() : nullptr;
if (AnimInstance && PredictiveMontage)
{
@dorgonman
dorgonman / ue4_build_plugin.sh
Last active March 17, 2018 05:05
ue4_build_plugin
UEBuildPlugin(){
mkdir -p "${PLUGIN_PACKAGE_ARCHIVE_DIR}"
PLUGIN_PACKAGE_ARCHIVE_DIR=$(cd "${PLUGIN_PACKAGE_ARCHIVE_DIR}"; pwd)
echo "-----------------------------------------------------"
echo "UEBuildPlugin: ${PLUGIN_FILE} ${PLUGIN_BUILD_TARGET} to ${PLUGIN_PACKAGE_ARCHIVE_DIR}"
echo "-----------------------------------------------------"
cmd=" \
'${UE4_ENGINE_ROOT}/Engine/Build/BatchFiles/RunUAT.bat' BuildPlugin \
-Plugin='${PLUGIN_FILE}' -TargetPlatforms=${PLUGIN_BUILD_TARGET} \
@dorgonman
dorgonman / cloudSettings
Last active August 25, 2019 15:18
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-08-25T15:18:01.590Z","extensionVersion":"v3.4.2"}