static string GetStateKey(TargetStateTarget target, string key, ItemId itemId) { switch (target) { case TargetStateTarget.Item: return(RoomStateKey.GetItemKey(itemId.Value, key)); case TargetStateTarget.Player: return(RoomStateKey.GetPlayerKey(key)); case TargetStateTarget.Global: return(RoomStateKey.GetGlobalKey(key)); default: throw new NotImplementedException(); } }
bool TryGetKey(ItemTriggerTarget target, IItem senderItem, IItem specifiedTarget, GameObject collidedObject, string triggerKey, out string key) { key = default; switch (target) { case ItemTriggerTarget.This: key = RoomStateKey.GetItemKey(senderItem.Id.Value, triggerKey); return(true); case ItemTriggerTarget.SpecifiedItem: if (specifiedTarget == null) { return(false); } if (specifiedTarget.gameObject == null) { return(false); } key = RoomStateKey.GetItemKey(specifiedTarget.Id.Value, triggerKey); return(true); case ItemTriggerTarget.Owner: key = RoomStateKey.GetPlayerKey(triggerKey); return(true); case ItemTriggerTarget.CollidedItemOrPlayer: if (collidedObject.CompareTag("Player")) { key = RoomStateKey.GetPlayerKey(triggerKey); return(true); } var collidedItem = collidedObject.GetComponentInParent <IItem>(); if (collidedItem != null) { key = RoomStateKey.GetItemKey(collidedItem.Id.Value, triggerKey); return(true); } return(false); case ItemTriggerTarget.Global: key = RoomStateKey.GetGlobalKey(triggerKey); return(true); default: throw new NotImplementedException(); } }