Exemplo n.º 1
0
        public bool WillInteract(PositionalHandApply interaction, NetworkSide side)
        {
            if (DefaultWillInteract.Default(interaction, side) == false)
            {
                return(false);
            }
            // must be targeting us
            if (interaction.TargetObject != gameObject)
            {
                return(false);
            }
            // allowed to attack due to cooldown?
            // note: actual cooldown is started in WeaponNetworkActions melee logic on server side,
            // clientPredictInteraction on clientside
            if (side == NetworkSide.Client && Cooldowns.IsOn(interaction, CooldownID.Asset(CommonCooldowns.Instance.Melee, side)))
            {
                return(false);
            }

            bool LocalItemCheck()
            {
                return(interaction.HandObject.OrNull()?.Item().CanBeUsedOnSelfOnHelpIntent ?? false);
            }

            // not punching unless harm intent
            if (interaction.Intent != Intent.Harm && !LocalItemCheck())
            {
                return(false);
            }

            // if attacking tiles, only some layers are allowed to be attacked
            if (interactableTiles != null)
            {
                var tileAt = interactableTiles.LayerTileAt(interaction.WorldPositionTarget, true);

                // Nothing there, could be space?
                if (tileAt == null)
                {
                    return(false);
                }

                if (attackableLayers.Contains(tileAt.LayerType) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
    public bool WillInteract(PositionalHandApply interaction, NetworkSide side)
    {
        //are we in range
        if (!DefaultWillInteract.Default(interaction, side))
        {
            return(false);
        }
        //must be targeting us
        if (interaction.TargetObject != gameObject)
        {
            return(false);
        }
        //allowed to attack due to cooldown?
        //note: actual cooldown is started in WeaponNetworkActions melee logic on server side,
        //clientPredictInteraction on clientside
        if (Cooldowns.IsOn(interaction, CooldownID.Asset(CommonCooldowns.Instance.Melee, side)))
        {
            interaction = PositionalHandApply.Invalid;
            return(true);
        }

        //not punching unless harm intent
        if (interaction.Intent != Intent.Harm)
        {
            return(false);
        }

        //if attacking tiles, only some layers are allowed to be attacked
        if (interactableTiles != null)
        {
            var tileAt = interactableTiles.LayerTileAt(interaction.WorldPositionTarget, true);

            //Nothing there, could be space?
            if (tileAt == null)
            {
                return(false);
            }

            if (!attackableLayers.Contains(tileAt.LayerType))
            {
                return(interaction.Intent == Intent.Harm && harmIntentOnlyAttackableLayers.Contains(tileAt.LayerType));
            }
        }

        return(true);
    }
Exemplo n.º 3
0
    public bool WillInteract(PositionalHandApply interaction, NetworkSide side)
    {
        //are we in range
        if (!DefaultWillInteract.Default(interaction, side))
        {
            return(false);
        }
        //must be targeting us
        if (interaction.TargetObject != gameObject)
        {
            return(false);
        }
        //allowed to attack due to cooldown?
        var playerScript = interaction.Performer.GetComponent <PlayerScript>();

        if (!playerScript.weaponNetworkActions.AllowAttack)
        {
            return(false);
        }

        //not punching unless harm intent
        if (interaction.HandObject == null && interaction.Intent != Intent.Harm)
        {
            return(false);
        }

        //if attacking tiles, only some layers are allowed to be attacked
        if (interactableTiles != null)
        {
            var tileAt = interactableTiles.LayerTileAt(interaction.WorldPositionTarget);
            if (!attackableLayers.Contains(tileAt.LayerType))
            {
                return(interaction.Intent == Intent.Harm && harmIntentOnlyAttackableLayers.Contains(tileAt.LayerType));
            }
        }

        return(true);
    }