Skip to content

Commit

Permalink
Fixed asynchronous initialization issue sometimes breaking inflatables.
Browse files Browse the repository at this point in the history
  • Loading branch information
naelstrof committed Apr 3, 2023
1 parent d605ec7 commit 201b568
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 157 deletions.
1 change: 0 additions & 1 deletion .idea/.idea.KoboldKare/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions Assets/KoboldKare/Input/InputSystem.inputsettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_SupportedDevices: []
m_UpdateMode: 1
m_MaxEventBytesPerUpdate: 5242880
m_MaxQueuedEventsPerUpdate: 1000
m_CompensateForScreenOrientation: 1
m_FilterNoiseOnCurrent: 0
m_DefaultDeadzoneMin: 0.125
m_BackgroundBehavior: 0
m_EditorInputBehaviorInPlayMode: 0
m_DefaultDeadzoneMin: 0.15
m_DefaultDeadzoneMax: 0.925
m_DefaultButtonPressPoint: 0.5
m_ButtonReleaseThreshold: 0.75
m_DefaultTapTime: 0.2
m_DefaultSlowTapTime: 0.5
m_DefaultHoldTime: 0.4
m_TapRadius: 5
m_MultiTapDelayTime: 0.75
m_DisableRedundantEventsMerging: 0
m_ShortcutKeysConsumeInputs: 0
m_iOSSettings:
m_MotionUsage:
m_Enabled: 0
m_Description:
3 changes: 1 addition & 2 deletions Assets/KoboldKare/Prefabs/GameManager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -23582,7 +23582,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 24.003448, y: 0}
m_AnchoredPosition: {x: 24.003418, y: 0}
m_SizeDelta: {x: -48, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3753642555959241819
Expand Down Expand Up @@ -27283,7 +27283,6 @@ MonoBehaviour:
- {fileID: 4175952421401704699}
- {fileID: 6253755554306497515}
- {fileID: 8173450064372538864}
- {fileID: 0}
enabledObjectsOffLevel:
- {fileID: 204055067210610296}
- {fileID: 4468076400065107710}
Expand Down
185 changes: 49 additions & 136 deletions Assets/KoboldKare/Scenes/MainMap.unity
Original file line number Diff line number Diff line change
Expand Up @@ -36117,53 +36117,6 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 252555575}
m_PrefabAsset: {fileID: 0}
--- !u!28 &253930760
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Lightning_PositionMap
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 2
m_Width: 8
m_Height: 1
m_CompleteImageSize: 128
m_MipsStripped: 0
m_TextureFormat: 20
m_MipCount: 1
m_IsReadable: 1
m_IsPreProcessed: 0
m_IgnoreMasterTextureLimit: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_VTOnly: 0
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 0
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
m_PlatformBlob:
image data: 128
_typelessdata: 9af967c3f0522742d6c32c430000803f736868c3fb292c42e07a2e430000803ff8136ac380152a42d6632d430000803f21f06ac3420b304270fd2a430000803f4a8c67c361903742f5282b430000803f879664c394c33142d6632e430000803fd90e63c3d2cd314214ee2c430000803f540365c3d24d2742a9d12c430000803f
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
--- !u!1001 &254456398
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -84560,6 +84513,53 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c5beb188c177b05468cc3ee1964cff66, type: 3}
--- !u!28 &572623691
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Lightning_PositionMap
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 2
m_Width: 8
m_Height: 1
m_CompleteImageSize: 128
m_MipsStripped: 0
m_TextureFormat: 20
m_MipCount: 1
m_IsReadable: 1
m_IsPreProcessed: 0
m_IgnoreMasterTextureLimit: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_VTOnly: 0
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 0
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
m_PlatformBlob:
image data: 128
_typelessdata: 9af967c3f0522742d6c32c430000803f736868c3fb292c42e07a2e430000803ff8136ac380152a42d6632d430000803f21f06ac3420b304270fd2a430000803f4a8c67c361903742f5282b430000803f879664c394c33142d6632e430000803fd90e63c3d2cd314214ee2c430000803f540365c3d24d2742a9d12c430000803f
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
--- !u!4 &573029323 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 0a897a71f09377d41bd8acda78636555,
Expand Down Expand Up @@ -294067,7 +294067,6 @@ GameObject:
m_Component:
- component: {fileID: 1799684043}
- component: {fileID: 1799684046}
- component: {fileID: 1799684045}
- component: {fileID: 1799684044}
m_Layer: 10
m_Name: LightprobeVolume
Expand Down Expand Up @@ -294141,26 +294140,6 @@ LightProbeGroup:
- {x: 2.1393628, y: 2.5993488, z: 1.9915932}
- {x: 2.039486, y: 5.0973454, z: 1.9976175}
m_Dering: 1
--- !u!114 &1799684045
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1799684042}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fc7eebf330e67854398f83add3b50749, type: 3}
m_Name:
m_EditorClassIdentifier:
horizontalSpacing: 2
verticalSpacing: 2
offsetFromFloor: 0.5
numberOfLayers: 2
fillVolume: 1
followFloor: 1
discardInsideGeometry: 1
drawDebug: 0
--- !u!65 &1799684046
BoxCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -349084,7 +349063,7 @@ PrefabInstance:
type: 3}
propertyPath: m_PropertySheet.m_NamedObject.m_Array.Array.data[0].m_Value
value:
objectReference: {fileID: 253930760}
objectReference: {fileID: 572623691}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 24cf10a9d79cd20439523f1400bc1fce, type: 3}
--- !u!4 &854138841937624099 stripped
Expand Down Expand Up @@ -362805,12 +362784,7 @@ PrefabInstance:
- target: {fileID: 1265477231297206195, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 24.001282
objectReference: {fileID: 0}
- target: {fileID: 1348797500760339702, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -50
value: 24.003418
objectReference: {fileID: 0}
- target: {fileID: 1515110291193307783, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
Expand Down Expand Up @@ -362862,11 +362836,6 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2980757906006962752, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 23.999878
objectReference: {fileID: 0}
- target: {fileID: 3143658858329877772, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchorMax.y
Expand Down Expand Up @@ -362917,52 +362886,6 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: managedReferences[-2]
value:
objectReference: {fileID: 0}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: modPostProcessors.Array.size
value: 13
objectReference: {fileID: 0}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: modPostProcessors.Array.data[12]
value: 1602998493153853440
objectReference: {fileID: 0}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: managedReferences[1602998493153853440]
value: Assembly-CSharp PrefabPostProcessor
objectReference: {fileID: 0}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: managedReferences[1602998493153853440].targetDatabase
value:
objectReference: {fileID: 11400000, guid: ab49c41711410144b99911cfd0a26001,
type: 2}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: managedReferences[1602998493153853440].networkedPrefabs
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5619718347981027232, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: managedReferences[1602998493153853440].searchLabel.m_LabelString
value: EquipmentStoreItem
objectReference: {fileID: 0}
- target: {fileID: 5709606446459236606, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 24.00113
objectReference: {fileID: 0}
- target: {fileID: 5884716654018068700, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.9998779
objectReference: {fileID: 0}
- target: {fileID: 7561188790633409797, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_Name
Expand Down Expand Up @@ -363023,11 +362946,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7997126073861605409, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -51.54492
objectReference: {fileID: 0}
- target: {fileID: 8040330175851621591, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchorMax.y
Expand All @@ -363053,11 +362971,6 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8040330177303624220, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 15.999603
objectReference: {fileID: 0}
- target: {fileID: 8040330177608225058, guid: 364d21a5e4c0c464784d42f01767a083,
type: 3}
propertyPath: m_AnchorMax.y
Expand Down
1 change: 1 addition & 0 deletions Assets/KoboldKare/Scripts/CharacterDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void InitializePreEnable() {
}

kobold = GetComponent<Kobold>();
kobold.Initialize();
body.mass = 25f;
body.drag = 0f;
body.angularDrag = 10f;
Expand Down
23 changes: 13 additions & 10 deletions Assets/KoboldKare/Scripts/Kobold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ public override void SetGenes(KoboldGenes newGenes) {
energyChanged?.Invoke(energy, newGenes.maxEnergy);
base.SetGenes(newGenes);
}
private void Awake() {

public void Initialize() {
if (initialized) {
return;
}

initialized = true;
usableColliderComparer = new UsableColliderComparer();
consumedReagents = new ReagentContents();
Expand All @@ -335,11 +335,6 @@ private void Awake() {
metabolizedContents = new ReagentContents(20f);
bellyContainer.maxVolume = 20f;
photonView.ObservedComponents.Add(bellyContainer);
bellyInflater.OnEnable();
sizeInflater.OnEnable();
boobsInflater.OnEnable();
fatnessInflater.OnEnable();
milkLactator.Awake();

if (tummyGrumbleSource == null) {
tummyGrumbleSource = hip.gameObject.AddComponent<AudioSource>();
Expand All @@ -361,6 +356,11 @@ private void Awake() {
gargleSource.loop = true;
}
bellyInflater.AddListener(new InflatableSoundPack(tummyGrumbles, tummyGrumbleSource, this));
bellyInflater.OnEnable();
sizeInflater.OnEnable();
boobsInflater.OnEnable();
fatnessInflater.OnEnable();
milkLactator.Awake();
}

void Start() {
Expand Down Expand Up @@ -568,11 +568,15 @@ public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
}

public void OnPhotonInstantiate(PhotonMessageInfo info) {
Awake();
GameManager.StartCoroutineStatic(WaitUntilReadyThenInstantiate(info));
}

private IEnumerator WaitUntilReadyThenInstantiate(PhotonMessageInfo info) {
yield return new WaitUntil(() => initialized);
if (info.photonView.InstantiationData == null) {
SetGenes(new KoboldGenes().Randomize(gameObject.name));
spawned?.Invoke(this);
return;
yield break;
}

if (info.photonView.InstantiationData.Length > 0 && info.photonView.InstantiationData[0] is BitBuffer) {
Expand All @@ -584,7 +588,6 @@ public void OnPhotonInstantiate(PhotonMessageInfo info) {
} else {
SetGenes(new KoboldGenes().Randomize(gameObject.name));
}

spawned?.Invoke(this);
}

Expand Down
10 changes: 4 additions & 6 deletions Assets/KoboldKare/Scripts/LevelFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@

public class LevelFilter : MonoBehaviour {
public string sceneName;
public List<GameObject> enabledObjectsOnLevel = new List<GameObject>();
public List<GameObject> enabledObjectsOffLevel = new List<GameObject>();
private void Awake() {
SceneManager.sceneLoaded += OnLevelFinishedLoading;
}
private void OnDestroy() {
public List<GameObject> enabledObjectsOnLevel;
public List<GameObject> enabledObjectsOffLevel;
private void OnDisable() {
SceneManager.sceneLoaded -= OnLevelFinishedLoading;
}
private void OnEnable() {
SceneManager.sceneLoaded += OnLevelFinishedLoading;
OnLevelFinishedLoading(SceneManager.GetActiveScene(), LoadSceneMode.Additive);
}
private void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode) {
Expand Down

0 comments on commit 201b568

Please sign in to comment.