private void ProcessAimApply(GameObject handObject, Vector2 targetVector, GameObject processorObj, GameObject performerObj, HandSlot usedSlot, MouseButtonState buttonState) { //try to look up the components on the processor that can handle this interaction var processorComponents = InteractionMessageUtils.TryGetProcessors <AimApply>(processorObj); //invoke each component that can handle this interaction var aimApply = AimApply.ByClient(performerObj, targetVector, handObject, usedSlot, buttonState); foreach (var processorComponent in processorComponents) { if (processorComponent.ServerProcessInteraction(aimApply)) { //something happened, don't check further components return; } } }
public override void Process() { var performer = SentByPlayer.GameObject; if (SentByPlayer == null || SentByPlayer.Script == null || SentByPlayer.Script.ItemStorage == null) { return; } if (InteractionType == typeof(PositionalHandApply)) { //look up item in active hand slot var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(AimApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(MouseDrop)) { LoadMultipleObjects(new uint[] { UsedObject, TargetObject, ProcessorObject }); var usedObj = NetworkObjects[0]; var targetObj = NetworkObjects[1]; var processorObj = NetworkObjects[2]; var interaction = MouseDrop.ByClient(performer, usedObj, targetObj, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandActivate)) { LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; var performerObj = SentByPlayer.GameObject; //look up item in active hand slot var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; var interaction = HandActivate.ByClient(performer, usedObject, usedSlot, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(InventoryApply)) { LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject, Storage }); var processorObj = NetworkObjects[0]; var usedObj = NetworkObjects[1]; var storageObj = NetworkObjects[2]; ItemSlot targetSlot = null; if (SlotIndex == -1) { targetSlot = ItemSlot.GetNamed(storageObj.GetComponent <ItemStorage>(), NamedSlot); } else { targetSlot = ItemSlot.GetIndexed(storageObj.GetComponent <ItemStorage>(), SlotIndex); } //if used object is null, then empty hand was used ItemSlot fromSlot = null; if (usedObj == null) { fromSlot = SentByPlayer.Script.ItemStorage.GetActiveHandSlot(); } else { fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot; } var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(TileApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex, SentByPlayer.GameObject, TargetVector, processorObj, usedSlot, usedObject, Intent, TileApply.ApplyType.HandApply); } else if (InteractionType == typeof(TileMouseDrop)) { LoadMultipleObjects(new uint[] { UsedObject, ProcessorObject }); var usedObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex, SentByPlayer.GameObject, TargetVector, processorObj, null, usedObj, Intent, TileApply.ApplyType.MouseDrop); } }
public override IEnumerator Process() { var performer = SentByPlayer.GameObject; if (InteractionType == typeof(PositionalHandApply)) { //look up item in active hand slot var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; yield return(WaitFor(TargetObject, ProcessorObject)); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; yield return(WaitFor(TargetObject, ProcessorObject)); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(AimApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; yield return(WaitFor(ProcessorObject)); var processorObj = NetworkObject; var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(MouseDrop)) { yield return(WaitFor(UsedObject, TargetObject, ProcessorObject)); var usedObj = NetworkObjects[0]; var targetObj = NetworkObjects[1]; var processorObj = NetworkObjects[2]; var interaction = MouseDrop.ByClient(performer, usedObj, targetObj); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandActivate)) { yield return(WaitFor(ProcessorObject)); var processorObj = NetworkObject; var performerObj = SentByPlayer.GameObject; //look up item in active hand slot var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; var interaction = HandActivate.ByClient(performer, usedObject, usedSlot); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(InventoryApply)) { yield return(WaitFor(ProcessorObject, UsedObject, Storage)); var processorObj = NetworkObjects[0]; var usedObj = NetworkObjects[1]; var storageObj = NetworkObjects[2]; ItemSlot targetSlot = null; if (SlotIndex == -1) { targetSlot = ItemSlot.GetNamed(storageObj.GetComponent <ItemStorage>(), NamedSlot); } else { targetSlot = ItemSlot.GetIndexed(storageObj.GetComponent <ItemStorage>(), SlotIndex); } //if used object is null, then empty hand was used ItemSlot fromSlot = null; if (usedObj == null) { fromSlot = SentByPlayer.Script.ItemStorage.GetActiveHandSlot(); } else { fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot; } var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot); ProcessInteraction(interaction, processorObj); } }
public override void Process(NetMessage msg) { var ComponentType = msg.ComponentType; var InteractionType = msg.InteractionType; var ProcessorObject = msg.ProcessorObject; var Intent = msg.Intent; var TargetObject = msg.TargetObject; var UsedObject = msg.UsedObject; var TargetBodyPart = msg.TargetBodyPart; var TargetVector = msg.TargetVector; var MouseButtonState = msg.MouseButtonState; var IsAltUsed = msg.IsAltUsed; var Storage = msg.Storage; var SlotIndex = msg.SlotIndex; var NamedSlot = msg.NamedSlot; var connectionPointA = msg.connectionPointA; var connectionPointB = msg.connectionPointB; var RequestedOption = msg.RequestedOption; var performer = SentByPlayer.GameObject; if (SentByPlayer == null || SentByPlayer.Script == null) { return; } if (SentByPlayer.Script.DynamicItemStorage == null) { if (InteractionType == typeof(AiActivate)) { LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = new AiActivate(performer, null, targetObj, Intent, msg.ClickTypes); ProcessInteraction(interaction, processorObj, ComponentType); } return; } if (InteractionType == typeof(PositionalHandApply)) { //look up item in active hand slot var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; CheckMatrixSync(ref targetObj); CheckMatrixSync(ref processorObj); var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(HandApply)) { var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot()?.ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; CheckMatrixSync(ref targetObj); CheckMatrixSync(ref processorObj); var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(AimApply)) { var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; CheckMatrixSync(ref processorObj); var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(MouseDrop)) { LoadMultipleObjects(new uint[] { UsedObject, TargetObject, ProcessorObject }); var usedObj = NetworkObjects[0]; var targetObj = NetworkObjects[1]; var processorObj = NetworkObjects[2]; CheckMatrixSync(ref targetObj); CheckMatrixSync(ref processorObj); var interaction = MouseDrop.ByClient(performer, usedObj, targetObj, Intent); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(HandActivate)) { LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; CheckMatrixSync(ref processorObj); var performerObj = SentByPlayer.GameObject; //look up item in active hand slot var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; var interaction = HandActivate.ByClient(performer, usedObject, usedSlot, Intent); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(InventoryApply)) { LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject, Storage }); var processorObj = NetworkObjects[0]; var usedObj = NetworkObjects[1]; var storageObj = NetworkObjects[2]; CheckMatrixSync(ref processorObj); ItemSlot targetSlot = null; if (SlotIndex == -1) { targetSlot = ItemSlot.GetNamed(storageObj.GetComponents <ItemStorage>()[msg.StorageIndexOnGameObject], NamedSlot); } else { targetSlot = ItemSlot.GetIndexed(storageObj.GetComponents <ItemStorage>()[msg.StorageIndexOnGameObject], SlotIndex); } //if used object is null, then empty hand was used ItemSlot fromSlot = null; if (usedObj == null) { fromSlot = SentByPlayer.Script.DynamicItemStorage.GetActiveHandSlot(); } else { fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot; } var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(TileApply)) { var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; CheckMatrixSync(ref processorObj); processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(SentByPlayer.GameObject, TargetVector, processorObj, usedSlot, usedObject, Intent, TileApply.ApplyType.HandApply); } else if (InteractionType == typeof(TileMouseDrop)) { LoadMultipleObjects(new uint[] { UsedObject, ProcessorObject }); var usedObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; CheckMatrixSync(ref processorObj); processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(SentByPlayer.GameObject, TargetVector, processorObj, null, usedObj, Intent, TileApply.ApplyType.MouseDrop); } else if (InteractionType == typeof(ConnectionApply)) { //look up item in active hand slot var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; CheckMatrixSync(ref targetObj); CheckMatrixSync(ref processorObj); var interaction = ConnectionApply.ByClient(performer, usedObject, targetObj, connectionPointA, connectionPointB, TargetVector, usedSlot, Intent); ProcessInteraction(interaction, processorObj, ComponentType); } else if (InteractionType == typeof(ContextMenuApply)) { LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var clientStorage = SentByPlayer.Script.DynamicItemStorage; var usedObj = clientStorage.GetActiveHandSlot().ItemObject; var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; CheckMatrixSync(ref targetObj); CheckMatrixSync(ref processorObj); var interaction = ContextMenuApply.ByClient(performer, usedObj, targetObj, RequestedOption, Intent); ProcessInteraction(interaction, processorObj, ComponentType); } }
public override IEnumerator Process() { var performer = SentByPlayer.GameObject; if (InteractionType == typeof(PositionalHandApply)) { //look up item in active hand slot var clientPNA = SentByPlayer.Script.playerNetworkActions; var usedSlot = HandSlot.ForName(clientPNA.activeHand); var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item; yield return(WaitFor(TargetObject, ProcessorObject)); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandApply)) { var clientPNA = SentByPlayer.Script.playerNetworkActions; var usedSlot = HandSlot.ForName(clientPNA.activeHand); var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item; yield return(WaitFor(TargetObject, ProcessorObject)); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var performerObj = SentByPlayer.GameObject; var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(AimApply)) { var clientPNA = SentByPlayer.Script.playerNetworkActions; var usedSlot = HandSlot.ForName(clientPNA.activeHand); var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item; yield return(WaitFor(ProcessorObject)); var processorObj = NetworkObject; var performerObj = SentByPlayer.GameObject; var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(MouseDrop)) { yield return(WaitFor(UsedObject, TargetObject, ProcessorObject)); var usedObj = NetworkObjects[0]; var targetObj = NetworkObjects[1]; var processorObj = NetworkObjects[2]; var performerObj = SentByPlayer.GameObject; var interaction = MouseDrop.ByClient(performer, usedObj, targetObj); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandActivate)) { yield return(WaitFor(ProcessorObject)); var processorObj = NetworkObject; var performerObj = SentByPlayer.GameObject; //look up item in active hand slot var clientPNA = SentByPlayer.Script.playerNetworkActions; var handSlot = HandSlot.ForName(clientPNA.activeHand); var activatedObject = clientPNA.Inventory[handSlot.equipSlot].Item; var interaction = HandActivate.ByClient(performer, activatedObject, handSlot); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(InventoryApply)) { yield return(WaitFor(ProcessorObject)); var processorObj = NetworkObject; var performerObj = SentByPlayer.GameObject; var pna = SentByPlayer.Script.playerNetworkActions; var handSlot = HandSlot.ForName(pna.activeHand); var handObject = pna.Inventory[handSlot.equipSlot].Item; var interaction = InventoryApply.ByClient(performer, pna.GetInventorySlot(processorObj), handObject, handSlot); ProcessInteraction(interaction, processorObj); } }