Files
UnrealEngineUWP/Engine/Source/Runtime/LevelSequence/Private/LevelSequenceObjectReference.cpp
John Pollard f080108579 Copying //UE4/Dev-Networking to //UE4/Main (Source: //UE4/Dev-Networking @3150552 )
==========================
MAJOR FEATURES + CHANGES
==========================

Change 3098408 on 2016/08/23 by Bart.Bressler
	Add IsStandalone blueprint node which returns true if the game is running in standalone

	PR #2109: [KismetSystemLibrary ~ Networking] New BP Node! Is Stand Alone  ? Rama (Contributed by EverNewJoy)

	#rb ryan.gerleve
	#tests added bluprint node to blueprint in test project and made sure it worked

Change 3101070 on 2016/08/25 by Bart.Bressler
	Exposed replication condition property flags to blueprints.

	PR #1355: Exposed "Replicate to Owner Only" for variables to Blueprints (dropdown) (Contributed by CodeSpartan)

	#rb ryan.gerleve

Change 3102934 on 2016/08/26 by Josh.Markiewicz
	#UE4 - fixed automation mistake that removes test data from test builds and adds it to shipping builds
	#codereview nick.darnell, alexis.matte
	#rb none

Change 3116738 on 2016/09/07 by John.Pollard

	Shared replication shadow state initial pass

	* Use a change list mgr to accumulate changes for a particular actor
	* Each connection will then re-use this information so that compares only happen at most once per frame/actor.
	* The enire history of changes for the actor are saved for the entire life of the actor
	* When the history starts to fill up, start merging older ones
	* JIP players will get entire history
	* Reset connection viewers after we're done with it

	#rb RyanG

Change 3123101 on 2016/09/13 by John.Pollard

	More efficiently process replayout commands

	* We used to iterate over every cmd even with small changelists
	* Now we only touch the absolute necessary cmds
	* Introduced FChangelistIterator that makes it easy to iterate over changelists
	* Introduced FRepHandleIterator, which allows you to convert a changelist of handles to CmdIndex, ArrayIndex, etc
	* FRepHandleIterator handles array and cmd index list bounds checking
	* Converted SentProperties and SendProperties_BackwardsCompatible to use the new FRepHandleIterator
	* Made explicit SendAllProperties_BackwardsCompatible since it was no longer easy to re-use implementation of SendProperties_BackwardsCompatible for this
	* Optimized changelist merging to use pruning when possible

	#rb RyanG

Change 3123589 on 2016/09/13 by John.Pollard

	Fix UE-35757 - Resources do not show a health bar when they're being damaged

	#rb none

Change 3130333 on 2016/09/19 by John.Pollard

	Fix replay backwards compatibility crash

	#rb DavidR

Change 3134499 on 2016/09/21 by Ryan.Gerleve

	Engine changes to support multiple "collections" of levels in a single world, the ability to duplicate the dynamic levels in a world at load time, and the ability to play back a replay in the duplicated levels without interfering with the original ones.

	#rb john.pollard, marc.audy, gil.gribb

Change 3134771 on 2016/09/21 by Ryan.Gerleve

	Missing file for 3134499.

	#rb none

Change 3134948 on 2016/09/21 by John.Pollard

	Fix CIS

	#rb RyanG

Change 3135279 on 2016/09/21 by Ryan.Gerleve

	Fix initialization order warning

	#rb none

Change 3137140 on 2016/09/22 by Ryan.Gerleve

	Fix static analysis warning

	#rb john.pollard

Change 3137886 on 2016/09/23 by John.Pollard

	Fix mismatch in replay backwards compatibility property serialization

	* Fixed a bug where we were writing out an extra handle when the array size was 0
	* Added extra sanity checks when reading arrays to check index bounds
	* Added asserts to verify that we actually have elemements in replicated arrays

	#rb BartB

Change 3138081 on 2016/09/23 by Ryan.Gerleve

	Explicity remove a level from its collection in BeginDestroy.

	#rb john.pollard
	#jira UE-36366

Change 3138768 on 2016/09/23 by Bart.Bressler

	Enable world origin rebasing for multiplayer. It can be enabled in projects in network project settings.

	PR #2359: UE-13079: World Origin Shifting for Multiplayer (Contributed by michail-nikolaev)

	#rb dmitriy.dyomin, zak.middleton

Change 3140413 on 2016/09/26 by Ryan.Gerleve

	Fix for crash during cooking

	#rb john.pollard
	#jira UE-36376

Change 3142515 on 2016/09/27 by Ryan.Gerleve

	Paragon code to use the single-world deathcam implementation and related fixes.

	#rb david.ratti, john.pollard

Change 3146799 on 2016/09/30 by John.Pollard

	Fix UE-36634: Logspam after rejoining LogOrion:Warning: AOrionPickupManager::TickPickups - SpawnedPickups

	* We now pass in bNetInitial to the compare function
	* We force compares when bNetInitial is true
	* We no longer compare properties that don't have the lifetime flag (weren't registered via DOREPLIFETIME

	#rb RyanG

Change 3147049 on 2016/09/30 by John.Pollard

	Fix UE-36635 - Crash when slotting upgrades quickly in cardshop

	#rb None
	#codereview Ryan.Gerleve

