private void AdvanceMovement(Vector3 tempOrigin, Vector3 tempGoal)
    {
        //Natural throw ending
        if (IsBeingThrown && ShouldStopThrow)
        {
//			Logger.Log( $"{gameObject.name}: Throw ended at {serverState.WorldPosition}" );
            serverState.ActiveThrow = ThrowInfo.NoThrow;
            //Change spin when we hit the ground. Zero was kinda dull
            serverState.SpinFactor = ( sbyte )(-serverState.SpinFactor * 0.2f);
            //todo: ground hit sound
        }

        serverState.WorldPosition = tempGoal;
        //Spess drifting is perpetual, but speed decreases each tile if object has landed (no throw) on the floor
        if (!IsBeingThrown && !MatrixManager.IsEmptyAt(Vector3Int.RoundToInt(tempOrigin)))
        {
            //on-ground resistance
            serverState.Speed = serverState.Speed - (serverState.Speed * 0.10f) - 0.5f;
            if (serverState.Speed <= 0.05f)
            {
                StopFloating();
            }
            else
            {
                NotifyPlayers();
            }
        }
    }
Exemple #2
0
    private bool PushInternal(
        Vector2Int direction, bool isNewtonian = false, float speed = Single.NaN, bool followMode = false, bool ignorePassable = false
        , GameObject context = null)
    {
        if (!float.IsNaN(speed) && speed <= 0)
        {
            return(false);
        }

        Vector3Int clampedDir    = direction.NormalizeTo3Int();
        Vector3Int origin        = ServerPosition;
        Vector3Int roundedTarget = origin + clampedDir;

        if (!ignorePassable && !MatrixManager.IsPassableAtAllMatrices(origin, roundedTarget, true, includingPlayers: !followMode, context: context))
        {
            return(false);
        }

        if (isNewtonian && !MatrixManager.IsSlipperyOrNoGravityAt(roundedTarget, registerTile.Matrix.MatrixInfo))
        {
            return(false);
        }

        if (!followMode && MatrixManager.IsEmptyAt(roundedTarget, true, registerTile.Matrix.MatrixInfo))
        {
            serverState.WorldImpulse = (Vector3)clampedDir;
        }
        else
        {
            serverState.WorldImpulse = Vector2.zero;
        }

        if (!float.IsNaN(speed) && speed > 0)
        {
            serverState.Speed = speed;
        }
        else
        {
            serverState.Speed = PushPull.DEFAULT_PUSH_SPEED;
        }

        if (followMode)
        {
            serverState.IsFollowUpdate = true;
            SetPosition(roundedTarget);
            serverState.IsFollowUpdate = false;
        }
        else
        {
            SetPosition(roundedTarget);
        }

        return(true);
    }
Exemple #3
0
    public bool Push(Vector2Int direction)
    {
        Vector2 target = ( Vector2 )serverState.WorldPosition + direction;

        serverState.Speed = PushSpeed;
        if (MatrixManager.IsEmptyAt(Vector3Int.RoundToInt(target)))
        {
            serverState.Impulse = direction;
        }

        SetPosition(target);
        return(true);
    }
Exemple #4
0
    public bool PredictivePush(Vector2Int direction)
    {
//		return false;
        Vector2 target = ( Vector2 )clientState.WorldPosition + direction;

        clientState.Speed = PushSpeed;
        if (MatrixManager.IsEmptyAt(Vector3Int.RoundToInt(target)))
        {
            clientState.Impulse = direction;
        }

        clientState.WorldPosition = target;
        return(true);
    }
Exemple #5
0
    public bool Push(Vector2Int direction, float speed = Single.NaN, bool followMode = false)
    {
        Vector3Int origin        = Vector3Int.RoundToInt((Vector2)serverState.WorldPosition);
        var        target        = ( Vector2 )serverState.WorldPosition + direction;
        var        roundedTarget = target.RoundToInt();

        if (!MatrixManager.IsPassableAt(origin, roundedTarget, includingPlayers: !followMode))
        {
            return(false);
        }

        if (!followMode && MatrixManager.IsEmptyAt(roundedTarget))
        {
            serverState.Impulse = direction;
        }
        else
        {
            serverState.Impulse = Vector2.zero;
        }

        if (!float.IsNaN(speed) && speed > 0)
        {
            serverState.Speed = speed;
        }
        else
        {
            serverState.Speed = PushPull.DEFAULT_PUSH_SPEED;
        }

        if (followMode)
        {
            serverState.IsFollowUpdate = true;
            SetPosition(roundedTarget);
            serverState.IsFollowUpdate = false;
        }
        else
        {
            SetPosition(target);
        }
        return(true);
    }
Exemple #6
0
    public bool PredictivePush(Vector2Int target, float speed = Single.NaN, bool followMode = false)
    {
        Poke();
        Vector3Int target3int = target.To3Int();

        Vector3Int currentPos = ClientPosition;

        if (!followMode && !MatrixManager.IsPassableAtAllMatrices(target3int, target3int, isServer: false))
        {
            return(false);
        }

        if (!followMode && MatrixManager.IsEmptyAt(target3int, false, registerTile.Matrix.MatrixInfo))
        {
            predictedState.WorldImpulse = target - currentPos.To2Int();
        }
        else
        {
            predictedState.WorldImpulse = Vector2.zero;
        }

        if (!float.IsNaN(speed) && speed > 0)
        {
            predictedState.Speed = speed;
        }
        else
        {
            predictedState.Speed = PushPull.DEFAULT_PUSH_SPEED;
        }

        predictedState.MatrixId      = MatrixManager.AtPoint(target3int, false, registerTile.Matrix.MatrixInfo).Id;
        predictedState.WorldPosition = target3int;

        //		Lerp to compensate one frame delay
        Lerp();

        return(true);
    }
Exemple #7
0
    public bool PredictivePush(Vector2Int target, float speed = Single.NaN, bool followMode = false)
    {
        Poke();
        Vector3Int target3int = target.To3Int();

        Vector3Int currentPos = ClientPosition;

        if (!followMode && !MatrixManager.IsPassableAt(target3int, target3int))
        {
            return(false);
        }

        if (!followMode && MatrixManager.IsEmptyAt(target3int))
        {
            predictedState.Impulse = target - currentPos.To2Int();
        }
        else
        {
            predictedState.Impulse = Vector2.zero;
        }

        if (!float.IsNaN(speed) && speed > 0)
        {
            predictedState.Speed = speed;
        }
        else
        {
            predictedState.Speed = DefaultPushSpeed;
        }

        predictedState.MatrixId      = MatrixManager.AtPoint(target3int).Id;
        predictedState.WorldPosition = target3int;

//		Lerp to compensate one frame delay
        Lerp();

        return(true);
    }