Skip to content

Commit

Permalink
Merge pull request #14 from DerpyNewbie/feature/pickup-event-invoker-all
Browse files Browse the repository at this point in the history
Add PickupEventType.All for PickupEventInvoker
  • Loading branch information
DerpyNewbie authored Nov 3, 2024
2 parents bfd8b5f + a76db0d commit a6cf58c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 8
Data: 9
- Name:
Entry: 7
Data:
Expand Down Expand Up @@ -525,6 +525,54 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _lastEventType
- Name: $v
Entry: 7
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _lastEventType
- Name: <UserType>k__BackingField
Entry: 9
Data: 27
- Name: <SystemType>k__BackingField
Entry: 9
Data: 28
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,49 @@ namespace DerpyNewbie.Common.Invoker
{
public class PickupEventInvoker : CommonInvokerBase
{
[SerializeField]
private PickupEventType eventType;
[SerializeField]
private bool overrideEventAsActualPickupEvent = true;
[SerializeField] private PickupEventType eventType = PickupEventType.All;
[SerializeField] private bool overrideEventAsActualPickupEvent = true;

private PickupEventType _lastEventType;

public override void OnPickup()
{
if (eventType == PickupEventType.OnPickup)
Invoke();
if (eventType != PickupEventType.OnPickup && eventType != PickupEventType.All) return;

_lastEventType = PickupEventType.OnPickup;
Invoke();
}

public override void OnPickupUseDown()
{
if (eventType == PickupEventType.OnPickupUseDown)
Invoke();
if (eventType != PickupEventType.OnPickupUseDown && eventType != PickupEventType.All) return;

_lastEventType = PickupEventType.OnPickupUseDown;
Invoke();
}

public override void OnPickupUseUp()
{
if (eventType == PickupEventType.OnPickupUseUp)
Invoke();
if (eventType != PickupEventType.OnPickupUseUp && eventType != PickupEventType.All) return;

_lastEventType = PickupEventType.OnPickupUseUp;
Invoke();
}

public override void OnDrop()
{
if (eventType == PickupEventType.OnDrop)
Invoke();
if (eventType != PickupEventType.OnDrop && eventType != PickupEventType.All) return;

_lastEventType = PickupEventType.OnDrop;
Invoke();
}

protected override void InternalInvoke()
{
if (overrideEventAsActualPickupEvent)
{
foreach (var listener in listeners)
_SendCallbackEvent(listener, eventType);
_SendCallbackEvent(listener, _lastEventType);
}
else
{
Expand Down Expand Up @@ -132,6 +140,7 @@ public enum PickupEventType
OnPickup,
OnPickupUseDown,
OnPickupUseUp,
OnDrop
OnDrop,
All,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ GameObject:
- component: {fileID: 1444180818789127613}
- component: {fileID: 1444180818789126720}
- component: {fileID: 1444180818789126728}
- component: {fileID: 1444180818789126723}
- component: {fileID: 1444180818789126722}
- component: {fileID: 1444180818789126731}
- component: {fileID: 1444180818789126730}
- component: {fileID: 1444180818789126725}
- component: {fileID: 1444180818789126724}
- component: {fileID: 1444180818789126727}
- component: {fileID: 1444180818789126726}
m_Layer: 13
Expand Down Expand Up @@ -119,177 +113,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
AllowCollisionOwnershipTransfer: 1
--- !u!114 &1444180818789126723
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1444180818789127615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cdbe3e35668bb6a48bdd4a11a998f9ff, type: 3}
m_Name:
m_EditorClassIdentifier:
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 1444180818789126722}
listeners:
- {fileID: 1444180820046226549}
eventName: _Interact
delay: 0
timing: 0
isGlobal: 0
isMasterOnly: 0
eventType: 0
overrideEventAsActualPickupEvent: 1
--- !u!114 &1444180818789126722
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1444180818789127615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
m_Name:
m_EditorClassIdentifier:
interactTextPlacement: {fileID: 0}
interactText: Use
interactTextGO: {fileID: 0}
proximity: 2
SynchronizePosition: 0
AllowCollisionOwnershipTransfer: 0
Reliable: 0
_syncMethod: 2
serializedProgramAsset: {fileID: 11400000, guid: f8285b051312b6f4cbf87eb514da940b,
type: 2}
programSource: {fileID: 11400000, guid: 43daf4bb0e859314cb4fd19b3cd7cc4a, type: 2}
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAc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wAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
publicVariablesUnityEngineObjects: []
publicVariablesSerializationDataFormat: 0
--- !u!114 &1444180818789126731
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1444180818789127615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cdbe3e35668bb6a48bdd4a11a998f9ff, type: 3}
m_Name:
m_EditorClassIdentifier:
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 1444180818789126730}
listeners:
- {fileID: 1444180820046226549}
eventName: _Interact
delay: 0
timing: 0
isGlobal: 0
isMasterOnly: 0
eventType: 3
overrideEventAsActualPickupEvent: 1
--- !u!114 &1444180818789126730
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1444180818789127615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
m_Name:
m_EditorClassIdentifier:
interactTextPlacement: {fileID: 0}
interactText: Use
interactTextGO: {fileID: 0}
proximity: 2
SynchronizePosition: 0
AllowCollisionOwnershipTransfer: 0
Reliable: 0
_syncMethod: 2
serializedProgramAsset: {fileID: 11400000, guid: f8285b051312b6f4cbf87eb514da940b,
type: 2}
programSource: {fileID: 11400000, guid: 43daf4bb0e859314cb4fd19b3cd7cc4a, type: 2}
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBh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E4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
publicVariablesUnityEngineObjects: []
publicVariablesSerializationDataFormat: 0
--- !u!114 &1444180818789126725
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1444180818789127615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cdbe3e35668bb6a48bdd4a11a998f9ff, type: 3}
m_Name:
m_EditorClassIdentifier:
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 1444180818789126724}
listeners:
- {fileID: 1444180820046226549}
eventName: _Interact
delay: 0
timing: 0
isGlobal: 0
isMasterOnly: 0
eventType: 1
overrideEventAsActualPickupEvent: 1
--- !u!114 &1444180818789126724
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1444180818789127615}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
m_Name:
m_EditorClassIdentifier:
interactTextPlacement: {fileID: 0}
interactText: Use
interactTextGO: {fileID: 0}
proximity: 2
SynchronizePosition: 0
AllowCollisionOwnershipTransfer: 0
Reliable: 0
_syncMethod: 2
serializedProgramAsset: {fileID: 11400000, guid: f8285b051312b6f4cbf87eb514da940b,
type: 2}
programSource: {fileID: 11400000, guid: 43daf4bb0e859314cb4fd19b3cd7cc4a, type: 2}
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
publicVariablesUnityEngineObjects: []
publicVariablesSerializationDataFormat: 0
--- !u!114 &1444180818789126727
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -319,7 +142,7 @@ MonoBehaviour:
timing: 0
isGlobal: 0
isMasterOnly: 0
eventType: 2
eventType: 4
overrideEventAsActualPickupEvent: 1
--- !u!114 &1444180818789126726
MonoBehaviour:
Expand Down

0 comments on commit a6cf58c

Please sign in to comment.