bool CanGrab(GameObject go, Collider2D col) { if (go.tag == "MultiBlock") { multiBlock = go.GetComponentInChildren <MultiBlock>(); grabDir = col.name; multiBlock.Activate(col.name); return(true); } if (go.tag == "Block" || go.tag == "Slippery" && dude.IsAttachedOrGrabbed()) { Block block = go.GetComponent <Block>(); if (!dude.HasActivated(block)) { dude.ActivateBlock(block); block.Activate(); } return(true); } if (go.tag == "Limb" && go.transform.parent != transform.parent) { var d = go.GetComponentInParent <Dude>(); if (d && d.isAlive) { d.GetGrabbed(); } return(true); } return(false); }
public void UseItem(Vector3 pos, Item item, BlockFace blockFace, Vector3 clickPos, Player player) { Block clicked = this.GetBlock(pos); Block replace = clicked.GetSideBlock(blockFace); if (clicked.Y > 255 || clicked.Y < 0 || clicked.ID == BlockFactory.AIR) { return; } PlayerInteractEventArgs playerInteractEvent = new PlayerInteractEventArgs(player, item, clicked, blockFace); if (player.IsAdventure) { playerInteractEvent.IsCancel = true; } if (Server.ServerConfig.SpawnProtection > 0 || player.Op) { //TODO } PlayerEvents.OnPlayerInteract(playerInteractEvent); if (playerInteractEvent.IsCancel) { return; } clicked.Update(World.BLOCK_UPDATE_TOUCH); if (!player.Sneaking && clicked.CanBeActivated && clicked.Activate(player, item)) { return; } if (!player.Sneaking && item.CanBeActivate && item.Activate(player, this, clicked, blockFace, clickPos)) { if (item.Count <= 0) { return; } } if (!item.CanBePlace) { return; } Block hand = item.Block; hand.Position = replace.Position; if (clicked.CanBeReplaced) { replace = clicked; hand.Position = replace.Position; } //TODO : near by entity check //TODO : check can place on BlockPlaceEventArgs blockPlaceEvent = new BlockPlaceEventArgs(player, hand, replace, clicked, item); //TODO : check spawn protection BlockEvents.OnBlockPlace(blockPlaceEvent); if (blockPlaceEvent.IsCancel) { return; } hand.Place(clicked, replace, blockFace, clickPos, player, item); LevelSoundEventPacket pk = new LevelSoundEventPacket(); pk.Position = (Vector3)hand.Position; pk.Sound = LevelSoundEventPacket.SOUND_PLACE; pk.ExtraData = hand.RuntimeId; pk.Pitch = 1; player.SendPacket(pk); //TODO : near players }
private void MoveBackToPool(Block block) { // TODO: Move back to pool? block.Activate(false); }
private void SpawnBlock(Block block) { block.transform.position = _spawnPoint.position; block.Activate(true); }
public void UseItem(Vector3 pos, Item item, BlockFace blockFace, Vector3 clickPos, Player player) { Block clicked = this.GetBlock(pos); Block replace = clicked.GetSideBlock(blockFace); if (clicked.Y > 255 || clicked.Y < 0 || clicked.ID == BlockIDs.AIR) { return; } PlayerInteractEventArgs args = new PlayerInteractEventArgs(player, item, clicked, blockFace); if (player.IsAdventure) { args.IsCancel = true; } /*if (Server.ServerConfig.SpawnProtection > 0 || player.Op) * { * //TODO * }*/ Server.Instance.Event.Player.OnPlayerInteract(this, args); if (args.IsCancel) { return; } clicked.OnTouchUpdate(); if (!player.Sneaking && clicked.CanBeActivated && clicked.Activate(player, item)) { return; } if (!player.Sneaking && item.Activate(player, this, clicked, blockFace, clickPos)) { if (item.Count <= 0) { return; } } Block hand = item.Block; if (hand.ID == BlockIDs.AIR) { return; } hand.Damage = item.Damage; hand.SetPosition(replace.GetPosition()); if (clicked.CanBeReplaced) { replace = clicked; hand.SetPosition(replace.GetPosition()); } //TODO : near by entity check //TODO : check can place on BlockPlaceEventArgs args1 = new BlockPlaceEventArgs(player, hand, replace, clicked, item); //TODO : check spawn protection Server.Instance.Event.Block.OnBlockPlace(this, args1); if (args1.IsCancel) { this.SendBlocks(Server.Instance.GetOnlinePlayers(), new Vector3[] { hand.ToVector3() }); return; } hand.Place(clicked, replace, blockFace, clickPos, player, item); LevelSoundEventPacket pk = new LevelSoundEventPacket { Position = hand.ToVector3(), Sound = LevelSoundEventPacket.SOUND_PLACE, ExtraData = hand.RuntimeId }; Server.Instance.BroadcastSendPacket(pk); //TODO : near players }