Change 3148296 on 2016/10/02 by John.Pollard

	Merging //UE4/Dev-Main to Dev-Networking (//UE4/Dev-Networking)

	#rb none

Change 3148816 on 2016/10/03 by Bart.Bressler

	Implement "Play Together" PS4 feature in Shooter Game

	#codereview marcus.wassmer, sam.zamani
	#rb john.pollard

Change 3149279 on 2016/10/03 by Bart.Bressler
	PS4 Play Together compile fix

	#rb none

Change 3150142 on 2016/10/04 by Ryan.Gerleve

	Remove reference to "deathcam" from a comment in engine code

	#rb none

#lockdown Nick.Penwarden

[CL 3150558 by John Pollard in Main branch]
2016-10-04 13:45:37 -04:00

139 lines
3.5 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "LevelSequencePCH.h"
#include "LevelSequenceObjectReference.h"
FLevelSequenceObjectReference::FLevelSequenceObjectReference(UObject* InObject, UObject* InContext)
{
if (InObject->IsA<AActor>() || InObject->IsA<UActorComponent>())
{
if (InContext->IsA<AActor>())
{
// When the context is an actor, we only use path name lookup within the actor since it's assumed the actor will be a spawnable
// As such, a persistent identifier for a dynamically spawned actor is not tenable
ObjectPath = InObject->GetPathName(InContext);
ObjectId = FUniqueObjectGuid();
}
else
{
ObjectId = FLazyObjectPtr(InObject).GetUniqueID();
ObjectPath = InObject->GetPathName(InContext);
}
}
}
FLevelSequenceObjectReference::FLevelSequenceObjectReference(const FUniqueObjectGuid& InObjectId, const FString& InObjectPath)
: ObjectId(InObjectId)
, ObjectPath(InObjectPath)
{
}
UObject* FLevelSequenceObjectReference::Resolve(UObject* InContext) const
{
if (ObjectId.IsValid() && InContext != nullptr)
{
int32 PIEInstanceID = InContext->GetOutermost()->PIEInstanceID;
FUniqueObjectGuid FixedUpId = PIEInstanceID == -1 ? ObjectId : ObjectId.FixupForPIE(PIEInstanceID);
FLazyObjectPtr LazyPtr;
LazyPtr = FixedUpId;
if (UObject* FoundObject = LazyPtr.Get())
{
return FoundObject;
}
}
if (!ObjectPath.IsEmpty())
{
return FindObject<UObject>(InContext, *ObjectPath, false);
}
return nullptr;
}
bool FLevelSequenceObjectReferenceMap::Serialize(FArchive& Ar)
{
int32 Num = Map.Num();
Ar << Num;
if (Ar.IsLoading())
{
while(Num-- > 0)
{
FGuid Key;
Ar << Key;
FLevelSequenceObjectReference Value;
Ar << Value;
Map.Add(Key, Value);
}
}
else if (Ar.IsSaving() || Ar.IsCountingMemory() || Ar.IsObjectReferenceCollector())
{
for (auto& Pair : Map)
{
Ar << Pair.Key;
Ar << Pair.Value;
}
}
return true;
}
bool FLevelSequenceObjectReferenceMap::HasBinding(const FGuid& ObjectId) const
{
if (const FLevelSequenceObjectReference* Reference = Map.Find(ObjectId))
{
return Reference->IsValid();
}
return false;
}
void FLevelSequenceObjectReferenceMap::CreateBinding(const FGuid& ObjectId, UObject* InObject, UObject* InContext)
{
FLevelSequenceObjectReference NewReference(InObject, InContext);
if (ensureMsgf(NewReference.IsValid(), TEXT("Unable to generate a reference for the specified object and context")))
{
Map.FindOrAdd(ObjectId) = NewReference;
}
}
void FLevelSequenceObjectReferenceMap::CreateBinding(const FGuid& ObjectId, const FLevelSequenceObjectReference& ObjectReference)
{
if (ensureMsgf(ObjectReference.IsValid(), TEXT("Invalid object reference specifed for binding")))
{
Map.FindOrAdd(ObjectId) = ObjectReference;
}
}
void FLevelSequenceObjectReferenceMap::RemoveBinding(const FGuid& ObjectId)
{
Map.Remove(ObjectId);
}
UObject* FLevelSequenceObjectReferenceMap::ResolveBinding(const FGuid& ObjectId, UObject* InContext) const
{
const FLevelSequenceObjectReference* Reference = Map.Find(ObjectId);
UObject* ResolvedObject = Reference ? Reference->Resolve(InContext) : nullptr;
if (ResolvedObject != nullptr)
{
// if the resolved object does not have a valid world (e.g. world is being torn down), dont resolve
return ResolvedObject->GetWorld() != nullptr ? ResolvedObject : nullptr;
}
return nullptr;
}
FGuid FLevelSequenceObjectReferenceMap::FindBindingId(UObject* InObject, UObject* InContext) const
{
for (const auto& Pair : Map)
{
if (Pair.Value.Resolve(InContext) == InObject)
{
return Pair.Key;
}
}
return FGuid();
}