/// <summary> /// Try to build cable /// </summary> private void Build() { if (startPoint == endPoint || Mathf.Abs(startPointVector.x - endPointVector.x) > 2.5 || Mathf.Abs(startPointVector.y - endPointVector.y) > 2.5) { return; } GameObject target = MouseUtils.GetOrderedObjectsUnderMouse().FirstOrDefault(); ConnectionApply cableApply = ConnectionApply.ByLocalPlayer(target, startPoint, endPoint, null); //if HandObject is null, then its an empty hand apply so we only need to check the receiving object if (cableApply.HandObject != null) { //get all components that can contains CableApply interaction var cableAppliables = cableApply.HandObject.GetComponents <MonoBehaviour>() .Where(c => c != null && c.enabled && (c is IBaseInteractable <ConnectionApply>)); foreach (var cableAppliable in cableAppliables.Reverse()) { var hap = cableAppliable as IBaseInteractable <ConnectionApply>; if (hap.ClientCheckAndTrigger(cableApply)) { return; } } } }
/// <summary> /// Try to build cable /// </summary> private void Build() { if (startPoint == endPoint || target == null) { return; } Vector2 targetVector = (connectionPointRenderers[endPoint].transform.position - transform.position); ConnectionApply cableApply = ConnectionApply.ByLocalPlayer(target, startPoint, endPoint, targetVector); //if HandObject is null, then its an empty hand apply so we only need to check the receiving object if (cableApply.HandObject != null) { //get all components that can contains CableApply interaction var cableAppliables = cableApply.HandObject.GetComponents <MonoBehaviour>() .Where(c => c != null && c.enabled && (c is IBaseInteractable <ConnectionApply>)); foreach (var cableAppliable in cableAppliables.Reverse()) { var hap = cableAppliable as IBaseInteractable <ConnectionApply>; if (hap.ClientCheckAndTrigger(cableApply)) { return; } } } }
/// <summary> /// Try to build cable /// </summary> private void Build() { if (startPoint == endPoint || target == null) { return; } var Register = PlayerManager.LocalPlayer.RegisterTile(); Vector3 Position = Vector3.zero; if (Register.Matrix.MatrixMove == null) { Position = cablePlacementVisualisation.transform.position + (new Vector3(0.5f, 0.5f, 0)); } else { var InQuaternion = Register.Matrix.MatrixMove.FacingOffsetFromInitial.Quaternion; Position = cablePlacementVisualisation.transform.position + (InQuaternion * new Vector3(0.5f, 0.5f, 0)); } Vector2 targetVector = Position.ToLocal(PlayerManager.LocalPlayer.RegisterTile().Matrix); // transform.position ( - transform.position); //TODO? what? is this ConnectionApply cableApply = ConnectionApply.ByLocalPlayer(target, startPoint, endPoint, targetVector); //if HandObject is null, then its an empty hand apply so we only need to check the receiving object if (cableApply.HandObject != null) { //get all components that can contains CableApply interaction var cableAppliables = cableApply.HandObject.GetComponents <MonoBehaviour>() .Where(c => c != null && c.enabled && (c is IBaseInteractable <ConnectionApply>)); foreach (var cableAppliable in cableAppliables.Reverse()) { var hap = cableAppliable as IBaseInteractable <ConnectionApply>; if (hap.ClientCheckAndTrigger(cableApply)) { return; } } } }
/// <summary> /// Default WIllInteract logic for ConnectionApply interactions /// </summary> public static bool ConnectionApply(ConnectionApply interaction, NetworkSide side) { return(Validations.CanApply(interaction, side)); }
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 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(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(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.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 = ConnectionApply.ByClient(performer, usedObject, targetObj, connectionPointA, connectionPointB, TargetVector, usedSlot, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(ContextMenuApply)) { LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var clientStorage = SentByPlayer.Script.ItemStorage; var usedObj = clientStorage.GetActiveHandSlot().ItemObject; var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = ContextMenuApply.ByClient(performer, usedObj, targetObj, RequestedOption, Intent); ProcessInteraction(interaction, processorObj); } }
public static bool CanApply(ConnectionApply toValidate, NetworkSide side, bool allowSoftCrit = false, ReachRange reachRange = ReachRange.Standard, bool isPlayerClick = false) => CanApply(toValidate.Performer, toValidate.TargetObject, side, allowSoftCrit, reachRange, toValidate.TargetVector, isPlayerClick: isPlayerClick);